Notifications
Clear all

[Solved] Apache virtual hosts doesn't work on Virtualmin on Ubuntu 16.04

1 Posts
1 Users
0 Likes
51 Views
Tharindu
(@tharindu)
Reputable Member Admin
Joined: 10 years ago
Posts: 307
Topic starter  

Virtual servers created with Virtualmin does not point to it's document root /home/username/public_html. Instead they are pointing to /var/www/html which is the document root for Apache default server. When I open domain on the browser, it fetches files from /var/www/html although Apache virtual host is configured to use /home/username/public_html as document root.

I came across this error today when trying to configure a DigitalOcean droplet for a client with Virtualmin and Apache. Client was originally having this error but I thought it was because client tried to install Virtualmin on top of configures LAMP server. So I requested a fresh server and installed Virtualmin with the script. But it didn't change anything. I got the same error with a fresh installation. Apache virtual hosts didn't work.

Funny thing is that I was able to access the site properly with Virtualmin's Preview Website feature. But when I open domain name directly, it shows content from default document root.

However, I was able to solve it by making a simple change to Apache virtual host file. Posting it here hoping to help others who might run in to same problem.

Open Apache Virtual host file for the domain,


nano /etc/apache2/sites-available/example.com.conf

The very first line of the file will read,


<VirtualHost *:80>

Replace * with server's IP address. Line should look like this after the change.


<VirtualHost ipaddress:80>

Save the file and restart Apache. Domain should point to correct directory now. You'll have to do this for every virtual server you create. This might be a bug in Virtualmin. But i'm not sure yet. I'll need to do more tests before coming to that conclusion.


   
Quote
Share:
Back to top button