All HowTo's Linux Redhat, Fedora and CentOS Linux Web Servers

Minimal Nginx and PHP-FPM on CentOS

This article explains how to install a minimal Nginx server with php-fpm on a CentOS server.

Install the packages:

yum install nginx php-fpm php

And here is the sample virtual-host config “/etc/nginx/conf.d/agix.com.au.conf”:

server {
        listen 80;
        server_name agix.com.au *.agix.com.au;

        access_log   /var/log/nginx/agix.com.au.access.log;
        error_log    /var/log/nginx/agix.com.au.error.log;

        root /var/www/agix.com.au;
        index index.php;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ .php$ {
                #try_files $uri =404;
                include fastcgi_params;
                include fastcgi.conf;
                fastcgi_index  index.php;
                fastcgi_pass   127.0.0.1:9000;
        }
}

Ensure this line exists in the “/etc/php-fpm.d/www.conf” file. It replaces existing “listen” lines:

listen = 127.0.0.1:9000

And restart Nginx and PHP.

service nginx restart
service php-fpm restart