Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Server: CentOs x86_64


listen =
listen.allowed_clients =
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


server {
listen       80;

#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
location ~ \.php$ {
    root           html;
    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:, server:, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: ""

How can I get this to work?

share|improve this question
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 ( is a good place if you are starting. Also, Martin Fjordvald's primer ( is good on location configs.

2) If I was having a problem getting my 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


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.