Differences between revisions 7 and 8
Revision 7 as of 2013-07-01 18:22:24
Size: 3611
Editor: GeoffSimmons
Comment: Fix formatting, drop nonexistent category, InterWiki.
Revision 8 as of 2013-07-02 09:19:09
Size: 3627
Editor: DarkErr
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: [[ru/nginx/FastCGI|Russian]]-~ ~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: English -[[ru/nginx/FastCGI|Русский]]-~

Translation(s): English -Русский


Install and configure FastCGI for nginx Webservice

FastCGI for nginx

To get FastCGI running for the nginx webservice, you will install the debian package fcgiwrap. Most of the documentation simply tell only aspects of the configuration. For example the SCRIPT_FILENAME and SCRIPT_NAME parameter in the nginx configuration: Both are needed.

This setup is done on a debian squeeze system with nginx 0.7.67-3 and fcgiwrap 1.0-1.

# apt-get install fcgiwrap

Configure nginx for FastCGI

Add a location configuration for cgi-bin at the proper place.

    location ~ ^/cgi-bin/.*\.cgi$ {
        gzip           off;
        root           /var/www/nginx-default;
        fastcgi_pass   unix:/var/run/fcgiwrap.socket;
        # include      fastcgi_params;
        fastcgi_param  QUERY_STRING       $query_string;
        fastcgi_param  REQUEST_METHOD     $request_method;
        fastcgi_param  CONTENT_TYPE       $content_type;
        fastcgi_param  CONTENT_LENGTH     $content_length;

        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        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;
    }

Most part of the fastcgi_param area are copy and pasted by the web sources. The intresting parts are

  • root /var/www/nginx-default;
  • fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  • fastcgi_param SCRIPT_NAME $fastcgi_script_name;

The root variable must set to the directory, where the cgi-bin directory lives. If you left the root variable in the location configuration, then nginx uses his default directory /usr/local/nginx/html/cgi-bin/ScriptName.cgi. You cant' use only the full path in the fastcgi_param SCRIPT_FILENAME variable. This won't work!

The fastcgi_param SCRIPT_FILENAME variable set the fullpath of the script. In my example the documentroot and fastcgi_script_name variable are used.

The fastcgi_param SCRIPT_NAME variable set the cgi script filename only.

All three parameters (root, fastcgi_param SCRIPT_FILENAME, fastcgi_param SCRIPT_NAME) are important.


CategorySoftware CategorySystemAdministration