我第一次使用Nginx,但是我更熟悉Apache和Linux。 我正在使用一个现有的项目,当我试图看到index.PHP我得到一个404文件未find。
这里是access.log条目:
2013/06/19 16:23:23 [error] 2216#0: *1 FastCGI sent in stderr: "Primary script unkNown" while reading response header from upstream,client: 127.0.0.1,server: localhost,request: "GET /index.PHP HTTP/1.1",upstream: "fastcgi://127.0.0.1:9000",host: "www.ordercloud.lh"
这里是网站可用的文件:
server { # Listening on port 80 without an IP address is only recommended if you are not running multiple v-hosts listen 80; # Bind to the public IP bound to your domain #listen 127.0.0.11:80; # Specify this vhost's domain name server_name www.ordercloud.lh; root /home/willem/git/console/frontend/www; index index.PHP index.html index.htm; # Specify log locations for current site access_log /var/log/access.log; error_log /var/log/error.log warn; # Typically I create a restrictions.conf file that I then include across all of my vhosts #include conf.d/restrictions.conf; # I've included the content of my restrictions.conf in-line for this example # BEGIN restrictions.conf # disable logging for favicon location = /favicon.ico { log_not_found off; access_log off; } # disable logging for robots.txt location = /robots.txt { allow all; log_not_found off; access_log off; } # Deny all attempts to access hidden files such as .htaccess,.htpasswd,.DS_Store (Mac). location ~ /. { deny all; access_log off; log_not_found off; } # END restrictions.conf # Typically I create a yiiframework.conf file that I then include across all of my yii vhosts #include conf.d/yiiframework.conf; # I've included the content of my yiiframework.conf in-line for this example # BEGIN yiiframework.conf # Block access to protected,framework,and nbproject (artifact from Netbeans) location ~ /(protected|framework|nbproject) { deny all; access_log off; log_not_found off; } # Block access to theme-folder views directories location ~ /themes/w+/views { deny all; access_log off; log_not_found off; } # Attempt the uri,uri+/,then fall back to yii's index.PHP with args included # Note: old examples use IF statements,which Nginx considers evil,this approach is more widely supported location / { try_files $uri $uri/ /index.PHP?$args; } # END yiiframework.conf # Tell browser to cache image files for 24 hours,do not log missing images # I typically keep this after the yii rules,so that there is no conflict with content served by Yii location ~* .(js|css|png|jpg|jpeg|gif|ico)$ { expires 24h; log_not_found off; } # Block for processing PHP files # Specifically matches URIs ending in .PHP location ~ .PHP$ { try_files $uri =404; fastcgi_intercept_errors on; # Fix for server variables that behave differently under Nginx/PHP-fpm than typically expected #fastcgi_split_path_info ^(.+.PHP)(/.+)$; # Include the standard fastcgi_params file included with Nginx include fastcgi_params; #fastcgi_param PATH_INFO $fastcgi_path_info; #fastcgi_index index.PHP; # Override the SCRIPT_FILENAME variable set by fastcgi_params fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # Pass to upstream PHP-FPM; This must match whatever you name your upstream connection fastcgi_pass 127.0.0.1:9000; } }
我的/home/willem/git/console由www-data:www-data(我的web用户正在运行PHP等)拥有,我已经给它777权限出于挫折感。
Nginx:“http”指令在/ etc / Nginx / sites-enabled / default中是不允许的:1
在生产中在Windows上部署Flask
如何在Nginx上使用Xdebug和Laravel在Mac上使用PHPStorm?
如何在Laravel Forge上安装CA软件包?
任何人都可以build议吗?
Nginx安装中间证书
如何为Ember.js + Express设置开发环境
Box API:如何使用https://api.Box.com/2.0/files/{fileId}/content获取位置属性
用Nginx + gunicorn + django间歇性502s
如何在Django,Varnish,Nginx中处理数千个遗留的URL?
来自FastCGI服务器的这个消息通常意味着它所给出的SCRIPT_FILENAME在其文件系统上没有找到或不可访问的文件。
/home/willem/git/console/frontend/www/index.PHP上的签出文件权限
是644吗?
和/ home / willem / git / console / frontend / www /
是755吗?
好吧,经过一天的努力,我发现了三件事
出于某种原因,我已经在9000端口上运行了,所以我改成了9001
我的默认网站正在拦截我的新网站,我再一次不承认为什么,因为它不应该,但我只是断开它
希望这可以节省一些麻烦!
这里是更详细的服务器故障链接: https : //serverfault.com/questions/517190/Nginx-1-fastcgi-sent-in-stderr-primary-script-unkNown/517207#517207
如果任何人有相同的错误:在我的情况下,问题是位于Nginx.conf中的位置块内的根指令缺少, 如在维基解释
我不知道如何计算$ document_root,但我解决了这个问题,通过确保我的文档根目录在/ usr / share / Nginx /只是html文件夹存在
“主脚本未知”是由SELinux安全上下文引起的。
客户得到回应
文件未找到。
* 19在读取来自上游的响应头时,在stderr中发送的FastCGI:“主脚本未知”
所以只需将Web根文件夹的安全上下文类型更改为httpd_sys_content_t
chcon -R -t httpd_sys_content_t / var / www / show
user nobody nobody; ### `user-1`,this is the user run Nginx woker process ... include servers/*.conf;
/etc/Nginx/servers/www.conf
location ~ .PHP$ { # fastcgi_pass 127.0.0.1:9000; # tcp socket fastcgi_pass unix:/var/run/PHP-fpm/fpm-www.sock; # unix socket fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
/etc/PHP-fpm.d/www.conf
[www] user = apache ### `user-2`,this is the user run PHP-fpm pool process user = apache ;listen = 127.0.0.1:9000 # tcp socket listen = /var/run/PHP-fpm/fpm-www.sock # unix socket listen.onwer = nobody ### `user-3`,this is the user for unix socket,like /var/run/PHP-fpm/fpm-www.sock listen.group = nobody # for tcp socket,these lines can be commented listen.mode = 0660
对于unix套接字,user-1需要与user-3相同,因为Nginx fastcgi_pass必须对unix套接字具有读/写权限。
否则Nginx将得到502 Bad Gateway ,而Nginx error.log有以下错误信息
* 36连接()到unix:/var/run/PHP-fpm/fpm-www.sock失败(13:权限被拒绝),同时连接到上游
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。