php-fpm for nginx

php-fpm – PHP FastCGI Process Manager ’PHP-FPM’. By default, php-fpm will respond to CGI requests listening on localhost http port 9000. Therefore php-fpm expects your webserver to forward all requests for ’.php’ files to port 9000 and you should edit your webserver configuration file appropriately.

In /etc/nginx/conf.d/default.conf, uncomment these following code.

[root@banjarnahor ~]# vim /etc/nginx/conf.d/default.conf
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

subsequently, in /etc/php-fpm.d/www.conf change the listen port from listen = into listen = /var/run/php5-fpm.sock. Becausse in /etc/nginx/conf.d/default.conf we use fastcgi_pass unix:/var/run/php5-fpm.sock;

[root@banjarnahor ~]# vim /etc/php-fpm.d/www.conf
listen = /var/run/php5-fpm.sock.
vim /etc/php-fpm.d/www.conf

start the service php-fpm and also verify the service is set to start when the system boots.

[root@banjarnahor ~]# service php-fpm status
php-fpm (pid 2656) is running...
[root@banjarnahor ~]# chkconfig --list | grep php
php-fpm 0:off 1:off 2:on 3:on 4:off 5:on 6:off

to check it. create file info.php in /usr/share/nginx/html/

[root@banjarnahor ~]# vim /usr/share/nginx/html/info.php 

open localhost/info.php

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>