I have apache 2.4 installed in Centos 7

the normal virtual host working fine with all server IPs

<VirtualHost *:80>

but when I assign a specific ip address for my virtual host and I change the ip in hosts file


the website display the apache welcome page

and i didn't change the Listen line in the httpd.conf

Listen 80

The default connection is probably still configured to listening on *:80 and is probably hitting that.

You configure your Virtual Host to listen for names

If your website has the domain name www.website.com you can listen on the same IP address for many VirtualHosts using the ServerName or ServerAlias directive

For example


    ServerName www.website.com

    DocumentRoot /var/www/website.com/


    ServerName www.anotherwebsite.com

    DocumentRoot /var/www/anotherwebsite.com/
  • I removed the default virtual host, I think that the previous code for hosting multiple website using one ip address, But I want to assign ip address for only virtual host
    – Mostafa
    Jan 16 '17 at 23:52
  • Okay you can still do so and use ServerName directive. You could also use the grep command to see if IP is being used in any other conf files or to search for the conf files that contain path to the default apache home page, for instance grep -R '' /etc/apache assuming you conf files are stored under /etc/apache Jan 17 '17 at 0:00
  • Also before restarting Apache worth doing a config test if you're not already, typically apache2ctl configtest or apachectl configtest Jan 17 '17 at 0:04
  • You can also define ServerAlias anotherwebstite.com To make the server listen on that too
    – Orphans
    Jan 17 '17 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.