我已经在CentOS 7.x环境下使用本教程编译了支持FPM的PHP 7。
我能够通过运行CLI来testingphp。
cd /opt/php7/bin ./php --version
哪个输出
PHP 7.0.6 (cli) (built: May 22 2016 07:20:48) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
我也安装了Apache,它运行成功。
现在我已经创build了虚拟主机,并将域引导到一个目录。 我已经用函数phpinfo()粘贴了一个php文件info.php ,但是服务器输出PHP函数而不执行它。
我觉得我现在真的很接近,只需要configurationapache运行php-fpm,所以我把这个configuration放在httpd.conf文件中,但是没有帮助。
<IfModule mod_fastcgi.c> DirectoryIndex index.html index.shtml index.cgi index.php AddType application/x-httpd-fastphp7 .php Action application/x-httpd-fastphp7 /php7-fcgi Alias /php7-fcgi /opt/php7/bin/php-cgi FastCgiExternalServer /var/www/html/ -socket /opt/php7/var/run/php-fpm.pid -pass-header Authorization <Directory /var/www/html/> Require all granted </Directory> </IfModule>
fcgi模块安装时,我运行apachectl -t -D DUMP_MODULES我得到fcgid_module (shared)
解决了这个问题。 我已经按照下面的步骤。
首先,如果你没有为php-fpmselect任何其他端口,那么它将被设置为在端口9000上运行。
/etc/init.d/php-fpm start
如果失败说明端口已经被占用,那么你将需要找出端口正在运行的进程号码并杀死它。
netstat -tulpn | grep :8999
这应该给你当前正在运行的进程ID。 例如,如果进程ID是21190那么你运行
kill 21190
现在,端口被清除了,现在可以尝试再次启动php-fpm
/etc/init.d/php-fpm start
例如,您正在托pipeexample.com 。 现在打开域的虚拟主机configuration。 这是一个最简单的例子。
<VirtualHost *:80> DocumentRoot "/var/www/html/example.com/" ServerName example.com </VirtualHost>
现在添加更新如下:
<VirtualHost *:80> DocumentRoot "/var/www/html/example.com/" ServerName example.com # Setup php-fpm to process php files ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/example.com/$1 DirectoryIndex /index.php index.php </VirtualHost>
现在所有你的PHP文件的example.com应该执行。
参考: https : //wiki.apache.org/httpd/PHP-FPM