cd usr/local/etc/nginx/ (takes us to nginx.conf file)
ls (lists all the files present on nginx folder)
To Read the content of nginx.conf file:
On your Terminal:
cat usr/local/etc/nginx/nginx.conf (views the content of the nginx.conf file)
To edit (add and remove code from nginx.conf file)
On your Terminal:
sudo vim nginx.conf (Opens nginx.conf on vim text editor)
#If you want to add and remove code you need to be on INSERT Mode on Vim.
On your Editor:
Press ('i') to activate insert mode (now you can add and remove code)
To Save Changes and Exit Vim:
Press ('Esc') to Exit INSERT Mode:
Type: (':wq') to save changes and quit .
To restart Ngnix:
sudo nginx -s reload
sudo nginx
To know if Nginx is running sucessfully:
sudo nginx -t
To reload Nginx
sudo nginx -s reload
To Check if anything is running on your port, let's say your example port is 8080
sudo lsof -i : 8080
If you get any errors on your port or if nginx is not running > always try restarting nginx.
If restarting doesn't work use the following command and restart nginx and reload nginx, it should work if your nginx configuration file doesn't have faulty code.
ps aux | grep nginx
If that doesn't work try killing the process and restarting nginx.
To kill all the processes running through nginx:
sudo pkill -f nginx
(Restart nginx after that with required command).
If you want to make your own ('.conf') file Example: 'local-dev.conf'.
Go to servers directory:
On Mac terminal:
cd usr/local/etc/nginx/servers
sudo nano 'local-dev.conf'
(now you can add your nginx configuration code on it.)
To route to your nginx.conf file.
On your Terminal:
cd usr/local/etc/nginx/ (takes us to nginx.conf file)
ls (lists all the files present on nginx folder)
To Read the content of nginx.conf file:
On your Terminal:
cat usr/local/etc/nginx/nginx.conf (views the content of the nginx.conf file)
To edit (add and remove code from nginx.conf file)
On your Terminal:
sudo vim nginx.conf (Opens nginx.conf on vim text editor)
#If you want to add and remove code you need to be on INSERT Mode on Vim.
On your Editor:
Press ('i') to activate insert mode (now you can add and remove code)
To Save Changes and Exit Vim:
Press ('Esc') to Exit INSERT Mode:
Type: (':wq') to save changes and quit .
To restart Ngnix:
sudo nginx -s reload
sudo nginx
To know if Nginx is running sucessfully:
sudo nginx -t
To reload Nginx
sudo nginx -s reload
To Check if anything is running on your port, let's say your example port is 8080
sudo lsof -i : 8080
If you get any errors on your port or if nginx is not running > always try restarting nginx.
If restarting doesn't work use the following command and restart nginx and reload nginx, it should work if your nginx configuration file doesn't have faulty code.
ps aux | grep nginx
If that doesn't work try killing the process and restarting nginx.
To kill all the processes running through nginx:
sudo pkill -f nginx
(Restart nginx after that with required command).
If you want to make your own ('.conf') file Example: 'local-dev.conf'.
Go to servers directory:
On Mac terminal:
cd usr/local/etc/nginx/servers
sudo nano 'local-dev.conf'
(now you can add your nginx configuration code on it.)