Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Server: CentOs x86_64

/etc/php-fpm.d/webuser1.conf

[webuser1]
listen = 127.0.0.1:9001
listen.allowed_clients = 127.0.0.1
user = webuser1
group = webuser1

pm = dynamic
pm.max_children = 15
pm.start_servers = 3
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 2000

request_slowlog_timeout = 5
slowlog = /home/webuser1/tmp/logs/webuser1.slow.log

php_admin_value[error_log] = /home/webuser1/tmp/logs/webuser1.error.log
php_admin_flag[log_errors] = on

/etc/nginx/conf.d/web1.conf

server {
listen       80;
server_name  c64p1.v.lab.gavika.com;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
    root   /home/webuser1/www/public;
    index  index.html index.htm index.php;
}

error_page  404              /404.html;
location = /404.html {
    root   /usr/share/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}


# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9001;
    fastcgi_index  index.php;
#   fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

}

In Nginx logs, I have:

2013/05/18 15:21:52 [error] 2943#0: *1 FastCGI sent in stderr: "Primary script unknown"     while reading response header from upstream, client: 192.168.122.1, server: c64p1.v.lab.gavika.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "c64p1.v.lab.gavika.com"

How can I get this to work?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You have placed your root directives in the wrong places.

root should be defined in the server block, not in each location block. This is one of the most common nginx misconfigurations.

To resolve the issue, remove all of the root directives from each location block, and place the correct root directive within the server block, not within any location.

share|improve this answer
    
Thanks. Placing the root directive within server block solves the problem. I had built on the default configuration found in /etc/nginx/conf.d/default.conf. The package was installed from Fedora EPEL. –  Sudheer May 19 '13 at 7:45
    
Yes, they ship a misconfigured default. –  Michael Hampton May 19 '13 at 13:48

Can you share what Headers you are testing which give you these results? It looks like you are just doing a Get root (/) request through a browser?

Without any more info on the input Headers or how you are testing your config, most likely you are facing a location problem in your config.

My two pieces of advice are:

1) Check out the help pages on Nginx locations. The Nginx Wiki (http://wiki.nginx.org/Configuration) is a good place if you are starting. Also, Martin Fjordvald's primer (http://blog.martinfjordvald.com/2010/07/nginx-primer/) is good on location configs.

2) If I was having a problem getting my c64p1.v.lab.gavika.com config to work, I would fall back to a simple Nginx config based on a localhost server and get the localhost config to work first.

share|improve this answer

Your Answer

 
discard

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.