Nginx: Essential Commands

Frequently used commands

Install Nginx


sudo apt-get install nginx



Start And Stop Nginx server

Start


sudo systemctl start nginx


Stop


sudo systemctl stop nginx



Current Status


sudo systemctl status nginx



Restart And Reload

Restart


sudo systemctl restart nginx


Reload


sudo systemctl reload nginx



Enable Or Disable

Enable(Start Automatically)


sudo systemctl enable nginx


Disable( Stop automatic Start On booting)


sudo systemctl disable nginx



Completely remove nginx


sudo apt-get purge nginx nginx-common nginx-full



Test Configuration


sudo nginx -t



Related

Add symbolic link


sudo ln -s  /etc/nginx/sites-available/your-server etc /etc/nginx/sites-enabled


Clean cache


sudo apt-get autoclean
sudo apt-get autoremove