step1:首先安裝 Oracle 免費的資料庫版本作為測試:Oracle Database 11g Express Edition,安裝最後將system的密碼修改為oracle作為測試用。

step2:下載 AppServ 2.5.10 安裝後

  • 1. 修改php.ini檔,將;extension=php_oci8.dll 中的 ; 除去
  • 2. 修改php.ini檔,設定 session.save_path = "c:/temp"
  • 3. 並重啟apache:
    C:\AppServ\Apache2.2\bin>httpd -k restart

step3:建立 PHP 連結 Oracle 資料庫的測試程式:oracle_conn_test.php

<?php

$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA=(SID=XE)))";

if ($c = OCILogon ( "system", "oracle", $db )) {
        
        echo "Successfully connected to Oracle.\n";
        
        OCILogoff ( $c );

} else {
        
        $err = OCIError ();
        
        echo "Connection failed." . $err [text];

}

?>

 

MIS 發表在 痞客邦 留言(0) 人氣()

在撰寫 PHP 程式時,error_reporting($Constant) 是指定PHP程式執行過程中,發生錯誤時,錯誤資訊產出在網頁的時機,只需要設定錯誤的等級,回報的錯誤將會有所不同。

參數說明:

Value

Constant

Description

Note

1 E_ERROR 執行時期致命的錯誤  
2 E_WARNING 執行時期錯誤警告  
4 E_PARSE 編譯時的程式剖析錯誤  
8 E_NOTICE 執行時期的提醒  
16 E_CORE_ERROR PHP 引擎啟動執行時產生的致命錯誤  
32 E_CORE_WARNING PHP 引擎啟動執行時產生的警告 since PHP 4
64 E_COMPILE_ERROR 致命的編譯時錯誤 since PHP 4
128 E_COMPILE_WARNING 致命的編譯時警告 since PHP 4
256 E_USER_ERROR 使用者定義的錯誤 since PHP 4
512 E_USER_WARNING 使用者定義的警告 since PHP 4
1024 E_USER_NOTICE 使用者定義的提醒 since PHP 4
2048 E_STRICT 編碼標準化警告(建議如何修改以向前兼容) since PHP 5.4
4096 E_RECOVERABLE_ERROR 接近致命的運行時錯誤,若未被捕獲則視同E_ERROR since PHP 5.2.0
8192 E_DEPRECATED Run-time notices. Enable this to receive warnings about code that will not work in future versions. since PHP 5.3.0
16384 E_USER_DEPRECATED User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error(). since PHP 5.3.0
30719 E_ALL 所有的錯誤、警告 32767 in PHP 6, 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously

 



範例:

1/0 會產生一個 WARNING 的錯誤等級,先將程式錯誤等級設為 E_ERROR ,則不會有錯誤訊息出現,因為已經被忽略了。

error_reporting(E_ERROR);
printf("%d\n", 1/0);

error_reporting(E_WARNING);
printf("%d\n", 1/0);


 

輸出結果:

0
Warning: Division by zero in C:\AppServ\www\test.php on line 6
0 



參考文件:
http://tw2.php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-error

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

Windows Server AD 是一個 LADP 伺服器,可讓您將資訊儲存在目錄服務中,在資料庫中進行查詢,並可以使用他來作為身份的認證授權。

使用PHP撰寫程式難免會遇到需要作身份認證的問題,除了自行撰寫這部份程式的選擇外,PHP 的函式庫中亦提供了標準的 LDAP 函式,如果公司組織中已經有架設 Windows 2K/2003 網域的環境 ,將身份認證的工作交由 Windows AD 亦是一個不錯的選擇。

在寫此程式前,請先到 php.ini 檔,打開 php_ldap.dll 的功能(預設是關閉的),否則執行時會出現未定義函數的錯誤訊息。(打開後記得要重啟apache服務,功能才會生效)

PHP可以一筆一筆撈出AD資料(ldap_first_entry / ldap_next_entry),然後將每一筆資料的欄位屬性解析出來(ldap_get_values)。

