Home > CentOS > Setup VirtualHost

Create virtural host config file
mkdir /etc/httpd/conf/extra
vim /etc/httpd/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot "/var/www/vhosts/my-helper/htdocs"
ServerName my-helper.com
ServerAlias www.my-helper.com
<Directory "/var/www/vhosts/my-helper/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
ErrorLog "/var/www/vhosts/my-helper/logs/error.log"
CustomLog "/var/www/vhosts/my-helper/logs/access.log" common

Enable virtural host
vim /etc/httpd/conf/httpd.conf
Uncomment the following line:

NameVirtualHost *:80

Append the following line to the end of the file:

Include /etc/httpd/conf/extra/httpd-vhosts.conf

Check config file
apachectl graceful

Restart server
/etc/init.d/httpd restart

Flag Counter