在运行nginx时遇到问题

我在EC2上运行nginx,目的是设置phabricator。 这是我的nginx.conf文件:

# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user eng; worker_processes 1; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; # another virtual host using mix of IP-, name-, and port-based configuration include /etc/nginx/sites-enabled/*; } 

这是conf.d:

  " ============================================================================ " Netrw Directory Listing (netrw v134) " /etc/nginx/conf.d " Sorted by name " Sort sequence: [\/]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$ " Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec " ============================================================================ ../ virtual.conf 

在我的网站启用,我有一个符号链接到一个configuration,phabricator.mysite.com,它位于网站可用。 这里是phabricator.mysite.com的内容:

  ## Phabricator server { listen 80; server_name phabricator.mysite.com; root /home/eng/phabricator/phabricator/webroot; try_files $uri $uri/ /index.php; location / { index index.php; if ( !-f $request_filename ) { rewrite ^/(.*)$ /index.php?__path__=/$1 last; break; } } location /index.php { fastcgi_pass localhost:9000; fastcgi_index index.php; #required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; #variables to make the $_SERVER populate in PHP fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 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 GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; } } 

当我尝试访问phabricator.mysite.com时,在我的nginx错误日志中出现以下错误:

 2013/08/29 04:12:52 [error] 30977#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 50.240.220.206, server: phabricator.mysite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "phabricator.mysite.com" 

我的webroot文件夹的权限设置为755。

我究竟做错了什么?

这是从我的答案复制/粘贴在https://stackoverflow.com/questions/22090350/nginx-unable-to-open-primary-script/31907528#31907528 。 我实际上碰到了同样的问题,Phabricator成立了一个Google云端框。

SELinux在CentOS / RHEL 7+上会导致这个错误默认:(

为了testingSELinux是否是你的悲哀的根源,

 setenforce 0 

…看看是否一切正常。 如果解决了这个问题,你可以closuresSELinux(弱,你比这更好),或者你可以把它重新打开

 setenforce 1 

…然后妥善解决这个问题。

如果你这样做

 tail -f /var/log/audit/audit.log 

…你会看到SELinux的问题。 在我的情况下,它拒绝PHP-FPM访问网页文件。 您可以运行以下指令来修复它:

 setsebool -P httpd_can_network_connect_db 1 setsebool -P httpd_can_network_connect 1 

起初,这实际上并没有解决这个问题,但是恢复了SELinux的上下文

 restorecon -R -v /var/www 

希望有所帮助。

在位置部分添加“location /index.php {”后面的行

root / home / eng / phabricator / phabricator / webroot;