How to configure an Apache virtual host on Debian

We continue playing with Debian on our test server, today we were presented with the need to configure a Virtual Host, so with the help of a university guide I built a step by step to configure Apache virtual hosts in Debian.

Install apache

sudo apt-get update
sudo apt-get install apache2

Create new Virtual host file

Download our test virtual.conf file from here. Then we must copy the file virtual.conf to the folder /etc/apache2/sites-available/ for the new domain.

cp virtual.conf /etc/apache2/sites-available/

If required, we can change the file name. (For testing we will use the name: virtual )

Next we must change the following fields ServerName, ServerAdmin, DocumentRoot

Enable the new Virtual hosts files:

a2ensite virtual.conf

Restart Apache:

service apache2 restart

Configurar el archivo de hosts local

Open the file hosts for it type nano /etc/hosts

Add the new IP of your server at the bottom of the file as localhost.

It will be something like this: localhost wp yii # The following lines are desirable for IPv6 capable hosts :: 1 localhost ip6-localhost ip6-loopback ff02 :: 1 ip6-allnodes ff02 :: 2 ip6-allrouters

With this, a Virtual Host in Debian would be well configured

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

5 comments, leave yours

Leave a Comment

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



  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   3 said

    Hi, good morning

    Please I ask you for a tutorial where you explain how from the Internet (anywhere in the world) you can access the pages of the virtual host without using third party services?

  2.   Fulanito said

    The virtual.conf link does not work.

  3.   Johan Esteban said

    The tutorial is incomplete 0/10

  4.   fjmadrid said

    the virtual.conf file can no longer be downloaded. Please update the link.
    Thank you.

  5.   Ekaitz said

    Cannot access paste from virtual.conf. Yes, advertising, a blanket ...