-
Install nginx.
apt install nginx
-
Create dns record for domain and point to same host ip, here i will use hosts file.
echo "127.0.0.1 satu.dama.zip dua.dama.zip" >> /etc/hosts
-
Create directory for each website
# 1st website mkdir /var/www/html/satu # 2nd website mkdir /var/www/html/dua
-
Create simple html page for each website
echo "ini site satu" > /var/www/html/satu.dama.id/index.html echo "ini site dua" > /var/www/html/dua.dama.id/index.html
-
Create nginx conf for first website.
vim /etc/nginx/sites-available/satu server { listen 80; server_name satu.dama.id; #Need to replace With Your Domain root /var/www/html/satu.dama.id/; }
-
Create nginx conf for second website.
vim /etc/nginx/sites-available/dua server { listen 80; server_name dua.dama.id; #Need to replace With Your Domain root /var/www/html/dua.dama.id/; }
-
Nginx service doesnt import config file at
/etc/nginx/site-available
, but only imports config files at/etc/nginx/site-enabled
, so we have to copy or we can easily create a link to the directory.ln -s /etc/nginx/sites-available/satu /etc/nginx/sites-enabled/ ln -s /etc/nginx/sites-available/dua /etc/nginx/sites-enabled/
-
Restart the service
systemctl restart nginx
-
Run a test to see if everything works
$ curl satu.dama.id ini site satu $ curl dua.dama.id ini site dua
Configure Nginx Multisite
Updated: at 06:53 AMSuggest Changes