Level 73
Check this guide
https://www.howtoforge.com/centos-apache-config-virtual-host
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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)?
Check this guide
https://www.howtoforge.com/centos-apache-config-virtual-host
Please or to participate in this conversation.