First of all: I'm not an expert in configuring things. This is very new for me, so, my apologies in advance.
At work we have a Centos server. The guy who worked here before installed nginx. We need to made a php site, so, obviously, I need to set up php and make it work with nginx.
Making short a very long tale, I had to replace the nginx binary with a new one (because the older was compile without fast-cgi), and I had to recompile and install php (because the new version has fpm). Then I struggle with the config files, making this nginx.conf (not all the file)
user php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
and uncomment some parameters in php-fpm (to much to detail here, but the important is that group and user are "php")
I never could start the php-fpm with the instructions of the book
sudo /usr/sbin/php-fpm start
But after look at the net, I found this
sudo /usr/local/sbin/php-fpm --fpm-config=/usr/local/etc/php-fpm.conf
This worked (I think)
I restarted nginx. But… nothings happens with php… My calls to php files (via firefox)
doesn't even appear in the log (/opt/nginx/logs/error.log)
I'm really, really exhausted and lost… Could anyone help me, pleaaase…. 🙁
Thanks in advance
Best Answer
first of all check that php-fpm is listening on 9000 port: netstat -an | grep LISTEN | grep 9000 if it return something like: tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN then php-fpm works and you should check your nginx configuration. i.e. check if you defined right server_name. it should be the same as you enter it in your browser. if you use some other urls than localhost make sure you have right DNS record for this urls. mine config for php-fpm is:
this config works at many of my sites.