PHP和Apache的安裝

1.解壓 php-5.2.5-Win32.zip 文件到 D:\PHP。

2.複製 D:\PHP 目錄下的 php5ts.dll 文件到 C:\WINDOWS\system32 目錄中。

3.複製 D:\PHP 目錄下的 libmysql.dll 文件到 C:\WINDOWS\system32 目錄中。

4.複製 D:\PHP\ext 目錄下的 php_gd2.dll、php_mbstring.dll、php_mysql.dll 文件到 C:\WINDOWS\system32 目錄中。

5.複製 D:\PHP 目錄下的 php.ini-dist 文件到 C:\WINDOWS 目錄中,改名爲 php.ini。

注意:如果使用了NTFS文件系統,確保運行 webserver 的用戶對 php.ini 有讀取的權限(例如使其對 Everyone 可讀)。

6.用記事本打開編輯php.ini文件,找到並修改下面兩行:

 

; Directory in which the loadable extensions (modules) reside.

extension_dir = "./"

改成:

; Directory in which the loadable extensions (modules) reside.

extension_dir = "D:\PHP\ext"

 

 

再找到下面幾行:

 

; Windows Extensions

; Note that ODBC support is built in, so no dll is needed for it.

; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)

; extension folders as well as the separate PECL DLL download (PHP 5).

; Be sure to appropriately set the extension_dir directive.

加上:

extension=php_gd2.dll

extension=php_mbstring.dll

extension=php_mysql.dll

 

 

找到:

;date.timezone =

改成:

date.timezone = PRC

 

 

7.點擊apache_2.2.8-win32-x86-no_ssl.msi安裝Apache到D:\Apache。

8.編輯conf/httpd.conf文件:

 

[加載PHP5模塊]

找到LoadModule段,在下面添加:

LoadModule php5_module "D:/PHP/php5apache2_2.dll"

 

[設置的默認文檔]

找到:

<IfModule dir_module>

    DirectoryIndex index.html

</IfModule>

改成:

<IfModule dir_module>

    DirectoryIndex index.html index.htm index.php

</IfModule>

 

[設置MIME映射]

找到:

    # If the AddEncoding directives above are commented-out, then you

    # probably should define those extensions to indicate media types:

    #

    AddType application/x-compress .Z

    AddType application/x-gzip .gz .tgz

加上:

    AddType application/x-httpd-php .php

    AddType application/x-httpd-php .html

 

[開啓SSI支持]

找到:

    #AddType text/html .shtml

    #AddOutputFilter INCLUDES .shtml

改成:

    AddType text/html .shtml

    AddOutputFilter INCLUDES .shtml

找到:

    Options Indexes FollowSymLinks

改成:

    Options Indexes FollowSymLinks Includes

 

[設置主目錄]

找到:

DocumentRoot "D:/Apache/htdocs"

改成:

DocumentRoot "D:/wwwroot"

找到:

<Directory "D:/Apache/htdocs">

改成:

<Directory "D:/wwwroot">

 

 

9.編輯conf/httpd.conf文件創建虛擬目錄:

找到:

    # Alias /webpath /full/filesystem/path

    #

    # If you include a trailing / on /webpath then the server will

    # require it to be present in the URL.  You will also likely

    # need to provide a <Directory> section to allow access to

    # the filesystem path.

在下面添加:

    Alias /phpmyadmin "D:/phpmyadmin"

    <Directory "D:/phpmyadmin">

    AllowOverride None

    Options None

    Order allow,deny

    Allow from all

    </Directory>

 

 

<Directory "E:/wwwroot">

    Order allow,deny

    Allow from all

</Directory>

 

10.新建測試文件輸入“<?echo phpinfo();?>”。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章