實作如下:

案例環境說明:
1.公司組織內有一個Windows 網域,名稱為: domain.com。
2.domain.com 的網域有兩部網域主控站(DC)分別為:dc.domain.com、dc2.domain.com。
3.PHP版本:5.2.1 由下載 AppServ 2.5.10 安裝

PHP程式碼範例:

<?php
$domain = 'domain.com'; //設定網域名稱
$dn="dc=domain,dc=com";

$user = 'administrator'; //設定欲認證的帳號名稱
$password = 'password'; //設定欲認證的帳號密碼

// 使用 ldap bind 
$ldaprdn = $user . '@' . $domain; 
// ldap rdn or dn 
$ldappass = $password; // 設定密碼

// 連接至網域控制站
$ldapconn = ldap_connect($domain) or die("無法連接至 $domain");

// 如果要特別指定某一部網域主控站(DC)來作認證則上面改寫為
//$ldapconn = ldap_connect('dc.domain.com) or die("無法連接至 dc.domain.com"); 
// 或 
// $ldapconn = ldap_connect('dc2.domain.com)or die("無法連接至 dc2.domain.com"); 

//以下兩行務必加上,否則 Windows AD 無法在不指定 OU 下,作搜尋的動作
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);

if ($ldapconn) 
{ 
        // binding to ldap server
        echo("連結$domain <br>".$ldaprdn.",".$ldappass."<br>");
        $ldapbind = ldap_bind($ldapconn, $user, $password);     
        //$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);     
        //$ldapbind = ldap_bind($ldapconn);     
        // verify binding     
        if ($ldapbind) 
        {         
                $filter = "(sAMAccountName=$user)";        
                $result = @ldap_search($ldapconn, $dn, $filter);        
                if($result==false) 
                        echo "認證失敗(找不到 $user)";        
                else 
                {            
                        echo "認證成功...";             
                        //取出帳號的所有資訊             
                        $entries = ldap_get_entries($ldapconn, $result);
                        $data = ldap_get_entries( $ldapconn, $result );
                        
                        echo $data ["count"] . " entries returned\n";
                        
                        for($i = 0; $i <= $data ["count"]; $i ++) {
                                for($j = 0; $j <= $data [$i] ["count"]; $j ++) {
                                        echo "[$i:$j]=".$data [$i] [$j] . ": " . $data [$i] [$data [$i] [$j]] [0] . "\n<br>";
                                }
                        }                            
                }    
        } 
        else 
        {         
                echo "認證失敗...";     
        } 
}
//關閉LDAP連結
ldap_close($ldapconn);
?> 
文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

本篇文章主要在介紹 Oracle SQL Loader: SQLLDR 的使用方法,如何將檔案資料快速上載到 Oracle 資料庫的 Table 中。

  • Input data file for SQL*Loader

準備要匯入的資料,以逗點''作為每一欄位的分隔,每一行則為每一筆資料。以下列的來說,則有六筆資料,每一筆資料則有 4 個欄位值。

C:\tmp\oracle>type employee.txt
100,Thomas,Sales,5000
200,Jason,Technology,5500
300,Mayla,Technology,7000
400,Nisha,Marketing,9500
500,Randy,Technology,6000
501,Ritu,Accounting,5400

 

  • SQL*Loader Control File

依匯入資料的格式,作好SQL Loader 控制檔

C:\tmp\oracle>type employee.ctl
load data
 infile 'employee.txt'
 into table employee
 fields terminated by ","
 ( id, name, dept, salary )

參數說明如下:

  • infile – 資料檔放置的路徑及檔名
  • into table – 要載入到那一個 table name
  • fields terminated by – 欄位與欄位之間的分隔符號
  • ( id, name, dept, salary ) – 列出是要將資料放入那幾個欄位

 

  • 在資料庫中建立一個table:employee
SQL> create table employee
(
  id integer,
  name varchar2(10),
  dept varchar2(15),
  salary integer,
  hiredon date
)

 

  •  執行 sqlldr 上載資料
