Nginx Multi Site
Ubuntu Nginx Multi Site Commands
1 sudo apt-get update -y 2 sudo apt-get upgrade -y 3 sudo apt-get install nginx 4 echo "ServerDefault" | sudo tee -a /var/www/html/index.html 5 sudo mkdir -p /var/www/html/web1 6 sudo chown -R $USER:$USER /var/www/html/web1 7 echo "Server1" | sudo tee -a /var/www/html/web1/index.html 8 sudo mkdir -p /var/www/html/web2 9 sudo chown -R $USER:$USER /var/www/html/web2 10 echo "Server2" | sudo tee -a /var/www/html/web2/index.html 11 sudo vi /etc/nginx/sites-available/web1.conf 12 sudo vi /etc/nginx/sites-available/web2.conf 13 sudo ln -s /etc/nginx/sites-available/web1.conf /etc/nginx/sites-enabled/ 14 sudo ln -s /etc/nginx/sites-available/web2.conf /etc/nginx/sites-enabled/ 15 sudo chmod -R 755 /var/www/html/ 16 sudo rm -rf /etc/nginx/sites-enabled/default 17 sudo rm -rf /etc/nginx/sites-available/default 18 sudo nginx -t 19 sudo service nginx status 20 sudo service nginx restart
sudo vi /etc/nginx/sites-available/web1.conf
server { listen 80; listen [::]:80; # below line is website 1's webroot root /var/www/html/web1; #what is your index file name mention here ex: login.html index index.html index.htm index.nginx-debian.html index.php login.html; # this Server name block you want to mention your domain name server_name ngnix1.kishoreweb.com www.ngnix1.kishoreweb.com; }
sudo vi /etc/nginx/sites-available/web2.conf
server { listen 80; listen [::]:80; # below line is website 2's webroot root /var/www/html/web2; #what is your index file name mention here ex: login.html index index.html index.htm index.nginx-debian.html index.php login.html; # this Server name block you want to mention your domain name server_name ngnix2.kishoreweb.com www.ngnix2.kishoreweb.com; }