php怎么环境搭建,php环境搭建(如何搭建php运行环境)

1、PHP环境建立的条件是ApacheHTTPServer(Apache服务器)现已装置布置成功,并能够正常访问到服务器的主页面。ApacheHTTPServer的装置布置现已在上一篇解说的很详细了,不清楚的能够点击“ApacheHTTPServcer-Apache服务器下载与Windows系统下装置”查看具体操作。

2、PHP下载:

2.1、下载地址:http://php.net/downloads.php

2.1、版别挑选:如果是与Apache调配,建议挑选ThreadSafe版别;如果是与CGI或许FAST-CGI调配,建议挑选NonThreadSafe版别。

3、PHP环境建立:

3.1、将下载的.zip压缩包解压到指定的装置目录,此处装置途径为:D:\solt\php_5.6.33。

3.2、将PHP的根目录下的php.ini-development或许php.ini-production仿制一份并改名为php.ini,作为PHP的装备文件;

3.3、翻开php.ini,修正装备信息:

说明:a、ini文件的注释是分号(英文分号),所以撤销注释就删去分号;

b、${phphome}是PHP的根目录,即:D:\solt\php_5.6.33,装备文件中写成绝对途径。

3.3.1、修正扩展文件的途径:

;extension_dir=”ext”

撤销注释,或许改为:

extension_dir=”${phphome}\ext”;

注意:如果是与Apache调配,建议将扩展文件途径改为绝对途径,因为有或许加载不了。f6bbd142683b3248a4b7dbf2c385ae57.png

3.3.2、修正需求加载的扩展文件,下面代码是撤销部分扩展程序的注释之后的代码:

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;Mustbeaftermbstringasitdependsonit

extension=php_mysql.dll

extension=php_mysqli.dll

;extension=php_oci8_12c.dll;UsewithOracleDatabase12cInstantClient

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

;TheMIBSdataavailableinthePHPdistributionmustbeinstalled.

;Seehttp://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、设置默认的时区:

[Date]

;Definesthedefaulttimezoneusedbythedatefunctions

;http://php.net/date.timezone挑选时区列表网址date.timezone=Asia/Shanghai

3.3.4、设置ssl:

[openssl]

;ThelocationofaCertificateAuthority(CA)fileonthelocalfilesystem

;tousewhenverifyingtheidentityofSSL/TLSpeers.Mostusersshould

;notspecifyavalueforthisdirectiveasPHPwillattempttousethe

;OS-managedcertstoresinitsabsence.Ifspecified,thisvaluemaystill

;beoverriddenonaper-streambasisviathe"cafile"SSLstreamcontext

;option.

openssl.cafile=cacert.pem

依据需求能够自己增加扩展。

3.4、修正Apache24\conf\目录下的httpd.conf装备Apache,让Apache和PHP协同作业;

3.4.1、DocumentRoot设置:

修正前:默认的是Apache24下的htdocs目录:

修正后:指定到自定义的途径,但是要记住这个途径。

3.4.2、修正默认的索引,以支撑PHP:

修正前:

#DirectoryIndex:setsthefilethatApachewillserveifadirectory

#isrequested.

#DirectoryIndexindex.html

修正后:

#DirectoryIndex:setsthefilethatApachewillserveifadirectory

#isrequested.

#DirectoryIndexindex.htmlindex.phpindex.htm

3.4.3、开启rewrite功能:将下面这行代码前面的#去掉:

LoadModulerewrite_modulemodules/mod_rewrite.so

3.4.4、加载PHP模块,注意绝对途径:

如果是PHP5,在httpd.conf文件最终增加如下代码:

#php5.6LoadModulephp5_moduleD:/soft/php-5.6.33/php5apache2_4.dllPHPIniDir”D:/soft/php-5.6.33/”AddTypeapplication/x-httpd-php.php

AddTypeapplication/x-httpd-php-source.phps

如果是PHP7,则相应的更改,示例如下:

#php7

LoadModulephp7_moduleD:/soft/php-7.x.x/php7apache2_4.dllPHPIniDir”D:/soft/php-7.x.x/”AddTypeapplication/x-httpd-php.php

AddTypeapplication/x-httpd-php-source.phps

3.5、如果装置的PHPx64位版别,Apache也需求是x64位版别的。然后还要将php目录下的libssh2.dll以及ext目录下的php_curl.dll文件都仿制放到System32目录下(原文说还要仿制Apache目录下的libeay32.dll、ssleay32.dll文件,我没仿制,但是依然可用)。否则curl扩展无法使用。参考链接:http://my.oschina.net/lsfop/blog/496181。未做验证,仅仅照做,正常显示。

4、Apache+PHP启动运行测试:

4.1、在D:\soft\php_5.6.33\www目录下,创立index.php文件,文本内容如下:

php

echophpinfo();?>

4.2、重启Apache服务,翻开阅读地址栏输入:localhost:8081/index.php或许127.0.0.1:8081/index.php,就能够翻开PHP页面。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值