user1952811
user1952811

Reputation: 2468

Apache Showing Default page VHOST Page

I've added some sites through virtual host like this, I have also specified their document route. I added all the content there, but for some reason when I visit the site through the browser the Apache default page is showing up.

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/var/www/html/mydomain/public_html"
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    ErrorLog "/var/log/httpd/mydomain/error_log"
    CustomLog "/var/log/httpd/mydomain/access_log" common
</VirtualHost>

If anyone has any clue what's wrong, please let me know!

Upvotes: 2

Views: 2560

Answers (2)

Mart&#237;n Straus
Mart&#237;n Straus

Reputation: 568

Assuming you have your virtual host's configuration file at /etc/apache2/sites-available, you must create a symlink to it at /etc/apache2/sites-enabled, like this:

ln -s /etc/apache2/sites-avaliable/mydomain.com /etc/apache2/sites-enabled/mydomain.com.conf

Notice that the extension of the symlink at sites-enabled is .conf. In my case, that was required as it's explained in the main configuration file /etc/apache2/apache2.conf:

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#   /etc/apache2/
#   |-- apache2.conf
#   |   `--  ports.conf
#   |-- mods-enabled
#   |   |-- *.load
#   |   `-- *.conf
#   |-- conf-enabled
#   |   `-- *.conf
#   `-- sites-enabled
#       `-- *.conf

The last two lines explain that only files at sites-enabled with .conf extension are loaded.

Upvotes: 0

Diego
Diego

Reputation: 100

Your ServerName is mydomain.com, but I assume you're trying to connect to it typing "localhost" on your browser. This way apache will use the default vhost instead of yours, which is probably defined on /etc/apache/sites-enabled/default.

What you can do is set mydomain.com to point to localhost. On Linux edit the /etc/hosts file adding the following line:

127.0.0.1   mydomain.com

Upvotes: 2

Related Questions