Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running nginx on EC2, with the goal of setting up phabricator. This is my nginx.conf file:

# For more information on configuration, see:
#   * Official English Documentation:
#   * Official Russian Documentation:

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/;

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
# 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/*;


This is 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   
 " ============================================================================

In my sites-enabled, I have a symlink to a configuration,, which is located in sites-available. Here are the contents of

 ## Phabricator
server {
    listen       80;

    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;

    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;

When I try to access, I get the following error in my nginx error log:

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

THe permissions for my webroot folder are set to 755.

What am I doing wrong?

share|improve this question
What research have you done? From what I've seen it may be related to a wrongly set SCRIPT_FILENAME in the nginx fastcgi_param directive. – Drew Khoury Aug 29 '13 at 4:44
I've been Googling around for several hours. The fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; comes from the config at… . It may be wrong. Where would I find the values being assigned to these variables? I know that $document_root is set in the root directive--which is correct (If I put an html file in my root folder I can access it no problem). Where can I find the value of $fastcgi_script_name? – Catherine Aug 29 '13 at 4:53
It think you should add the relevant information in your questions, so people answering it can do a good job. – Drew Khoury Aug 29 '13 at 4:55
What information am I missing that I can provide? I'd be more than happy to, I'm just not sure what I'm missing. – Catherine Aug 29 '13 at 4:57
Everything you said in your comment. I'm just pointing out that this information is valuable and probably worth throwing in the question in the fist place. – Drew Khoury Aug 29 '13 at 5:01

2 Answers 2

This is a copy/paste from my answer at . I actually ran into this same issue getting Phabricator set up a Google Cloud box.

SELinux will cause this error on CentOS/RHEL 7+ by default :(

To test if SELinux is the source of your woes, do

setenforce 0

... and see if everything works. If that fixed it, you can leave SELinux off (weak, you're better than that), or you can turn it back on with

setenforce 1

... and then properly fix the issue.

If you do

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

... you'll see the SELinux issue. In my case, it was denying PHP-FPM access to web files. You can run the following directives to fix it:

setsebool -P httpd_can_network_connect_db 1
setsebool -P httpd_can_network_connect 1

This actually didn't fix it for me at first, but then restoring SELinux context did it

restorecon -R -v /var/www

Hope that helps.

share|improve this answer
Your problem was "Primary script unknown"? – Michael Hampton Aug 9 at 19:18
Yup: 2015/08/09 18:14:31 [error] 10052#0: *20 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client:, server:, request: "GET / HTTP/1.1", upst ream: "fastcgi://", host: "" – siliconrockstar Aug 9 at 19:34

add following line after, "location /index.php {" in location section

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

share|improve this answer
Nope, that's not it. PHP FPM is running. Calling netstat -lpn shows, among other things: tcp 0 0* LISTEN 25141/php-fpm – Catherine Aug 29 '13 at 5:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.