Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install nginx on Ubuntu 14.04
sudo apt-get update
sudo apt-get install nginx
  • Default serve directory
  • create directory to store html
sudo mkdir -p /var/www/{site}.com/html
sudo chown -R $USER:$USER /var/www/{site}.com/html
sudo chmod -R 755 /var/www
  • create html file
touch /var/www/{site}.com/html/index.html
  • create server block file
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/{site}.com
sudo nano /etc/nginx/sites-available/{site}.com
  • look in file and change data
# change root to
root /var/www/{site}.com/html;
# change server_name to
server_name {site}.com www.{site}.com;
  • enable site
sudo ln -s /etc/nginx/sites-available/{site}.com /etc/nginx/sites-enabled/
  • remove default enable site
sudo rm /etc/nginx/sites-enabled/default
  • restart nginx
sudo service nginx restart


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.