Yesterday we discussed about how we can install and integrate Nginx on Webmin server.
Today we are going to discuss how we integrate php-fpm in to this.
PHP-FPM (FastCGI Process Manager) is an another type of php handler which is commonly can be seen if the web server is Nginx. Some of them preferred the same to improve their website performance.
Install php-fpm is pretty straight forward. Use yum.
yum install php-fpm
Now Configure NGINX to use TCP connections instead of Unix sockets.
- Log in to the webmin panel using https:IPADDRESS:10000 and go to
- Webmin > Server > Ngnix Webserver > Module Config
- ChangeConnect Nginx to PHP processes with from Socket files to TCP connections
By default at the time of website creation through virtualmin it execute PHP as php-cgi. We need to change to php-fpm. For the same we need to Disable the PHP-CGI call when creating and/or running a site:
- Open file named /usr/libexec/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl and commend line
# Launch it, and save the PID &start_php_fcgi_server_command($d, $cmd, $envs_to_set, $log, $pidfile);
- Change the user as nginx in the file /etc/php-fpm.d/www.conf. Because in my case the nginx is running as user nginx.
- Don’t try to start the php-fpm service as this is recommended by the virtualmin website itself.
- Now create a website through virtualmin and after that start the php-fpm service using below command
service php-fpm start
- Test it out if the php-fpm enabled or not using phpinfo page.
- So basically what I understood is everytime we create a new website on virtualmin we need to stop the php-fpm service and start again after creating the virtualmin. This is the limitation at this moment.
Now lets try PHP-FPM from an Unix Socket instead of a TCP connection. In order to do the same change the configurations we made earlier.
- Go to Webmin > Server > Ngnix Webserver > Module Config
- ChangeConnect Nginx to PHP processes with from TCP connections to Socket files
- Add a folder for sockets using below command.
mkdir -p /var/run/php-fpm/
- Open /etc/php-fpm.d/www.conf and change
listen = 127.0.0.1:9000 to listen = /var/run/php-fpm/DOMAINNAME.socket
- Now go to Webmin > Server > Ngnix Webserver > Edit Configuration Files and change
fastcgi_pass localhost:9000; to fastcgi_pass unix:/var/run/php-fpm/DOMAINNAME.socket;
That’s all, Now we completed the setup of Nginx, php-fpm and Webmin integration.