Kategoriat
Uncategorized

How to setup default domain on apache?

How to setup default domain on apache?

I set up first domain:

sudo nano /etc/apache2/sites-available/domain.com.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName domain.com
    ServerAlias www.domain.com
    DocumentRoot /var/www/domain.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite domain.com.conf

Then I did exactly the same for domain2.com

sudo nano /etc/apache2/sites-available/domain2.com.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName domain2.com
    ServerAlias www.domain2.com
    DocumentRoot /var/www/domain2.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite domain2.com.conf

If I now visit domain.com it shows content of domain.com, when I visit domain2.com it shows content of domain2. That’s perfect.

But when I visit server’s IP address it gives me content of domain.com. How can I change that? Specify what is the default content if (domain is not provided) OR (domain is not specified on server)?

Tray2

Level 50

Posted 11 months ago #

BEST ANSWER

siangboon

Level 50

Posted 11 months ago #

instead of using *:80 , i think you may use a IP Address binding for a default virtual host or default vhosts for all ports…

 

Source: How to setup default domain on apache?