C:\tmp\oracle>sqlldr scott/tiger control=employee.ctl
SQL*Loader: Release 11.2.0.2.0 - Production on 星期四 10月 25 14:16:39 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
Commit point reached - logical record count 5
Commit point reached - logical record count 6

 

  • 驗證一下資料是否有上載到資料庫的 table:employee 中

sqlldr-employee.png  

 

  • 若有新的資料,要加入到 table:employee ,則必須在控制檔增加 參數:append
C:\tmp\oracle>type employee-append.ctl
load data
 infile 'employee-append.txt'
 append
 into table employee
 fields terminated by ","
 ( id, name, dept, salary )

 

要增加的資料如下:

C:\tmp\oracle>type employee-append.txt
600,Ritu,Accounting,5400
700,Jessica,Marketing,7800

 

  • 再執行一次 sqlldr
C:\tmp\oracle>sqlldr edi/edi control=employee-append.ctl
SQL*Loader: Release 11.2.0.2.0 - Production on 星期四 10月 25 14:35:30 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
Commit point reached - logical record count 1
Commit point reached - logical record count 2

 

  • 再次驗證資料

sqlldr-employee-append.png  

 

  • 若要上載到資料庫的資料格式是固定位置如下:
200JasonTechnology550001-02-2005
300MaylaTechnology700010-08-2000
500RandyTechnology600001-01-2007

 

  • 控制檔可以修改如下:
C:\tmp\oracle>type employee-fixed.ctl
load data
 infile 'employee-fixed.txt'
 into table employee
 fields terminated by ","
 ( id position(1:3), name position(4:8), dept position(9:18), salary position(19:22),hiredon position(23:32) DATE "DD-MM-YYYY")

 

驗證資料:

sqlldr-employee-fixed.png  

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

  Oracle 從 9i 開始提供了 Flashback Query 功能,可用於恢復錯誤的 DML 操作。在 Oracle 10g 中對 Flashback Query 做了較大改進,不再局限於 Flashback Query ,還可用於恢復錯誤的 DDL(Drop) 操作。

  Flashback Query  是透過一個新的 Package:DBMS_FLASH 來實現。DBA 可使用 Flashback Query 可以及時取得錯誤操作 DML(Delete、Update、Insert) 在當前某一時間點資料庫的映射視圖,DBA 可以利用系統時間或系統改變號(SCN:System Change Number)來指定這個唯讀視圖,並可以針對錯誤進行相應的恢復措施。

  以下來實作一下整個過程:

1. 可以先用下列 SQL 語法來查詢 recyclebin 是否有被 drop 的 table,此時應該是沒有的。

SQL>select object_name,original_name,operation,type,droptime from recyclebin;

 2. 建立測試的 table : demo_users

create table demo_users (id char(2), name varchar2(10));
insert into demo_users values ('01','David');
insert into demo_users values ('02','Scott');
select * from demo_users;

 可以查詢到有兩筆資料在 demo_users 的資料表( Table )裡。

recyclebin_table_select_ok.png  

3. 刪除資料表 demo_users 並在查詢資源回收筒中是否有被刪除的資料表。

SQL>drop table demo_users;
SQL>SELECT object_name,original_name,operation,type,droptime 
FROM recyclebin;

 此時發現有一筆資料

recyclebin_table.png  

4. 回復此資料表 demo_users

SQL>flashback table demo_users to before drop ;

 這樣子就可以將資料表 Table:demo_users 回復了。

      Oracle Flashback Database 的特性允許透過 SQL 語法 Flashback Database 語句,讓資料庫回到當前的某一個時間點或者SCN,而不需要做時間點的恢復。Flashback Database 可以迅速將資料庫回到錯誤操作或人為錯誤的前一個時間點,如 Ctrl+Z 的 "復原" 操作,可以不利用備份資料 (RM) 就可以快速的實現以時間點為基礎來作恢復。Oracle 通過新建的 Flashback Logs,記錄資料庫的 Flashback 操作。如果希望能 Flashback Database,需要設置如下參數:DB_RECOVER_FILE_DEST日誌的存放位置, DB_RECOVER_FILE_DEST_SIZE恢復區的大小。在建立資料庫的時候,Oracle將自動建立恢復區,但預設是關閉的,需要執行 alter database flashback on 的指令來啟動。

 

  • 若要回復整個資料庫到當前的某一個時間點,SQL 指令為:
