After failing to get FastCGI to work with PHP I have installed the PHP-FPM service which is reported to work out of the box, however PHP files are downloading instead of executing.
This is what I have in the nginx.conf file:
server {
listen 80;
server_name pubserver;
root /usr/share/nginx/html;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
The command netstat -tulpn | grep :9000
displays this which suggests PHP-FPM is running:
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1058/php-fpm.conf)
Best Answer
Finally managed to get it working. After checking the logs I noticed there were errors like this which indicated redirect cycles:
So I thoroughly checked the nginx.conf file and found that this line:
was loading 3 other files, namely:
After opening default.conf I noticed the following rules were already there:
Probably because I installed nginx and PHP-FPM from the CentOS repository it came already configured. Apparently I rushed to configure the PHP service before testing if it was working.