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

As I'm struggling for 8 hours to make Nginx works, I (finally) tracked the problem and eventually found it. I was getting HTTP 500 ERROR (Internal Server Error). I manipulated the configurations for every piece of software I have, but no luck.

Anyway, the problem was in the FastCGI SCRIPT_FILENAME and FastCGI SCRIPT_NAME these 2 variables were causing 500 HTTP ERROR when including them to the host configuration file. to make it clear, here's some snippets of my configurations.
1. sites-enabled/default:

   location ~ \.php$
    {
    #fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/www$fastcgi_script_name;
     fastcgi_param  QUERY_STRING     $query_string;
        fastcgi_param  REQUEST_METHOD   $request_method;
        fastcgi_param  CONTENT_TYPE     $content_type;
        fastcgi_param  CONTENT_LENGTH   $content_length;
    #including fastcgi_params, is the root of all evil.
    include /etc/nginx/fastcgi_params;        
    }

2.fastcgi_params, the included file(in the previous snippet):

fastcgi_param   QUERY_STRING        $query_string;
fastcgi_param   REQUEST_METHOD      $request_method;
fastcgi_param   CONTENT_TYPE        $content_type;
fastcgi_param   CONTENT_LENGTH      $content_length;
#HERE, THE ERROR IS THROWN.
#Commenting the SCRIPT_FILENAME AND SCRIPT_NAME removes the ERROR.
fastcgi_param   SCRIPT_FILENAME     $request_filename;
fastcgi_param   SCRIPT_NAME     $fastcgi_script_name;
fastcgi_param   REQUEST_URI     $request_uri;
fastcgi_param   DOCUMENT_URI        $document_uri;
fastcgi_param   DOCUMENT_ROOT       $document_root;
fastcgi_param   SERVER_PROTOCOL     $server_protocol;

fastcgi_param   GATEWAY_INTERFACE   CGI/1.1;
fastcgi_param   SERVER_SOFTWARE     nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR     $remote_addr;
fastcgi_param   REMOTE_PORT     $remote_port;
fastcgi_param   SERVER_ADDR     $server_addr;
fastcgi_param   SERVER_PORT     $server_port;
fastcgi_param   SERVER_NAME     $server_name;

fastcgi_param   HTTPS           $https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS     200;

as I commented the solution looks simple, but actually, commenting SCRIPT_NAME and SCRIPT_FILENAME breaks my code since the framework I'm developing on(Codeigniter) is using SCRIPT_NAME to obtain the URL of my website, besides the SCRIPT_NAME is assigned to a global variable in PHP($_SERVER['SCRIPT_NAME']). so I can't comment these 2 lines.

So, what's the solution to this problem, is it a bug? or just misconfiguration? By the way, the error's log doesn't show anything useful.

Additional information:
1. I'm running Debian 6.
2. using dotdeb build.
3. using PHP5-FPM.
3. I get 403 HTTP errors when accessing directories.
4. I get Codeigniter's(the framework) custom 404 HTTP errors when a file was not found.

share|improve this question

1 Answer 1

According to Nginx documentation, you should be using:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

And specifying your root directory outside of the location blocks:

server {
  server_name www.domain.com;
  root /var/www/nginx-default/;
  location / {
    [...]
  }
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.