SQL>flashback database to time to_timestamp(xxx);
  •  若要回復某一個資料表 Table 到當前的某一個時間點,SQL 指令為:
SQL> flashback table table_name to timestamp 
to_timestamp('2006-05-30 14:21:43','yyyy-mm-dd hh24:mi:ss');

  • 有關scn值就是記錄在這個table裡:flashback_transaction_query


  table_flashback_transaction_query.png  

參考文獻: http://blog.roodo.com/mywork/archives/1684525.html

 

Configuring Your Database for Oracle Flashback Transaction Query

To configure your database for the Oracle Flashback Transaction Query feature, you or your database administrator must do the following:

  • Ensure that Oracle Database is running with version 10.0 compatibility.

  • Enable supplemental logging:

    ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

 

Configuring Your Database for Flashback Transaction

To configure your database for the Flashback Transaction feature, you or your database administrator must do the following:

  • With the database mounted but not open, enable ARCHIVELOG:

    ALTER DATABASE ARCHIVELOG;
    
  • Open at least one archive log:

    ALTER SYSTEM ARCHIVE LOG CURRENT;
    
  • If not done already, enable supplemental logging:

    ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
    

 

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

  Oracle 的 External Tables 被定義為可以讀取資料庫外部的資料,如:文字檔案、CSV...等檔案;您可以把它當成是一個可以不需事先將資料導入( load in ) 資料庫就可以進行 Query 的 View,您可以針對 external table 的 data 作 select、join、sort 等動作,也可以對 external tables 建立 views,synonymes。但是,你不能對這些 external 作DML 的動作(UPDATE, INSERT, or DELETE),也就是只能讀取( Read Only ),而且也不能建立 index。

下面的範例中,將對不同格式 Comma delimitedFixed field length 的檔案來作示範。

Step I: 建立 External Tables 所需的文字檔

Comma delimited (文字檔案、CSV) 檔案資料格式如下,各欄位以 ',' 作為區隔

200,Whalen,Administration,1987.09.17 00:00:00
201,Hartstein,Marketing,1996.02.17 00:00:00
202,Fay,Marketing,1997.08.17 00:00:00
114,Raphaely,Purchasing,1994.12.07 00:00:00
115,Khoo,Purchasing,1995.05.18 00:00:00
116,Baida,Purchasing,1997.12.24 00:00:00
117,Tobias,Purchasing,1997.07.24 00:00:00
118,Himuro,Purchasing,1998.11.15 00:00:00

 Step II: 建立 Directory 物件 

CREATE OR REPLACE DIRECTORY ext_dir as 'C:\oraclexe\ExternalTable';

為了預防 ORA-29913 的錯誤,因此需授權需要讀取資料的人有讀/寫的權限

GRANT read, write on directory ext_dir to polin;

Step III: 建立 External Tables

CREATE TABLE ext_table_csv (
  employee_id     number(6),
  last_name       varchar2(25),
  department_name  varchar2(30),
  hire_date       date
)
ORGANIZATION EXTERNAL (
  type              oracle_loader
  default directory ext_dir
  access parameters (
    records delimited  by newline
    fields  terminated by ','
    missing field values are null
    (employee_id, last_name, department_name,hire_date CHAR(19) DATE_FORMAT DATE MASK "YYYY.MM.DD HH24:MI:SS")
  )
  location ('user_dept.csv')
)
reject limit unlimited;

