0

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

<VirtualHost 11.22.33.44:80>

the website display the apache welcome page

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

Listen 80
Mostafa
  • 131
  • 1
  • 8

1 Answers1

2

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

<VirtualHost 11.22.33.44:80>

    ServerName www.website.com

    DocumentRoot /var/www/website.com/
</virtualHost>

<VirtualHost 11.22.33.44:80>

    ServerName www.anotherwebsite.com

    DocumentRoot /var/www/anotherwebsite.com/
</virtualHost>
mrjamesmyers
  • 296
  • 1
  • 8
  • 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 '11.22.33.44' /etc/apache` assuming you conf files are stored under /etc/apache – mrjamesmyers Jan 17 '17 at 00:00
  • Also before restarting Apache worth doing a config test if you're not already, typically `apache2ctl configtest` or `apachectl configtest` – mrjamesmyers Jan 17 '17 at 00:04
  • You can also define ServerAlias anotherwebstite.com To make the server listen on that too – Orphans Jan 17 '17 at 06:38