service nginx start is ok but nginx not running

I have a ubuntu 14.04 machin with nginx, which was working fine until I last used my computer that was last night. Today when I started my computer and navigated to 127.0.0.1 it said server not found so I tried restarting nginx nginx start was successful but I had the same issue on 127.0.0.1 so I checked netstat -ntlp where I did not see port 80 anywhere. I am not sure what went wrong and clueless about it. Here is the nginx log :

2015/03/22 17:50:10 [alert] 5030#0: unlink() "/run/nginx.pid" failed (2: No such file or directory)

1 Answer

Problem:

It is because by default Apache and nginx are listening to the same port number (:80)

  1. Reconfigure nginx to listen on a different port by following these steps:

    sudo vim /etc/nginx/sites-available/default
  2. Change all ports :80 to :8000 or another unused port number.

  3. Check if the configuration is correct:

    sudo service nginx configtest
  4. Restart nginx:

    sudo service nginx restart
  5. Check the status of nginx:

    sudo service nginx status

Note: You can also check on your browser whether nginx is working:

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like