ACCESS PARAMETERS 參數指定,此 External Tables 的格式,以 NEWLINE為每筆資料的分隔,每個欄位用 ',' 分隔,若有無值的狀況,當成 NULL,四個欄位分別為 employee_id,last_name,department_name,hire_date,其中 hire_date 的 format 指定為 "YYYY.MM.DD HH24:MI:SS"

Step IV: Querying Data

select * from ext_table_csv order by department_name;

查詢出來的資料如下圖:
externalTableQuery.png  

Fixed field length 檔案資料格式如下,各欄位的資料長度是固定的,以欄位的起始位址作為區隔,如前兩碼1-2是國家代碼,第3碼是區域碼

AR2
AU3
BE1
BR2
CA2
CH1
CN3
DE1

 Fixed field length所需建立 External Tables 的語法如下:

CREATE TABLE ext_table_fixed (
   country_id CHAR(2),
   region_id NUMBER(1)
)
ORGANIZATION EXTERNAL (
   type       oracle_loader
   default directory ext_dir
   access parameters (
     records delimited by newline
     fields (
       country_id position(1:2) ,
       region_id  position(3:4)
    )
  )
  location ('country_region.txt')
)
reject limit unlimited;

延伸討論

若我們將 External Table 實體目錄 'C:\oraclexe\ExternalTable' 下的檔案更名或刪除,則系統會有錯誤訊息,因此可以得知,它是直接去讀取該目錄下的檔案內容。

externalTableQueryError.png  

Populating Tables using the INSERT command
如果您想對這些資料作進一步的操作,可以是使用"insert into ... select from" 的語法來將這些資料加入 Database 中,這種方式比 SQL*Loader的效率好很多。

Dropping External Tables
如果你不需要這些 External Tables,可以使用 DROP TABLE statement 將它們移除,不過這不會影響到存在於資料庫外的檔案。

Summary
基本上你也可以使用 SQL*Loader來完成以上的事情,但是相較之下 External Tables 彈性跟效率都比較好。External Table尚有其他的定義和使用注意事項( Ex. Performance ),在使用前最好是先評估一下。

參考文獻
External tables in Oracle http://www.adp-gmbh.ch/ora/misc/ext_table.html

MIS 發表在 痞客邦 留言(0) 人氣()

關於Express的版本

  • SQL Server Express (x86 和 x64)

單純只有SQL Server Express資料庫系統。與with Tools, with Advanced Services兩版本最大差異就是沒有SQL Server Management Studio 2008 Express(SSMSE)管理工具。也就是說,如果你的這台資料庫伺服器只需要讓遠端Client連接進來進行相關作業,根本不會有本機使用 SSMSE管理工具的機會,那就很適合這個版本,小又單純。

  • SQL Server Express with Tools (x86 和 x64)


這是2008 Express + SSMSE管理工具的版本。也就是你有需要在資料庫伺服器本機做一些組態設定…等相關操作,那你就安裝這個版本。

  • SQL Server Express with Advanced Services (x86 和 x64)


除了SQL Server Express與SSMSE管理工具外,還提供「全文索引」及「報表伺服器」兩大功能。

SQL Server 2008 Express的限制

  在開始進入安裝之前,我們要先了解2008 Express的一些限制。在2008 Express中除了進階軟體功能的限制外(例如:壓縮),另外更重要的就是硬體上的限制,在功能差異方面,請參考上一節的註解「SQL Server 2008版本功能差異」。而2008 Express硬體的限制延續2005 Express一樣的限制:

  • CPU數目:1
  • 記憶體上限:1 GB
  • 64位元支援:Windows on Windows (WOW)
  • 資料庫大小:4 GB

2008 Express 的限制是「單一mdf檔案的大小」有限制,所以如果你預計你的資料庫大小會超過4 GB時,除了購買正式版外,在2008 Express上你可以多開幾個資料庫檔案避開這部分的限制,例如:products.mdf、members.mdf,但唯一麻煩可能是程式就要設計成 「跨資料庫存取」的方式。

