sudo nano /etc/httpd/conf/httpd.conf
add this line:
NameVirtualHost *:80
sudo nano /etc/httpd/sites-available/test1.com.conf
<VirtualHost *:80> ServerName test1.com DocumentRoot /home/test1.com/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /home/test1.com/> Options -Indexes +FollowSymLinks -MultiViews -Includes AllowOverride All AcceptPathInfo On Order allow,deny allow from all </Directory> ErrorLog /home/test1.com/error.log CustomLog /home/test1.com/requests.log combined </VirtualHost>
sudo nano /etc/httpd/sites-available/test2.com.conf
<VirtualHost *:80> ServerName test2.com DocumentRoot /home/test2.com/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /home/test2.com/> Options -Indexes +FollowSymLinks -MultiViews -Includes AllowOverride All AcceptPathInfo On Order allow,deny allow from all </Directory> ErrorLog /home/test2.com/error.log CustomLog /home/test2.com/requests.log combined </VirtualHost>
sudo ln -s /etc/httpd/sites-available/test1.com.conf /etc/httpd/sites-enabled/test1.com.conf
sudo ln -s /etc/httpd/sites-available/test2.com.conf /etc/httpd/sites-enabled/test2.com.conf
sudo nano /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 127.0.0.1 test1.com www.test1.com test1 127.0.0.1 test2.com www.test2.com test2
sudo service httpd restart
That’s it.