Configure logs in Apache for virtualhost

First of all, let’s distinguish between error logs and access logs.

In this guide you can see how:

But, I noticed that there was not info in the apache /var/log/apache2.access log

The trick is to add one line to the virtualhost that you would like to control:

CustomLog /var/log/apache/ combined


How to change the domain name of a virtual host in Apache

This instructions will be useful for you if you have a webserver with Ubuntu 12.04 (I have not tested this solution with other versions) running Apache 2.2.

Starting point:

You have a domain configured as a virtualhost. For example:

Ending point:

You want to change it to

These are the steps you have to follow:

1. Modify /etc/hosts

The line
should be changed to

2. Rename the file /etc/apache2/sites-available/ to

mv /etc/apache2/sites-available/ /etc/apache2/sites-available/

3. Rename the folder where you have the public content, that is the DocumentRoot Apache configuration.
E.g. in my case, this is /var/www/
mv /var/www/ /var/www/

4. Disable the former site and enable the new one:


On one hand, this will remove the symlink in /etc/apache2/sites-enabled that refers to /etc/apache2/sites-available.
And on the other this will create a new symlink for the new site.
Further details about a2ensite and a2disite here:

5. When you are done, restart Apache

service apache2 restart