server { listen 80; server_name localhost; access_log /data/sites_logs/default.log combined; root /data/sites/default; index index.htm index.html index.php; if ( $query_string ~* ".*[\;'\<\>].*" ){ return 404; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 7d; } ###########################################隱藏index.php location / { index index.htm index.html index.php; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } ##########################################pathinfo 模式# location ~ .*\.(php|php5)?$ {# #fastcgi_pass remote_php_ip:9000;# fastcgi_pass unix:/dev/shm/php-cgi.sock;# fastcgi_index index.php;# include fastcgi.conf;# } location ~ \.php$ { fastcgi_pass phpfpm:9000; fastcgi_index index.php; include fastcgi_params; #設定PATH_INFO並改寫SCRIPT_FILENAME,SCRIPT_NAME伺服器環境變數 set $fastcgi_script_name2 $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; fastcgi_param SCRIPT_NAME $fastcgi_script_name2; }}
回複內容:
server { listen 80; server_name localhost; access_log /data/sites_logs/default.log combined; root /data/sites/default; index index.htm index.html index.php; if ( $query_string ~* ".*[\;'\<\>].*" ){ return 404; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 7d; } ###########################################隱藏index.php location / { index index.htm index.html index.php; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } ##########################################pathinfo 模式# location ~ .*\.(php|php5)?$ {# #fastcgi_pass remote_php_ip:9000;# fastcgi_pass unix:/dev/shm/php-cgi.sock;# fastcgi_index index.php;# include fastcgi.conf;# } location ~ \.php$ { fastcgi_pass phpfpm:9000; fastcgi_index index.php; include fastcgi_params; #設定PATH_INFO並改寫SCRIPT_FILENAME,SCRIPT_NAME伺服器環境變數 set $fastcgi_script_name2 $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; fastcgi_param SCRIPT_NAME $fastcgi_script_name2; }}
你php-fpm配置的不符吧 本地應該是 127.0.0.1:9000 你phpfpm:9000 phpfpm是網域名稱還是什麼 看看nginx的日誌 說什麼
被mac os分區格式坑了一把。
mac os分區格式有2種:
1、Mac OS 擴充(區分大小寫,日誌式)
2、Mac OS 擴充(日誌式)
我的主盤分區預設是第二種。通過docker掛在的話,就出現了這樣的問題。
如果是伺服器環境應該不會有這樣的問題。
location ~* \.php$
~* 表示不區分大小寫.