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.

When i start nginx it just doesn`t start correctly.

[root@xx]# /sbin/service nginx start
Starting nginx:                                            [  OK  ]
[root@xx]# /sbin/service nginx status
nginx dead but subsys locked

I cannot even stop it normally.

[root@xx]# /sbin/service nginx stop
Stopping nginx:                                            [FAILED]

But the nginx master process is alive:

[root@xx]# ps ux | grep nginx
root      7206  0.0  0.0  43156   944 ?        Ss   15:27   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

And if i try to launch it again it will fail to bind a port. So only way to stop it is to use kill.

THe nginx log is empty, nothing there. Nginx version - 1.0.13. RHEL 5.6 my nginx config.

user django django;
worker_processes 2;

pid        /opt/django/tmp/nginx.pid;

error_log /opt/django/logs/nginx/nginx_error_main.log;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    server_tokens off;

    ## Log Format
    log_format  main  '$remote_addr $host $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$gzip_ra$

    error_log /opt/django/logs/nginx/nginx_error.log debug;
    access_log  /opt/django/logs/nginx/nginx_access.log main;

    sendfile on;
    keepalive_timeout 65;

    ## Compression
    gzip              on;
    gzip_buffers      16 8k;
    gzip_comp_level   6;
    gzip_http_version 1.0;
    gzip_min_length   0;
    gzip_types        text/plain text/css image/x-icon image/png application/json application/x-javascript text/xml application/xml application/xml+r$
    gzip_vary         on;
    gzip_proxied      any;

    include /opt/django/configs/nginx/*.conf;
}


upstream my-backend {
    server localhost:9000;
}

server {
    listen 80;
    server_name test.com www.test.com;
    charset utf-8;

    root /opt/django/htdocs/spprod;

    access_log /opt/django/logs/nginx/test_access.log;
    error_log  /opt/django/logs/nginx/test_error.log;

    location /static {
        root /opt/django/htdocs/spprod;
        autoindex off;
        expires 1M;
    }


    location / {
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   REMOTE_HOST      $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-FORWARDED-PROTOCOL $scheme;
        proxy_pass http://my-backend;
    }

    error_page 500 502 503 504 /media/50x.html;
}

Any thought of what can be wrong and where should i look?

share|improve this question
    
Can you confirm that nginx is actually not functioning - e.g. by trying to retrieve a static file through it? Typically the 'service nginx status' command relies on the PID written to a file. You appear to have a non-default location of the PID file (in your nginx.conf) so it is conceivable that nginx is running fine, but the reported status is incorrect. (Admittedly, most init scripts write the pid independently of the process itself, but it remains a possibility). –  cyberx86 Mar 14 '12 at 23:02
    
Argghhh. Actually figured out error. It was not a nginx fault. If was a cisco firewall on server that blocked all request that maked me think nginx doesn`t work. So the only one question i have now is why it doesn`t stop when i do /sbin/service nginx stop –  Aldarund Mar 14 '12 at 23:19
    
As seemingly unlikely as two separate problems are, check if the PIDs match. The 'service nginx stop' command uses the PID it wrote out earlier (killproc -p ${pidfile} ${prog}), if there isn't a matching process with that PID, it can't successfully stop it. Compare cat /var/run/nginx.pid (or whatever your init script uses) to ps -ef | grep nginx –  cyberx86 Mar 14 '12 at 23:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.