I'm trying to setup Apache with two websites using a single IP and name based resolution. For example, let's use: example.com and staging.example.com
I understand that I can place both <Virtual Host *:80> blocks in a single /etc/httpd/conf/httpd.conf file, but I've also seen centOS tutorials where the virtual host blocks are being placed in /etc/httpd/conf.d/example.com.conf and /etc/httpd/conf.d/staging.example.com.conf. The latter makes a little more sense to me to keep the individual settings separate.
Should either solution work? I couldn't find any confirmation for multi-site name based resolution and having my blocks in the separate files. I've actually also tried testing it, and can only get the staging.example.com site to load properly. I can't find any obvious syntax issues, so I'm wondering if the multi-conf files are the issue somehow, or if my DNS is broken.
Here's an example:
example.com.conf
Code: Select all
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/example.com
<Directory /var/www/html/example.com>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Code: Select all
<VirtualHost *:80>
ServerName staging.example.com
ServerAlias www.staging.example.com
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/staging.example.com
<Directory /var/www/html/staging.example.com>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>