CentOS 7 Apache use PHP-FPM
Install PHP-FPM with command
1 |
yum install php-fpm |
Edit www.conf
1 |
vi /etc/php-fpm.d/www.conf |
Find
1 |
listen = 127.0.0.1:9000 |
Replace with
1 |
listen = /var/run/php-fpm/default.sock |
Find
1 2 |
;listen.owner = nobody ;listen.group = nobody |
Replace with
1 2 |
listen.owner = apache listen.group = apache |
Edit php.conf
1 2 |
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.old vi /etc/httpd/conf.d/php.conf |
Add
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<Proxy "unix:/var/run/php-fpm/default.sock|fcgi://php-fpm"> ProxySet disablereuse=off </Proxy> <FilesMatch \.php$> SetHandler proxy:fcgi://php-fpm </FilesMatch> AddType text/html .php DirectoryIndex index.php <FilesMatch \.phps$> SetHandler application/x-httpd-php-source </FilesMatch> |
Restart Apache/php-fpm
1 2 |
systemctl restart httpd systemctl restart php-fpm |
Method 2
Here is php-fpm config using proxy_fcgi
https://gist.github.com/serverok/3d2e43bb951ded9a42ce8bc0c2c3b627