How-to create a virtual host in Apache (Ubuntu)

You will find on most Linux based web hosts a directory which is called “sites-available” (inside /etc/httpd/ or /etc/apache2/). Create a configuration file with the name “domain.com” for your host and add this code:

ServerName domain.com
ServerAlias www.domain.com
ServerAdmin [email protected]
DocumentRoot /home/user/domain.com/public_html/
ErrorLog /var/log/apache2/domain.com-error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg
LogLevel warn
CustomLog /var/log/apache2/domain.com-access.log combined

Create the directory for your web host and activate the host with a2ensite domain.com and reload your apache engine.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.