php windows环境安装的方法详解

发布时间:2024-08-15 点击:94
php windows环境安装的方法:首先下载好php,并将下载的php压缩包解压到指定的安装目录;然后打开“php.ini”,并修改配置信息;接着修改apache配置文件;最后加载php模块并重启apache服务即可。
windows系统下php环境搭建
1、php环境搭建的前提是 apache http server (apache 服务器)已经安装部署成功,并可以正常访问到服务器的主页面。apache http server 的安装部署已经在上一篇讲解的很详细了,不清楚的可以点击“ apache http servcer-apache服务器下载与windows系统下安装”查看具体操作。
2、php下载:
2.1、下载地址:http://php.net/downloads.php
2.1、版本选择:如果是与 apache 搭配,建议选择 thread safe 版本;如果是与 cgi 或者 fast-cgi 搭配,建议选择 non thread safe 版本。
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 搭配,建议将扩展文件路径改为绝对路径,因为有可能加载不了。
3.3.2、修改需要加载的扩展文件,下面代码是取消部分扩展程序的注释之后的代码:
extension=php_bz2.dllextension=php_curl.dllextension=php_fileinfo.dllextension=php_gd2.dllextension=php_gettext.dll;extension=php_gmp.dll;extension=php_intl.dll;extension=php_imap.dll;extension=php_interbase.dll;extension=php_ldap.dllextension=php_mbstring.dllextension=php_exif.dll ; must be after mbstring as it depends on itextension=php_mysql.dllextension=php_mysqli.dll;extension=php_oci8_12c.dll ; use with oracle database 12c instant clientextension=php_openssl.dll;extension=php_pdo_firebird.dllextension=php_pdo_mysql.dll;extension=php_pdo_oci.dllextension=php_pdo_odbc.dllextension=php_pdo_pgsql.dllextension=php_pdo_sqlite.dllextension=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.dllextension=php_soap.dllextension=php_sockets.dllextension=php_sqlite3.dll;extension=php_sybase_ct.dllextension=php_tidy.dllextension=php_xmlrpc.dllextension=php_xsl.dll 3.3.3、设置默认的时区:
[date]; defines the default timezone used by the date functions; http://php.net/date.timezone 选择时区列表网址date.timezone = asia/shanghai 3.3.4、设置 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 根据需求可以自己添加扩展。
3.4、修改 apache24\\\\conf\\\\ 目录下的 httpd.conf 配置 apache ,让 apache 和 php 协同工作;
3.4.1、documentroot 设置:
修改前:默认的是 apache24 下的 htdocs 目录:
修改后:指定到自定义的路径,但是要记住这个路径。
3.4.2、修改默认的索引,以支持 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、开启 rewrite 功能:将下面这行代码前面的 # 去掉:
loadmodule rewrite_module modules/mod_rewrite.so 3.4.4、加载 php 模块,注意绝对路径:
如果是 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 .phpaddtype application/x-httpd-php-source .phps</ifmodule> 如果是 php 7,则相应的更改,示例如下:
#php7loadmodule 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 .phpaddtype application/x-httpd-php-source .phps</ifmodule> 3.5、如果安装的php x64位版本,apache也需要是x64位版本的。然后还要将php目录下的libssh2.dll以及ext目录下的php_curl.dll文件

腾讯企业邮箱的Foxmail for windows 在客户端的设置
虚拟主机好还是云主机好
这个网站用的是云服务器-其他问题
我们公司备案营业执照上传照出来效果不清晰
阿里云服务器怎么多开网站
阿里云高防服务器掉包
千万别伪造域名认证信息 伪造域名实名认证后果严重
显示备案已经通过为啥还绑定不上首页