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

home Forums Server Administration [Solved] Apache virtual hosts doesn't work on Virtualmin on Ubuntu 16.04

Tagged: , ,

This topic contains 0 replies, has 1 voice, and was last updated by  Tharindu Kumara 9 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #6009

    Tharindu Kumara
    Keymaster

    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.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.