Nginx
- is a HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server
Installation
homebrew
brew install nginx
apt
sudo apt update sudo apt install nginx
Configuration
homebrew
1. The default place of nginx.conf on Mac after installing with brew is:
/usr/local/etc/nginx/nginx.conf2. default docroot is:
/usr/local/var/www3. to change default docroot, modify the nginx.conf
…location / {root /RIGHT/HERE/CHANGE/TO/YOUR/DESIRED/PATH;index index.html index.htm;}…4. nginx will load all files in:
/usr/local/etc/nginx/servers/
display nginx.conf location and verify syntax
display path to nginx.conf and verify its syntax
nginx -t
Start Stop Restart
homebrew
1. start nginx
to have launchd start nginx now and restart at login:
brew services start nginxor, if you don’t want/need a background service you can just run:
sudo nginxtest it by going to http://localhost:8080
2. stop nginx
brew services stop nginxsudo nginx -s stop <— fast shutdownsudo nginx -s quit <— graceful shutdown
linux
sudo service bind9 start sudo service bind9 stop sudo service bind9 restart sudo service bind9 status sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl status nginx