How to verify if nginx is running or not?
After running an ASP.NET vNext project on my local machine I was trying to figure out how I can run it on nginx as it looks to be a recommended choice
Following jsinh's blog, I installed it using:
sudo apt-get update
sudo apt-get install nginx -y
I was trying to understand whether it is working or not by using:
ifconfig eth0 | grep inet | awk '{ print $2}'
After running
sudo service nginx start
sudo service nginx stop
However, the output is always the same:
How to verify if nginx is running or not?
Solution 1:
Looking at the requirement you have, the below command shall help:
service nginx status
Solution 2:
You could use lsof
to see what application is listening on port 80:
sudo lsof -i TCP:80
Solution 3:
This is probably system-dependent, but this is the simplest way I've found.
if [ -e /var/run/nginx.pid ]; then echo "nginx is running"; fi
That's the best solution for scripting.
Solution 4:
If you are on mac machine and had installed nginx using
brew install nginx
then
brew services list
is the command for you. This will return a list of services installed via brew and their corresponding status.