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.

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. example.com/about just displays example.com

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

server {
    listen 80;
    server_name samayres.net www.samayres.net;

    index index.html index.php index.htm;


    access_log /home/sam/www/samayres.net/logs/access_logs.log;
    error_log /home/sam/www/samayres.net/logs/error_logs.log;
    root /home/sam/www/samayres.net;
    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_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /home/sam/www/samayres.net/index.php;
             }

}

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It's because of this fastcgi_param SCRIPT_FILENAME /home/sam/www/samayres.net/index.php;

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

Per NGINX's documentation: http://wiki.nginx.org/HttpFastcgiModule

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.