- Install Nginx
]# yum install nginx
- Install php-fpm
]# yum install php54-fpm
- Create a *.conf file for php-fpm
]# cd /etc/php-fpm.d/
]# cp www.conf your-domain.conf
- Setup the your-domain.conf file
]# vim your-domain.conf
- Type
i
to enter Edit mode. - Change the second line
[www]
to[your-domain]
- Change line 12 to:
listen = /var/run/php-fpm/your-domain.sock
- Change line 31 to:
listen.owner = nginx
- Change line 32 to:
listen.group = nginx
- Change line 39 to:
user = nginx
(do this if you’re running nginx as a proxy to Apache) - Change line 41 to:
group = nginx
(do this if you’re running nginx as a proxy to Apache) - Type
Esc : wq [enter]
- Modify the default Nginx Config file
]# vim /etc/nginx/nginx.conf
- Change
index index.html index.htm;
toindex index.html index.htm index.php;
- Type
Esc: wq [enter]
- Setup your virtual host file for nginx
]# cd /etc/nginx/conf.d/
]# vim virtual.conf
(This is a new file that will be created)- Enter all your
server {}
info for the domain you’re adding.- To use unix sockets (recommended) type this into a location block
-
location ~[^/]\.php$ { fastcgi_pass unix:/var/run/php5-fpm/your-domain.sock; include fastcgi_params; }
- Type
Esc: wq [enter]
- Enter all your
- Modify the fastcgi_params file
]# vim /etc/nginx/fastcgi_params
- Add
pastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
to the list of parameters - Type
Esc: wq [enter]
- Start the servers
]# /etc/init.d/php-fpm restart
]# /etc/init.d/nginx restart
- Notice any errors, and make the appropriate adjustments.