I am testing a configuration on my local system to learn Apache configuration and use the same method to handle my production server.
I need to configure two domains example.com
and example.org
I have the directories where the php scripts are there:
/server/example.com for example.com
and
/server/example.org for example.org
I ran this command on both the directories:
sudo chcon -R -h -t httpd_sys_content_t /server/example.*
index.php in example.com contains
<?
$debug = ($_SERVER['HTTP_HOST'] == 'example.com');
if ($debug) echo "in example.com";
?>
and
index.php in example.org contains
<?
$debug = ($_SERVER['HTTP_HOST'] == 'example.org');
if ($debug) echo "in example.org";
?>
also I created a apache conf file named example.conf
under /etc/httpd/conf.d/example.conf
Here are the contents of the .conf file:
<VirtualHost example.com:81>
DocumentRoot /server/example.com
ServerName example.com
<Directory "/server/example.com">
AllowOverride None
Options All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm
</Directory>
</VirtualHost>
<VirtualHost example.org:82>
DocumentRoot /server/example.org
ServerName example.org
<Directory "/server/example.org">
AllowOverride None
Options All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm
</Directory>
</VirtualHost>
When I access example.com
the site works as expeted. The script file in /server/example.com
get evaluated to true and displays in example.com
Now, when I access example.org
. the site shows nothing.
Also, here is my /etc/host
that I modified:
127.0.0.1 example.com
127.0.0.1 example.org
Can anybody suggest what I am missing here?