Create and set up an Apache virtual host

A virtual host is a web server entry point. It allows to define and configure the addresses handled by Apache.

This post describes how to create and configure an Apache virtual host.


Create the virtual host’s root directory

The root directory contains resources (pages, scripts, images, videos, files…) needed to display the website corresponding to the virtual host.

I recommend creating the root directory in /home/myuser, and using a domain name as the root directory’s name.

mkdir /home/myuser/
chown myuser:myuser /home/myuser/

Create a virtual host

I recommend using a domain name as virtual host’s name.

Line AssignUserID myuser myuser is only useful if the apache2-mpm-itk package for customizing the Apache user is installed on the server.

nano /etc/apache2/sites-available/

<VirtualHost *:80>
    DocumentRoot /home/myuser/
    Options -Indexes
    AssignUserID myuser myuser

Enable virtual host

service apache2 reload

Apache now handles the addresses and

Disable virtual host


Leave a Reply

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