The following guide describes how to configire Nginx and PHP-FPM to use Sockets on Centos 6. This guide assumes you have already installed a LEMP stack as shown in Install LEMP on Centos
Step 1 – Configure PHP-FPM
Edit the PHP-FPM configuration file and set the required values
vi /etc/php-fpm.d/www.conf
listen = /var/run/php-main.socket
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
Alternatively the following sed commands will set the variables for you
sed -i s'/listen = 127.0.0.1:9000/listen = \/var\/run\/php-main.socket/' /etc/php-fpm.d/www.conf
sed -i s'/;listen.owner = nobody/listen.owner = nginx/' /etc/php-fpm.d/www.conf
sed -i s'/;listen.group = nobody/listen.group = nginx/' /etc/php-fpm.d/www.conf
sed -i s'/;listen.mode = 0660/listen.mode = 0660/' /etc/php-fpm.d/www.conf
Step 2 – Configure Nginx config
Edit the PHP-FPM configuration file and set the required values
vi /etc/nginx/conf.d/default.conf
fastcgi_pass unix:/var/run/php-main.socket;
Alternatively the following sed commands will set the variables for you
sed -i s'/fastcgi_pass 127.0.0.1:9000;/fastcgi_pass unix:\/var\/run\/php-main.socket;/' /etc/nginx/conf.d/default.conf
Step 3 – Restart the Services
All that’s left is to restart the services and test.
service php-fpm restart
service nginx restart
Source URL: https://www.servermule.com.au/help/linux/configure-nginx-php-fpm-socket-centos/
0 comments:
Post a Comment