Skip to content

Instantly share code, notes, and snippets.

@dragoljub-bogicevic-devtech
Last active June 21, 2017 18:36
Show Gist options
  • Save dragoljub-bogicevic-devtech/f18ba73b4497c82726c241d80dde6ece to your computer and use it in GitHub Desktop.
Save dragoljub-bogicevic-devtech/f18ba73b4497c82726c241d80dde6ece to your computer and use it in GitHub Desktop.
Set up nginx as web server for static content
#!/bin/bash
echo "Starting Provision: web server $1"
sudo apt-get update
sudo apt-get install -y nginx
sudo service nginx stop
sudo mkdir -p /var/www/html
sudo touch /var/www/html/index.html
echo "poy from $2" >> /var/www/html/index.html
sudo rm -rf /etc/nginx/sites-available/default
sudo rm -rf /etc/nginx/sites-enabled/default
sudo touch /etc/nginx/sites-enabled/default
echo "server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm;
server_name $2 www. $2;
location / {
allow $3;
deny all;
}
}" >> /etc/nginx/sites-enabled/default
sudo service nginx start
echo "Machine: web server $1" >> /var/www/html/index.html
echo "*************** Provision web $1 complete ***************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment