Virtual hosts

Support for webhosts that use CentOS
Post Reply
Posts: 1
Joined: 2012/10/26 09:44:38

Virtual hosts

Post by tomitzel » 2012/10/26 09:51:38


I have a server with IP and I want the domain to load website from /var/www/html/something/

I've tried to configure them as follows:

DocumentRoot /var/www/html/something/
ErrorLog logs/something-error_log
CustomLog logs/something-access_log common

I've reloaded apache, but when accesing the domain, it only shows the root of the server /var/www/html/

Any idea what is wrong?

Posts: 1
Joined: 2012/10/26 11:36:20

Re: Virtual hosts

Post by MIKNOTAURO » 2012/10/26 11:57:09

you have to make this
type on /etc/httpd/
mkdir sites-available
mkdir sites-enabled

then you have to edit


something like this

NameVirtualHost *:80
Include /etc/httpd/sites-enabled/

then you have to create some configuration files for your sites

[root@mik httpd]# cd sites-available/
[root@mik sites-available]# cat >
# (/etc/httpd/sites-available/

ServerAlias *

#Indexes + Directory Root
DocumentRoot /home/csmith/www/

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all

ErrorLog /home/csmith/www/
CustomLog /home/csmith/www/ combined

Change the DocumentRoot to wherever you want

[root@mik sites-available]# ln -s /etc/httpd/sites-available/ /etc/httpd/sites-enabled/

restart your service... and thats all...

User avatar
Forum Moderator
Posts: 28514
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Virtual hosts

Post by TrevorH » 2012/10/26 14:15:29

Most of that looks like Debianisms and will most likely not work in CentOS.

Vhost files are best created in /etc/httpd/conf.d as that needs no modification of the distro supplied httpd.conf to be picked up.

Under CentOS with selinux turned on as default, httpd will be unable to access /home/ directories without special action.

[b]tomitzel[/b] Creating your vhost under /var/www/html/subdir means that the default web site can access the other site's data by using e.g. which may not be what you desired. I find it better to create a /var/www/something site which is one level up from the default docroot and thus can't be seen from the default site yet still picks up the correct selinux contexts. The server needs to be able to lookup and resolve it to the IP address that you have given in the virtual host definition - can it do that?

Post Reply

Return to “CentOS 5 - Webhosting Support”