学习是最好的投资!
應該是把break改成last就好了
location / { rewrite ^/ /index.php break; }
你的這一段意思為,將所有的uri轉發請求重寫為index.php 然後break,新的重寫後的uri(在這個列子被重寫為index.php)不會再去匹配下面這個location ,所以你的php檔案沒有傳遞給php-fpm去解析。但是換成last以後,新的uri會重新匹配符合條件的location,所以index.php被傳遞給php-fpm解析執行了。
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; }
如果不明白,毛遂自薦自己的一篇部落格。 http://blog.csdn.net/fantexi1...
fastcgi_pass 0.0.0.0:9000; 0.0.0.0是什麼鬼
如果是新手的話, 不建議自己配置, 盡量使用一鍵配置比如:https://lnmp.org的lnmp一鍵安裝
server { listen 80; server_name frontend.com; index index.html index.php; root /Users/zhgxun/Public/html/php/zoulu/frontend/web; if (!-e $request_filename) { rewrite ^(.*)$ /index.php/ last; } location ~ [^/]\.php(/|$) { fastcgi_pass 127.0.0.1:9000; include fastcgi.conf; } access_log /Users/zhgxun/Public/html/logs/frontend.log main; }
我本地使用的配置。
php-fpm 重啟否?
server{ listen 80; server_name erp.XX.xyz; root /opt/local/www/project/xx/public; index index.php index.html index.htm; error_page 497 https://$host:$server_port$request_uri; if (!-e $request_filename) { rewrite ^(.*\.(?:css|less|scss|js|coffee|jpg|png|gif|jpeg|exe|xls|ico|xml|xlsx))$ /?sumibuy=common/munee/&files=/ last; rewrite ^/(.*) /index.php? last; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|xml|js|css|ttf|woff|ico|exe|xls|xlsx|html)$ { access_log off; expires 1d; break; } location ^~ /upload/{ access_log off; expires 1d; break; } location ~ .* { fastcgi_buffer_size 128k; fastcgi_buffers 32 32k; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /opt/local/www/project/XX/public$fastcgi_script_name; include fastcgi_params; } }
參考一下我的試試看
建議查看nginx和php的日誌來發現問題,
我的conf是這樣的:
location ~* \.php5?$ { include fastcgi_params; ##fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/usr/local/php5.6/var/run/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; }
另外,你的php-fpm進程正常麼? $ ps aux|grep 'php-fpm'21274 user php-fpm: master process (/usr/local/php5.6/etc/php-fpm.conf)21275 user php-fpm: pool www21276user 21276user php-fpm: pool www
雷雷
應該是把break改成last就好了
你的這一段意思為,將所有的uri轉發請求重寫為index.php 然後break,新的重寫後的uri(在這個列子被重寫為index.php)不會再去匹配下面這個location ,所以你的php檔案沒有傳遞給php-fpm去解析。但是換成last以後,新的uri會重新匹配符合條件的location,所以index.php被傳遞給php-fpm解析執行了。
如果不明白,毛遂自薦自己的一篇部落格。 http://blog.csdn.net/fantexi1...
fastcgi_pass 0.0.0.0:9000; 0.0.0.0是什麼鬼
如果是新手的話, 不建議自己配置, 盡量使用一鍵配置比如:https://lnmp.org的lnmp一鍵安裝
我本地使用的配置。
php-fpm 重啟否?
參考一下我的試試看
建議查看nginx和php的日誌來發現問題,
我的conf是這樣的:
另外,你的php-fpm進程正常麼?
$ 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
21276user 21276user php-fpm: pool www
雷雷