Results 1 to 2 of 2

Thread: Nginx with fastcgi php

  1. #1
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Nginx with fastcgi php

    hi,

    I am trying to set up an nginx server. I intend to use it with, php and python, and probably with frameworks like django and codeigniter. However, I can't get it working. This is what I did:

    Installed these from Install/remove software:
    nginx,FastCGI,php5-fastcgi,python-fcgi,spawn-fcgi

    My current nginx.conf file is this (Stripped comments):

    Code:
    user  nginx;
    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        index  index.html index.htm;
        server {
            listen       80;
            server_name <my server name was here>;
    
            root   <my root directory was here>;
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /srv/www/htdocs/;
            }
    
            location ~ \.php$ {
                root           html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                include        fastcgi_params;
            }
    
    }
    I couldn't manage to spawn php5 cgi with using spawn-fcgi, instead I typed this into terminal:

    Code:
    php-cgi5 -b 127.0.0.1:9000
    What happens is: when I type a php url to address bar, I only get a text saying "No input file specified."

    This is what I get when I make netcat sit on 9000, and go for <hostname>/phpinfo.php:
    Code:
    SCRIPT_FILENAME/scripts/phpinfo.php
                                       QUERY_STRINGREQUEST_METHODGET
                                                                    CONTENT_TYPECONTENT_LENGTH
    
                                                                                              SCRIPT_NAME/phpinfo.php
    
                     REQUEST_URI/phpinfo.php
    
                                            DOCUMENT_URI/phpinfo.php
    DOCUMENT_ROOT/usr//htmSERVER_PROTOCOLHTTP/1.1GATEWAY_INTERFACECGI/1.1
                                                                         SERVER_SOFTWAREnginx/0.8.53
    REMOTE_ADDR<my ip was here>
                              REMOTE_PORT57546
                                              SERVER_ADDR<my ip was here>
                                                                        SERVER_PORT80
                                                                                     SERVER_NAME<hostname was here>REDIRECT_STATUS200       HTTP_HOST<hostname was here>LHTTP_USER_AGENTMozilla/5.0 (X11; Linux i686; rv:2.0b13pre) Gecko/20110317 Firefox/4.0b13pre
                                                                    ?HTTP_ACCEPTtext/html,applicatioHTTP_ACCEPT_ENCODINGgzip, deflateHTTP_ACCEPT_CHARSETISO-8859-1,utf-8;q=0.7,*;q=0.7HTTP_KEEP_ALIVE115
    HTTP_CONNECTIONkeep-alive
    There are clearly some config problems here, but can't find out what are they, since this is first time I try to setup nginx and fastcgi. I was using apache before.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  2. #2
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: Nginx with fastcgi php

    Finally fixed, to those who are interested, I changed this;
    Code:
                fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    to, this:

    Code:
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •