[vc_row][vc_column][vc_column_text]
Steps to Setup Apache Virtual Hosts on CentOS 7
Step 1 – Install Webserver:
yum install -y httpd
After install Start and Enable Service
Step 2 – Enable Service:
#systemctl enable httpd
Step 3 – Start Service:
#systemctl start httpd
Step 4 – Allow Firewall:
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Step 5 – Create Path Web:
mkdir -p /var/www/test1.com
mkdir -p /var/www/test2.com
Step 6 – Create HTML File:
This is for Test1 web page
vi /var/www/test1.com/index.html
<!doctype html >
<html lang="en">
<head>
<title> to test1.com</title>
</head>
<body>
<h1>! test1.com home page!</h1>
</body>
</html>
This is for Test2 web page
vi /var/www/test2.com/index.html
<!doctype html >
<html lang="en">
<head>
<title> to test2.com</title>
</head>
<body>
<h1>! test2.com home page!</h1>
</body>
</html>
Step 7 – Make permision:
chown -R apache: /var/www/test1.com
chown -R apache: /var/www/test2.com
Step 8 – Create Virsual Host:
This is for test1.com conf
vi /etc/httpd/conf.d/test1.com.conf
<VirtualHost *:80>
ServerName test1.com
ServerAlias www.test1.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/test1.com
<Directory /var/www/test1.com>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/test1.com-error.log
CustomLog /var/log/httpd/test1.com-access.log combined
</VirtualHost>
This is for test2.com conf
vi /etc/httpd/conf.d/test2.com.conf
<VirtualHost *:80>
ServerName test2.com
ServerAlias www.test2.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/test2.com
<Directory /var/www/test2.com>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/test2.com-error.log
CustomLog /var/log/httpd/test2.com-access.log combined
</VirtualHost>
Step 9 – Restart
After Setup Restart Service Hosting
systemctl restart httpd
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][/vc_column_text][/vc_column][/vc_row]