I have compiled PHP 7 with FPM support using this tutorial on CentOS 7.x environment.
I was able to test the php through CLI by running.
cd /opt/php7/bin
./php --version
Which outputs
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
I have also installed apache and it is running successfully.
Now I have created vhosts and guided domain to a directory. I have pasted a php file info.php
with the function phpinfo()
but server outputs the PHP function without executing it.
I feel I am really close now and just need to configure apache to run with php-fpm so I put this config on httpd.conf
file but it doesn't help.
<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 module is installed beacuse when I run apachectl -t -D DUMP_MODULES
I get fcgid_module (shared)
Best Answer
Solved the problem. I have followed the steps below.
Make Sure PHP-FPM is running
First of all if you haven't choose any alternative port for php-fpm then it will be set to run at port 9000.
or
If it fails saying that the port is already occupied then you will need to find out the process number that is running by the port and kill it.
This should give you the process id that is currently running. For example if the process id is
21190
then you runNow that the port is cleared you can now try to start the
php-fpm
againUpdate vHost config file
For example you are hosting
example.com
. Now open up the vhost config for the domain. Here is a simplest example.Now add update it with following:
And now all your php file for the example.com should execute.
Reference: https://wiki.apache.org/httpd/PHP-FPM