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 have a concrete5 site that works 'out of the box' in apache server. However I am having a lot of trouble running it in nginx.

The following is the nginx configuration i am using:

server {
    root /home/test/public;
    index index.php;

    access_log /home/test/logs/access.log;
    error_log /home/test/logs/error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ index.php;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }
    # pass the PHP scripts to FastCGI server listening on unix socket
    #
    location ~ \.php($|/) {
            fastcgi_pass unix:/tmp/phpfpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            include fastcgi_params;
    }
    location ~ /\.ht {
            deny  all;
    }
}

I am able to get the homepage but am having problem with the inner pages. The inner pages display an "Access denied". Possibly the rewrite is not working, in effect I think its querying and trying to execute php files directly instead of going through the concrete dispatcher.

I am totally lost here.

Thank you for your help, in advance.

share|improve this question
    
Did you tried config like this? –  hangover Jun 27 '12 at 15:04

1 Answer 1

up vote 0 down vote accepted

Changed the configurations to:

server {
    root /home/test/public;
    index index.php;

    access_log /home/test/logs/access.log;
    error_log /home/test/logs/error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /index.php/$request_uri;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    # pass the PHP scripts to FastCGI server listening on unix socket
    #
    location ~ \.php($|/) {
            set $script $uri;
            if ($uri ~ "^(.+\.php)(/.+)") {
                    set $script $1;
            }
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$script;
            fastcgi_intercept_errors on;
            fastcgi_pass unix:/tmp/phpfpm.sock;
    }

    location ~ /\.ht {
            deny  all;
    }
}

And it works thanks to hangover and the link he provided.

I am still not clear what I did wrong, maybe an nginx expert can help me understand.

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.