SQL Server 2008 Express 安裝前環境準備

在開始安裝SQL Server Express之前,必須先準備好作業系統.NET Framework環境,所以我們必須先行下載以下套件(最好依順序安裝):
 

  • Microsoft .Net Framework 3.5 SP1:下載點(啟動載入器)、下載點(完整套件)
  • Windows Installer 4.5:下載點 (需重開機)
  • Windows PowerShell 1.0:
    x86 版 Windows XP Service Pack 2 的 Windows PowerShell 1.0:下載點
    x64 版 Windows XP Service Pack 2 的 Windows PowerShell 1.0:下載點
    x86 版 Windows Server 2003 Service Pack 1 的 Windows PowerShell 1.0:下載點
    x64 版 Windows Server 2003 的 Windows PowerShell 1.0:下載點
    Itanium 版 Windows Server 2003 Service Pack 1 的 Windows PowerShell 1.0:下載點
    x86 版 Windows Vista 的 Windows PowerShell 1.0:下載點
    x64 版 Windows Vista 的 Windows PowerShell 1.0:下載點


要比較注意的只有PowerShell一項,請選擇正確的版本對應的PowerShell,進入下載面畫後,你可以依需求切換PowerShell的語 系版本,也就是說,假設我不要使用繁體版本,我習慣看英文,那就可以選擇安裝英文版本的PowerShell,安裝之後,以後只要有關 PowerShell的任何訊息都會以英文來顯示。重點是,對應的作業系統版本要對,語系看你喜好。

另外只有一種情況下可以不安裝 PowerShell,只有單純安裝「SQL Server Express」這個版本時,可以不下載及安裝PowerShell,其他兩個2008 Express版本(with Tools及with Advanced Services),或單獨安裝SSMSE管理工具,都需要安裝以上三個套件。

SQL Server 2008 Express 安裝

  • SQL Server Express Service Pack 1:下載點
    Microsoft SQL Server 2008 Management Studio Express:下載點
  • SQL Server Express with Tools:下載點
  • SQL Server Express with Advanced Services:下載點
  • SQL Server Expres Service Pack 1:下載點
  • Microsoft SQL Server 2008 線上叢書 (2009 年 5 月):下載點
  • 範例和範例資料庫 (英文):下載點

2009年4月7日SQL Server Express推出Service Pack 1,所以你安裝with Tools及with Advanced Services版本,切記,安裝之後一定要快上Service Pack 1,依照基本預計值應就可以安裝成功。

SQL Server 2008 Express 的「執行個體」

「執行個體」,簡單說,你就把執行個體看成每一個「資料庫的名稱」,例如,我這次安裝的資料庫名稱叫「SQLEXPRESS」,然後,我在同一台電腦再安裝一次SQL Server 2008,然後我給他執行個體的名稱為「SQLBruce」。然後只需在使用時(SSMSE、網頁、應用程式都一樣)指定你所要「連接」的資料庫執行個體名稱,這些程式就知道要跟那一個資料庫來進行連接及處理的動作。

預設執行個體:此執行個體是藉由執行它的電腦網路名稱來識別。一部電腦中只能有一個是預設執行個體。它能讓較早SQL Server版本來使用SSMSE來連線到預設執行個體。

具名執行個體:此執行個體是以電腦的網路名稱加上執行個體名稱來識別,格式為{Computer Name}\{Instance Name},例如:

DS\SQLExpress
DS\SQLBruce
以上是標準使用{Computer Name}\{Instance Name}的格式。

192.168.1.10\SQLExpress
192.168.1.10\SQLBruce
你也可以使用IP來代替{Computer Name}部分。

DS.yourdomain.com\SQLExpress
DS.yourdomain.com\SQLBruce
你也可以使用Domain來代替{Computer Name}部分。IP與Domain在遠端連線時會使用到。

.\SQLExpress
.\SQLBruce

