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 am planning to switch my website (drupal 6.25) from apache to nginx. i have prepared everything for nginx and tested it on port 81. it is working fine. and now i changed listen from 81 to 80 and stop apache and start nginx. the website starts giving


504 Gateway Time-out nginx/0.8.54

and serves nothing :( my nginx server is

server {
        listen   80 backlog=128;
        root /var/www/web1/htdocs;
        index index.php index.html index.htm;        
        server_name www.example.com;

        location / {
        if (!-e $request_filename) {
                rewrite ^/(.*)$ /index.php?q=$1 last;
                }
        }

        access_log /var/log/nginx.web1.log;
        error_log /var/log/nginx.web1.error.log error;
        location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
                rewrite ^/favicon.ico$ /sites/all/themes/sky/favicon.ico break;
                access_log        off;
                expires           30d;
        }
        location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        #fastcgi_pass  127.0.0.1:9000; #I have tried this option as well
        fastcgi_pass  unix:/tmp/php.socket;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/web1/htdocs/$fastcgi_script_name;
    }
}

and the nginx.conf contains:


user www-data;
worker_processes 5;
pid /var/run/nginx.pid;

events {
        worker_connections 64;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        keepalive_requests      20;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_static       on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

 include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

any idea of what is wrong? or how can i fix it?
Thanks a lot for your help

share|improve this question
    
The error says "Gateway timeout" yet you're not showing any configuration of PHP. Please provide this or people won't be able to help you much. –  Martin Fjordvald May 3 '12 at 12:08
    
in php.ini, i have request_terminate_timeout=30s max_execution_time = 30 memory_limit = 2048M default_socket_timeout = 60 what else you might need from php.ini? –  Alaa Alomari May 3 '12 at 12:42
    
Anything in /var/log/nginx/access.log or /var/log/nginx/error.log? –  pjmorse May 3 '12 at 13:30
    
Mostly interested in how you spawn php, I was suspecting that you didn't at all but I didn't want to put an answer until I knew it. Seems vartec didn't mind though so follow his advice. –  Martin Fjordvald May 3 '12 at 14:18
    
@pjmorse: nothing wrong at all in the error log. –  Alaa Alomari May 5 '12 at 9:27

1 Answer 1

up vote 1 down vote accepted

You're trying to connect to PHP Fast-CGI on unix:/tmp/php.socket, but you're not running PHP Fast-CGI daemon. PHP-FPM is a separate daemon and nginx will not spawn it automatically.

See PHP documentation on deploying FastCGI Process Manager (FPM) and HOWTO for installing Nginix + PHP-FPM on Ubuntu

If you're using standard install, you're most likely will have a service named php-fpm or php5-fpm, which you should start and add to list of services started automatically.

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.