1

I have a CentOS 7 server running Apache 2, and am trying to host 2 sites. My two domain names are pointed to the server at IP 70.61.231.8.

verizondecom.com
windstreamdecom.com

On the server, I have a virtual host set up for each site.

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName windstreamdecom.com
  ServerAlias www.windstreamdecom.com
  ErrorLog /var/log/httpd/windstreamdecom.err
  CustomLog /var/log/httpd/windstreamdecom.log combined
  DocumentRoot /var/www/windstreamdecom/public
  SetEnv ENVIRONMENT "production"
  <Directory "/var/www/windstreamdecom/public">
    AllowOverride ALL
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
</VirtualHost>


<VirtualHost *:80>
  ServerName verizondecom.com
  ServerAlias www.verizondecom.com
  ErrorLog /var/log/httpd/verizondecom.err
  CustomLog /var/log/httpd/verizondecom.log combined
  DocumentRoot /var/www/www.verizondecom.com/public
  SetEnv ENVIRONMENT "production"
  <Directory "/var/www/www.verizondecom.com/public">
    AllowOverride ALL
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
</VirtualHost>

When I type in either domain name, I get the first Vhost (Windstream). The URL in the browser also changes to the server's IP address.

What am I missing here? I need to be able to go to both websites, and the URL should be the hostname, not the IP.

scott80109
  • 153
  • 4
  • 11
  • What does `httpd -S` show? (Particularly for the virtualhosts) – Cameron Kerr Nov 12 '17 at 05:03
  • *:443 70.61.231.8 (/etc/httpd/conf.d/ssl.conf:56) *:80 70.61.231.8 (/etc/httpd/sites-enabled/www.verizondecom.com.conf:4) ServerRoot: "/etc/httpd" Main DocumentRoot: "/etc/httpd/htdocs" Main ErrorLog: "/etc/httpd/logs/error_log" Mutex authn-socache: using_defaults Mutex ssl-cache: using_defaults Mutex default: dir="/run/httpd/" mechanism=default PidFile: "/run/httpd/httpd.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="apache" id=48 Group: name="apache" id=48 – scott80109 Nov 12 '17 at 05:57
  • worth double checking- did you reboot the apache after adding the second vhost entry? – Anson W Han Nov 13 '17 at 04:53
  • Yet. I have tweaked the vhost files and restarted Apache multiple time – scott80109 Nov 13 '17 at 18:39

1 Answers1

0

Do you have the following in your apache config?

NameVirtualHost *:80

The *:80 part needs to match what you use in the <VirtualHost *:80> part.

Also is the default config removed? `

Mike
  • 22,310
  • 7
  • 56
  • 79