這個重要,這個「‧」(點)代表「本機」的意思。如果你是在本機作業,那就可以使用這個簡寫「‧」來代替{Computer Name},例如,你的資料庫與網站是在同一台伺服器,那麼網站內與資料庫連接相關程式碼,就可以使用這個「‧」來簡化程式碼

SQL Server 2008 Express 別名設定

若要以輸入192.168.1.10 來取代 192.168.1.10\SQLExpress 登入資料庫則需要作下列步驟

  • Protocals For SQLEXPRESS 的 TCP/IP 要Enable,與將 IPAll 的 TCP Port 設為1433

SQLServerConfigurationManager.png  

  •  啟用 Client Protocals 的TCP/IP ,讓外來的電腦可連入這台主機的 SQL Server 2008 Express

SQLServerClientProtocals.png  

  •  設定別名(Alias)192.168.1.10就可以登入為192.168.1.10\SQLEXPRESS

SQLServerClientAlias.png  

  • 啟動 SQL Server Browser 的 Services 

SQLServerServices.png  

  •  別忘了將防火牆對 SQL Server 2008 通訊的 1433 port 開啟

SQLServerFirewallPort.png  

  •  遠端電腦要連入時,就可以在伺服器用192.168.1.10 取代192.168.1.10\SQLEXPRESS 登入了

SQLServerLogin.png  

 

參考:http://blog.kkbruce.net/2009/08/microsoft-sql-server-2008-express.html#.T4vlPtmd0ug

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

個人專屬的網站,大部份都是在遠端的伺服器上,要如何上傳已經設計好的檔案,是重要的一環,說到上傳檔案到遠端伺服器,並且修改目錄的讀取權限,這個工具 Filezilla 就不可不知了。

   Filezilla 的軟體工具是完全免費的,它分有 Client 及 Server 兩種,但我們只要下載 Filezilla Client 端的軟體即可,除非你想要架設一個 FTP 伺服器,才需要 Filezilla Server。下載的網址如下:

Filezilla Client:http://filezilla-project.org/download.php?type=client
Filezilla Server:http://filezilla-project.org/download.php?type=server

  Filezilla Client 的安裝軟體分成全自動安裝 FileZilla_x.x.x_win32-setup.exe 及免安裝 FileZilla_x.x.x_win32.zip 兩種,若您不瞭解這兩種的差別,可以用全自動安裝的版本,但本人會建議使用免安裝的版本,因為它只要解開 ZIP 壓縮檔在任何一個目錄下,然後點選 filezilla.exe 就可以直接使用它了。

filezilla_folder.png  

  Filezilla 可以在站台管理員將 FTP 伺服器的網址資料記錄起來,這樣可以將您的 FTP 伺服器主機作分類管理。

Filezilla_siteManage.png  

  Filezilla 連到遠端伺服器除了在站台管理員管理外,也可以直接在 快速連線 列輸入 FTP 的網址。

Filezilla_Main.png  

   Filezilla 有另項功能,也是您一定要知道的:現在免費的網路空間,大部份都不提供 Telnet 或者 SSH  的功能讓您登入遠端伺服器,那我們怎麼管理網站伺服器內目錄的權限呢?Filezilla 可以使用 GUI 圖形介面來作管理,這就方便許多了。

filezilla_folder_permission.png  

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

利用 .htaccess 檔案來保護網頁目錄,只能適用於 Apache 伺服器,對於 ISS 並不適用,假如你無法修改 Apache 的設定檔,那 .htaccess 檔案會是一個很好的選擇。 .htaccess 能在你架設的網站目錄內對網站伺服器產生控制作用,目錄內一旦有這個檔案,該目錄及所有子目錄都會受到影響。

   .htaccess 是一個文字檔,你可以使用任何像是 NotePad 的文字編輯器直接撰寫,編輯這個檔案,然後再用 ftp 的方法上載到 Apache 的目錄內。如果使用 ftp 的軟體需選擇傳輸模式,要記得選擇 ASCII 模式。

   以下針對 .htaccess 檔案內容的參數作一些說明:

