我有以下設置。未找到php文件的NGINX文件
Nginx作爲一個web服務器。將請求傳遞給在Rails服務器上運行的獨角獸。我現在想在mysite.com/blog上安裝wordpress。因此我安裝並配置了php和fastcgi。 nginx的配置如下:
upstream unicorn_mysite {
server unix:/tmp/unicorn.mysite.sock fail_timeout=0;
}
server {
listen 80;
server_name mysite.com;
return 301 https://www.$server_name$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /opt/certs/thinbundle.crt;
ssl_certificate_key /opt/certs/mysite.key;
server_name mysite.com;
root /opt/www/mysite/current/public;
location /blog {
index index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /blog/index.php?q=$1 last;
}
location ~ .php(?|$) {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/www/mysite_wordpress$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
location ~ ^/assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass http://unicorn_mysite;
proxy_set_header X-Forwarded-Proto $scheme;
add_header Front-End-Htps on;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
和fastcgi_params文件/ etc/nginx的/ fastcgi_params包含:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
當我去mysite.com/blog我得到這個:
當我看nginx的日誌,我看到:
2016/03/15 11:26:35 [error] 23109#23109: *29 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 185.14.209.183, server: mysite.com, request: "GET /blog HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.mysite.com"
2016/03/15 11:28:36 [error] 23109#23109: *35 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 185.14.209.183, server: mysite.com, request: "GET /blog HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.mysite.com"
2016/03/15 11:32:12 [error] 23109#23109: *38 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 185.14.209.183, server: mysite.com, request: "GET /blog HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.mysite.com"
2016/03/15 11:36:41 [error] 23109#23109: *45 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 185.14.209.183, server: mysite.com, request: "GET /blog HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.mysite.com"
有人可以幫我解決這個文件沒有找到。哪個文件沒有找到?它在哪裏尋找它 - 即爲什麼它找不到它!這些錯誤都不能幫助我找出問題的原因!