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

I've set up nginx and got it (sort of) working on two different domains. But for some reason nginx only serves the index file of the directory, no matter what is entered in the address bar. eg. just displays

Here is my current config, if any of you guys/girls could help me out it'd be appreciated, thank you!

server {
    listen 80;

    index index.html index.php index.htm;

    access_log /home/sam/www/;
    error_log /home/sam/www/;
    root /home/sam/www/;
    error_page 401 401.html;
    error_page 403 403.html;
    error_page 404 404.html;
    error_page 500 502 503 504 500.html;

    location / {
            try_files $uri $uri/ /index.php?$args;

# rewrite adminpanel to use https
    rewrite ^/adminpanel(.*)$ https://$host$uri permanent;

# Add trailing slash to */wp-admin requests. Needed if wordpress is installed later
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

 # Directives to send expires headers
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
             expires 30d;

# Deny all attempts to access hidden files such as .htaccess, .htpasswd
    location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;

    location ~ \.php$ {
            try_files index index.php $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /home/sam/www/;


nginx.conf is default, I haven't made any changes to that.

share|improve this question
up vote 2 down vote accepted

It's because of this fastcgi_param SCRIPT_FILENAME /home/sam/www/;

It should be something like fastcgi_param SCRIPT_FILENAME $document_root/php/$fastcgi_script_name;

Per NGINX's documentation:

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.