Install Nginx PHP-FPM and Varnish on CentOS


First of all download and install the remi repo

rpm -Uvh epel-release-6-8.noarch.rpm remi-release-6.rpm

Now Installed the php with common used modules and php-fpm

yum --enablerepo=remi install php php-fpm php-common php-mysql php-pdo php-pecl-apc php-cli php-mcrypt php-xml php-gd php-mbstring

Now Install the nginx

yum install nginx

Now edit the php-fpm configuration file /etc/php-fpm.d/www.conf and change the user and group to nginx.

;listen =
listen = /var/run/php-fpm/php-fpm.sock
;user = apache
user = nginx
; RPM: Keep a group allowed to write in log dir.
;group = apache
group = nginx

Edit he nginx configuration file /etc/nginx/conf.d/default.conf and set the the port to 8080 and set correct path to php-fpm socket file

listen       8080; 
location ~ \.php$ {
      root   /usr/share/nginx/html;
      fastcgi_split_path_info  ^(.+\.php)(.*)$;
      fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_index  index.php;
      fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
      include fastcgi_params;

Install varnish

rpm -Uvh
yum install varnish

Edit varnish configuration file /etc/sysconfig/varnish and set the port to 80


Now you are ready to go, start the php-fpm, nginx and varnish

service php-fpm start
service nginx start
service varnish start