The httpd configuration before adding the VirtualHost:
Code: Select all
ServerName www. 1stwebiste. com:80
Alias 1stwebsite "/var/www/html/1stwebsite/"
ServerAdmin admin @ 1stwebsite.com
DocumentRoot "/var/www/html/1stwebsite"
<Directory /1stwebsite/>
Options Indexes MultiViews FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
UseCanonicalName Off
To add a virtual server, we have to change the current website (master server) to a virtual server.
Amend as follows
Code: Select all
[root @ centos ~]$ vim /etc/http/conf/httpd.conf
# Global Config #
NameVirtualHost *:80
#-----------------------------------------------------------
#-----=== !!! MAIN WEB SERVER www. 1stwebsite .com !!!! ===-----
<VirtualHost *:80>
ServerName www. 1stwebsite .com:80
ServerAdmin admin @ 1stwebsite.com
DocumentRoot "/var/www/html/1stwebsite/"
<Directory /var/www/html/1stwebsite/>
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#-----====== !!! END Config www. 1stwebsite .com !!!! =======----
Code: Select all
[root @ centos ~]$ service httpd restart
Code: Select all
[root @ centos ~]$ /etc/init.d/httpd restart
If everything is fine, and the server works perfectly, the next virtualhost can be added. The next virtualhost is forum.1stwebsite.com
Add the following configuration
Code: Select all
[root @ centos ~]$ vim /etc/http/conf/httpd.conf
#-----=== !!! www.forum. 1stwebsite .com !!!! ===-----
<VirtualHost *:80>
ServerName www.forum.1stwebsite.com:80
ServerAdmin [email protected]
DocumentRoot "/var/www/html/forum.1stwebsite.com/"
<Directory /var/www/html/forum.1stwebsite.com/>
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#-----====== !!! END Config www. forum.1stwebsite .com !!!! =======----
Code: Select all
[root @ centos ~]$ service httpd restart
Code: Select all
[root @ centos ~]$ /etc/init.d/httpd restart