3.3.2、修改需要加載的擴(kuò)展文件,下面代碼是取消部分?jǐn)U展程序的注釋之后的代碼:
extension=php_bz2.dll extension=php_curl.dll extension=php_fileinfo.dll extension=php_gd2.dll extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll extension=php_exif.dll ; Must be after mbstring as it depends on it extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client extension=php_openssl.dll ;extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll extension=php_pdo_odbc.dll extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll extension=php_pgsql.dll ;extension=php_shmop.dll ; The MIBS data available in the PHP distribution must be installed. ; See http://www.php.net/manual/en/snmp.installation.php ;extension=php_snmp.dll extension=php_soap.dll extension=php_sockets.dll extension=php_sqlite3.dll ;extension=php_sybase_ct.dll extension=php_tidy.dll extension=php_xmlrpc.dll extension=php_xsl.dll
3.3.3、設(shè)置默認(rèn)的時(shí)區(qū):
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone 選擇時(shí)區(qū)列表網(wǎng)址date.timezone = Asia/Shanghai
3.3.4、設(shè)置 ssl :
[openssl] ; The location of a Certificate Authority (CA) file on the local filesystem ; to use when verifying the identity of SSL/TLS peers. Most users should ; not specify a value for this directive as PHP will attempt to use the ; OS-managed cert stores in its absence. If specified, this value may still ; be overridden on a per-stream basis via the "cafile" SSL stream context ; option. openssl.cafile= cacert.pem
根據(jù)需求可以自己添加擴(kuò)展。
3.4、修改 Apache24\\\\conf\\\\ 目錄下的 httpd.conf 配置 Apache ,讓 Apache 和 PHP 協(xié)同工作;
3.4.1、DocumentRoot 設(shè)置:
修改前:默認(rèn)的是 Apache24 下的 htdocs 目錄:
修改后:指定到自定義的路徑,但是要記住這個(gè)路徑。
3.4.2、修改默認(rèn)的索引,以支持 PHP :
修改前:
# DirectoryIndex: sets the file that Apache will serve if a directory # is requested. #<IfModule dir_module>DirectoryIndex index.html</IfModule>
修改后:
# DirectoryIndex: sets the file that Apache will serve if a directory # is requested. #<IfModule dir_module>DirectoryIndex index.html index.php index.htm</IfModule>
3.4.3、開(kāi)啟 rewrite 功能:將下面這行代碼前面的 # 去掉:
LoadModule rewrite_module modules/mod_rewrite.so
3.4.4、加載 PHP 模塊,注意絕對(duì)路徑:
如果是 PHP 5,在 httpd.conf 文件最后添加如下代碼:
#php5.6LoadModule php5_module D:/soft/php-5.6.33/php5apache2_4.dll <IfModule php5_module> PHPIniDir "D:/soft/php-5.6.33/" AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps</IfModule>
如果是 PHP 7,則相應(yīng)的更改,示例如下:
#php7 LoadModule php7_module D:/soft/php-7.x.x/php7apache2_4.dll<IfModule php7_module> PHPIniDir "D:/soft/php-7.x.x/" AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps</IfModule>
3.5、如果安裝的PHP x64位版本,Apache也需要是x64位版本的。然后還要將php目錄下的libssh2.dll以及ext目錄下的php_curl.dll文件都復(fù)制放到System32目錄下(原文說(shuō)還要復(fù)制Apache目錄下的libeay32.dll、ssleay32.dll文件,我沒(méi)復(fù)制,但是依然可用)。否則curl擴(kuò)展無(wú)法使用。參考鏈接:http://my.oschina.net/lsfop/blog/496181 。未做驗(yàn)證,只是照做,正常顯示。
4、Apache PHP 啟動(dòng)運(yùn)行測(cè)試:
4.1、在 D:\\\\soft\\\\php_5.6.33\\\\www 目錄下,創(chuàng)建 index.php 文件,文本內(nèi)容如下:
<?php echo phpinfo();?>
4.2、重啟 Apache 服務(wù),打開(kāi)瀏覽地址欄輸入: localhost:8081/index.php 或者 127.0.0.1:8081/index.php ,就可以打開(kāi) PHP 頁(yè)面。
最后說(shuō)明一點(diǎn)兒,PHP 環(huán)境搭建可以借助于 PHP 開(kāi)發(fā)環(huán)境搭建工具,下載地址:http://www.php.cn/xiazai/gongju或者h(yuǎn)ttp://www.wampserver.com/,在此處就不介紹工具安裝方法了。
更多相關(guān)知識(shí),請(qǐng)?jiān)L問(wèn)PHP中文網(wǎng)!
更多關(guān)于云服務(wù)器,域名注冊(cè),虛擬主機(jī)的問(wèn)題,請(qǐng)?jiān)L問(wèn)西部數(shù)碼官網(wǎng):m.ps-sw.cn