最近配置 Apache 2.4 支持PHP7,能够正常运行,扩展PHP7的extensions的时候,出现缺少:
----libssh2.dll,libcrypto-1_1-x64.dll,LIBPQ.dll,icuuc60.dll 的报错,尝试过各种解决方案,都不行,后来直接把PHP安装路径添加到path环境变量中就解决了。
下面记录一下:
服务器:Windows Server 2012 R2 Standard
Apache: httpd-2.4.29-o102n-x64-vc14-r2
PHP:php-7.2.3-Win32-VC15-x64
提前安装VC15
1.打开conf文件夹下面的httpd.conf文件
2.分别查找以下关键字,并修改,如下
Define SRVROOT "E:\mysever\Apache24"
ServerRoot "${SRVROOT}"
Listen 80
ServerName localhost:80
DocumentRoot "E:/mysever/Apache24/htdocs"
1.打开PHP7的安装文件目录,找到php.ini-production,复制一份,文件名修改为:php.ini,放回原目录。
2.php.ini,查找以下关键字,并修改内容(把前面的“;”号去掉,代表启用这行代码),如下:
; extension_dir = "./"
; On windows:
extension_dir = "E:\mysever\php7\ext"
extension=bz2
extension=curl
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
;extension=interbase
;extension=ldap
extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
;extension=pdo_sqlite
extension=pgsql
extension=shmop
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=snmp
extension=soap
extension=sockets
extension=sqlite3
extension=tidy
extension=xmlrpc
extension=xsl
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone ="PRC"
1.再次打开conf文件夹下面的httpd.conf文件
2.查找以下关键字,并修改:
DirectoryIndex index.html index.php
3.在httpd.conf文件最后添加以下内容:
#php7 support
LoadModule php7_module "E:/mysever/php7/php7apache2_4.dll"
PHPIniDir "E:/mysever/php7/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
出现缺少libssh2.dll,libcrypto-1_1-x64.dll,LIBPQ.dll,icuuc60.dll的报错,在Apache 服务目录下编写index.php
添加以下内容:
echo phpinfo();
?>
浏览器访问这个文件,正常运行。
解决以上报错方案:
把PHP7的安装目录:E:\mysever\php7和E:\mysever\php7\ext,添加到环境变量PATH中,重启Apache,不再出现缺少libssh2.dll,libcrypto-1_1-x64.dll,LIBPQ.dll,icuuc60.dll的报错