參數 說明
Options +Indexes 顯示目錄內的檔案清單
Options -Indexes 不顯示目錄內的檔案清單
IndexOptions +FancyIndexing 檔案清單呈現時,出現檔案類型的小圖示
IndexOptions -FancyIndexing 檔案清單呈現時,不要出現檔案類型的小圖示
IndexIgnore *.php *.html 隱藏指定的檔案,其餘的檔案則呈現出來。此範例為 隱藏所有 .php 及 .html 的檔案
文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

利用 Apache 架設網站伺服器服務 這一篇文章裡我們已經建立好 Apache 網站伺服器,它預設安裝在 C:\AppServ (以後稱此目錄為 「APACHE_ROOT」 ),預設網址的主目錄是 「APACHE_HOME\www」 ,這是在 Apache 伺服器的設定檔( 「APACHE_ROOT\Apache2.2\conf\httpd.conf」 )中定義的。

APACHE_ROOT\Apache2.2\conf\httpd.conf 」檔案的內容: 

Apache 伺服器的設定檔 httpd.conf

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/AppServ/www"

  預設一台主機只有一個獨立的網站,若您想要在同一台主機能夠有一個以上的獨立網站,可以利用 Apache 伺服器中的 Virtual Host 的設定,從下面的示意圖可以瞭解,這些不同的獨立網站都架設在同一個IP的主機上。

virtualHost.png  

要有這樣的效果,可以藉由下面的步驟來達成:

1. 申請個人網域後(mistech.localhost.com),在原有主機上(127.0.0.1)加設虛擬主機為個人網站(http://mistech.localhost.com/)。這裡的 http://mistech.localhost.com/ 是以本站為例,您應該改為您個人專屬的網域。

2. 在 DNS 伺服器的設定
 

dns                   IN   A      127.0.0.1  ;這個IP的名稱是dns,是本尊
www                 IN   CNAME    dns    ;這是第一個虛擬網站 mistech.localhost.com   --分身
forum                IN   CNAME    dns   ;這是第二個虛擬網站 forum.mistech.localhost.com --分身
phpMyAdmin     IN   CNAME    dns ;這是第三個虛擬網站 phpmyadmin.mistech.localhost.com --分身

若您沒有 DNS 伺服器,也可以直接修改 C:\Windows\System32\drivers\etc\host 檔案也可以,只是這樣的設定只限這台主機適用。

Windows XP/Vista/7 的 hots 檔案
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.

127.0.0.1  www.mistech.localhost.com forum.mistech.localhost.com mistech.localhost.com

 

 3. 在 APACHE_ROOT\Apache2.2\conf\httpd.conf 的內容

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf        ; 將前面的 # 刪除,並修改 APACHE_ROOT\Apache2.2\conf\extra/httpd-vhosts.conf 這個檔案

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

 4. 在 APACHE_ROOT\Apache2.2\conf\extra\httpd-vhosts.conf 的內容

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
# Use name-based virtual hosting.
#
NameVirtualHost 127.0.0.1:80

# 這是第一個虛擬網站 www.mistech.localhost.com   --分身
<VirtualHost *:80>
    ServerAdmin webamin@mistech.localhost.com
    DocumentRoot "C:/AppServ/www/mistech"
    ServerName www.mistech.localhost.com
</VirtualHost>

#這是第二個虛擬網站 forum.mistech.localhost.com --分身
<VirtualHost *:80>
    ServerAdmin webamin@mistech.localhost.com
    DocumentRoot "C:/AppServ/www/forum"
    ServerName forum.mistech.localhost.com
</VirtualHost>

#這是第三個虛擬網站 phpmyadmin.workplace.netau.net --分身
<VirtualHost *:80>
    ServerAdmin webamin@mistech.localhost.com
    DocumentRoot "C:/AppServ/www/phpMyAdmin"
    ServerName phpmyadmin.mistech.localhost.com
</VirtualHost>

 重新啟動 Apache 伺服器,就可以了,測試一下吧。

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()