Update system yum -y update && upgrade Installing nginx yum -y install epel-release yum -y install nginx
Backup configuration mkdir /root/backup cp -r /etc/nginx /root/backup/
Start Nginx daemon systemctl start nginx systemctl enable nginx
Create directory for each host mkdir /var/www/ mkdir /var/www/host1.darin.web.id mkdir /var/www/host2.darin.web.id chmod 755 /var/www/*
Create index file for each host vim /var/www/host1.darin.web.id/index.html
<html>
<head>
<title>host1.darin.web.id</title>
</head>
<body>
<p>host1.darin.web.id</p>
</body>
</html>
vim /var/www/host2.darin.web.id/index.html
<html>
<head>
<title>host2.darin.web.id</title>
</head>
<body>
<p>host2.darin.web.id</p>
</body>
</html>
chown nginx:nginx /var/www/*
Configure ServerBlock cd /etc/nginx/conf.d/ touch host1.darin.web.id.conf touch host2.darin.web.id.conf
vim host1.darin.web.id.conf
server {
listen 80;
server_name host1.darin.web.id;
access_log /var/log/nginx/host1.darin.web.id_access.log main;
error_log /var/log/nginx/host1.darin.web.id_error.log;
location / {
root /var/www/host1.darin.web.id/;
index index.html index.htm;
}
}
vim host2.darin.web.id.conf
server {
listen 80;
server_name host2.darin.web.id;
access_log /var/log/nginx/host2.darin.web.id_access.log main;
error_log /var/log/nginx/host2.darin.web.id_error.log;
location / {
root /var/www/host2.darin.web.id/;
index index.html index.htm;
}
}
nginx -t systemctl restart nginx