标签:Centos php7.2 fast-cgi+php7
1. 编译安装apache 2.4参考Centos 6.9 apahce 2.4.29编译安装
#curl -O http://cn2.php.net/distributions/php-7.2.3.tar.bz2
有个别包需要EPEL源,可提前配置好Aliyun的Yum源
#yum install bzip2-devel libxml2-devel libmcrypt-devel
注意:php-7.0以上版本使用--enable-mysqlnd --withmysqli=mysqlnd ,原--with-mysql不再支持
编译参数
#cd php-7.2.3
./configure --prefix=/usr/local/php-7.2.3 --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfo
编译与安装
# make -j 8
出现Build complete. 那么,恭喜编译成功
# make install
创建一个软链接,方便管理版本
#ln -s php-7.2.3/ php
注意,这些文件是在源码目录里
# cp php.ini-production /etc/php.ini
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# chmod +x /etc/rc.d/init.d/php-fpm
# vim /etc/rc.d/init.d/php-fpm
prefix=/usr/local/php > 把这行修改为指定的编译路径
# sed -ri.bak s#php-7.2.3#php#g /usr/local/php/etc/php-fpm.conf.default
# mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# mv /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# chkconfig --add php-fpm
# chkconfig php-fpm
# vim /etc/httpd2.4/httpd.conf
确保以下2条取消注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
# 如果使用的是虚拟主机形式,把下面4行添加到主机标签中
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/www/virtualhost/$1
其中/app/www/virtualhost指的是站点文件目录
例子:
<VirtualHost *:80>
DocumentRoot "/app/www/virtualhost"
ServerName www.hunk.tech
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/www/virtualhost/$1
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<Directory "/app/www/virtualhost">
AllowOverride None
Options None
Require all granted
</Directory>
</VirtualHost>
#ss -nlt
fcgi正在监听端口
State Recv-Q Send-Q Local Address:Port
LISTEN 0 128 127.0.0.1:9000
编辑一个php的测试文件
#vim /app/www/virtualhost/index.php
<?php
phpinfo();
?>
Centos 6.9 编译安装 apache 2.4+php7.2.3 + Fast-cgi
标签:Centos php7.2 fast-cgi+php7
原文地址:http://blog.51cto.com/191226139/2082678