location ~ \.php$ {
fastcgi_pass 0.0.0.0:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include fastcgi_params;
break;
}
location/{
rewrite ^/ /index.php break;
}
With this setting, accessing the php page will directly download the php file.
But don't redirect
location/{
index index.php
}
I can execute the php file normally, but my head is spinning and I don’t know why.
You should just change break to last
What you mean is to rewrite all uri forwarding requests to index.php and then break. The new rewritten uri (rewritten to index.php in this example) will no longer match the following location. , so your php file is not passed to php-fpm for parsing. But after changing to last, the new uri will re-match the location that meets the conditions, so index.php is passed to php-fpm for parsing and execution.
If you don’t understand, please recommend one of your own blogs. http://blog.csdn.net/fantexi1...
fastcgi_pass 0.0.0.0:9000; What the hell is 0.0.0.0
If you are a novice, it is not recommended to configure it yourself. Try to use one-click configuration such as: https://lnmp.org's lnmp one-click installation
The configuration I use locally.
php-fpm Restart?
Please refer to mine and give it a try
It is recommended to check the logs of nginx and php to find the problem,
My conf is like this:
Also, is your php-fpm process normal?
$ ps aux|grep 'php-fpm'
21274 user php-fpm: master process (/usr/local/php5.6/etc/php-fpm.conf)
21275 user php-fpm: pool www
21276 user php-fpm: pool www