Blog · 05/03/2021
Webmin cannot create Apache virtual hosts
Introduction to Apache in Webmin
Webmin is a control panel that allows us to manage any Linux server through a friendly browser-based interface.
By default, Webmin installs the Apache2 Web Server which is responsible for serving the different web pages.
Before you understand the error we are dealing with in this entry it is important to understand how Apache is structured and what are its main configuration files.
You can access the Apache Web Server Module from the main Webmin menu, within the Server category and then in the Configuration File Editing section.

The main directories and configuration files are:
- /etc/apache2: is the default directory of Apache and within it are all the configuration files.
- /etc/apache2/apache2.conf: is the main apache settings file, from here you can modify the global settings.
- /etc/apache2/ports.conf: is the configuration file that is responsible for specify the ports by which you must listen to Apache, usually are the port 80 and the 443 in case of having active the SSL.
- /etc/apache2/sites-available/: directory where the virtual hots are saved for each site, here there are only links to sites-enabled.
- /etc/apache2/sites-enabled/: in this directory are all the virtual hots of the web server.
- /etc/apache2/conf-available/: Configuration files that do not belong to any virtual host are stored, in this case only the links to conf-enabled
- /etc/apache2/conf-enabled/: where all the files of all the settings that do not belong to any virtual host are found.
- /etc/apache2/mods-available/: all modules that can be used in Apache.
- /etc/apache2/mods-enabled/: only the modules activated in Apache are found.
- *.load: They are specific files to be able to load some modules.
- *.conf: These are specific files of the configuration of some modules.

Each time a Virtual Server is created in Webmin you need to add a link file within the /etc/apache2/sites-available directory.
You also need to add the Virtual Server configuration file to the /etc/apache2/sites-enabled directory.
Analysis of error
In this post we deal with the error that prevents Webmin from creating a VirtualHost within Apache corresponding to the Virtual Server that is being created.
The following is indicated in the image where the error originates when creating a new Server, in the Webalizer sections and in the creation of the virtual SSL site.

After these errors, it can be observed that a PHP execution mode has not been properly assigned.

And it is also impossible to edit the web guidelines, as virtually no VirtualHost has been created.

In search of the problem
To locate the error we try to create a new VirtualHost from the Webmin Apache Module itself to observe the result that is obtained.

The result obtained can be:
- The indicated domain is not valid
- The VirtualHost has been created correctly, but indicating that the /etc/apache2/sites-enabled/ directory is not currently used by Apache.

Possible solution to error
After analyzing all the tests and results, it can be determined that for some reason the Apache module has been disconfigured.
You need to go to the Apache Module and click on the boiling symbol located at the top of the screen to go to the settings.

In the configuration file we detect that the directory route where the virtual servers are added is incorrect.

You are pointing to the sites-available directory when you actually have to be pointing to sites-enabled.

The configuration is saved and the Apache server is restarted to apply the changes.
sudo service apache2 restart
After these steps, the creation of virtual and virtualhost servers in Apache using Webmin is already working properly.
To see more details of the error you can visit the Related Ticket created on Webmin: Webmin / Bugs / #5455 Impossible to create a VirtualHost in Apache2 (sourceforge.net)
Have you had a similar mistake? tell us how you fixed it.