The configurations of virtual hosts in Ubuntu are somewhat different from those in windows.
To create a VM, follow these steps:
1. In the/etc/apache2/sites-available/directory, create a file for you to configure the host, open it, and configure it:
sudo vi /etc/apache2/sites-available/webQQ
# This is a webqq VM <virtualhost *: 80>
# The root directory of the VM, DocumentRoot/var/www/webqq
# Host name servername www.webqq.com
# Configure the root directory <directory/varwww/webqq>
# Directoryindex index.html options indexes followsymlinks </directory> </virtualhost>
2 ., because the Apache configuration file apache2.conf only uses the include command to include files in the/etc/apache2/Site-Enable/directory, the file does not contain files in the/etc/apache2/sites-available/directory, therefore, we soft-link the/etc/apache2/sites-available/webqq to the/etc/apache2/sites-Enable/directory, so that our VM is successfully configured, when we do not want this virtual host, we can delete the soft link under/etc/apache2/Site-Enable.
sudo ln -s /etc/apache2/sites-available/webQQ /etc/apache2/sites-enable
3. We also need to add the ing between the host name and IP address in the/etc/hosts file.
127.0.0.1 www.webQQ.com
4. In the last step, restart Apache.
sudo /etc/init.d/apache2 restart
In this way, our VM is successfully configured.
Configuration of Apache Virtual Host in Ubuntu