Setting VirtualHost

Posted on

Setting VirtualHost – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, virtualhost, , , .

I am using Centos6.3 and I have configure apache using the Slicehost tutorial.

My configuration is the following:

<VirtualHost *:80>
    ServerName christabellehotel.com
    ServerAlias www.christabellehotel.com
    DirectoryIndex index.php
    DocumentRoot /home/sites/christabellehotel.com
    LogLevel warn
    ErrorLog /home/sites/christabellehotel.com/error.log
    CustomLog /home/sites/christabellehotel.com/access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerName akteabeach.com
    ServerAlias www.akteabeach.com
    DirectoryIndex index.php
    DocumentRoot /home/sites/akteabeach.com
    LogLevel warn
    ErrorLog /home/sites/akteabeach.com/error.log
    CustomLog /home/sites/akteabeach.com/access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerName 198.199.125.69
    DirectoryIndex index.php
    DocumentRoot /home/sites/
    LogLevel warn
    ErrorLog /home/sites/error.log
    CustomLog /home/sites/access.log combined
</VirtualHost>

The problem is that when I open http://christabellehotel.com/ I cannot see tha virtual host which I configure and which is the following: http://198.199.125.69/christabellehotel.com

Helpful information:

# /usr/sbin/httpd -S

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          198.199.125.69 (/etc/httpd/conf.d/ssl.conf:74)
*:80                   is a NameVirtualHost
     default server christabellehotel.com (/etc/httpd/conf/httpd.conf:1023)
     port 80 namevhost christabellehotel.com (/etc/httpd/conf/httpd.conf:1023)
             alias www.christabellehotel.com
     port 80 namevhost akteabeach.com (/etc/httpd/conf/httpd.conf:1034)
             alias www.akteabeach.com
     port 80 namevhost 198.199.125.69 (/etc/httpd/conf/httpd.conf:1044)

Syntax OK

Solution :

take the third virtualhost entry, move it to the top, and change the directive to

<VirtualHost 198.199.125.69:80>

change NameVirtualHost *:80 to NameVirtualHost *

Leave a Reply

Your email address will not be published. Required fields are marked *