Install Nginx with PHP-FPM on CentOS 6

What is Nginx?

Nginx (pronounced “engine x”) is a free, open-source, high-performance HTTP server. Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption.

What is PHP-FPM?

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.

Install the EPEL x86_64 YUM Repository

# rpm -Uvh

Install Nginx

Install PHP and PHP-FPM

Configure Nginx and PHP-FPM

Edit the www.conf pool and comment out the listen on TCP socket and add a unix socket listen = /var/run/php5-fpm.sock

Create a Nginx config file based on your individual site. Below is a config file specific to WordPress running the W3 Total Cache plugin. Note the fastcgi_pass is the same as the unix socket specified in the php-fpm www.conf pool.

Don’t forget to create your log directory if you’re not using the defualt.

Check your configuration for any errors.

Enable php-fpm and Nginx at startup.

Start php-fpm and Nginx.