Apache Virtual host issue

Tags
advanced, apache, httpd, virtual host

 
Thread Tools Search this Thread
# 1  
Old 08-27-2018
Apache Virtual host issue

Hello,

I am facing a very strange issue while setting a virtual host on apache to setup multiple websites using separate IPs.

Virtual host is setup but when i am browsing the website it display content under /var/www/html and displaying site1 and site2 folder instead of access the content under respective directory as mentioned in virtual host file.

Below is the steps and virtual host configuration i setup

Code:
sudo chown -R apache:apache /var/www/html/site1
sudo chown -R apache.apache /var/www/html/site2
chmod -R 755 /var/www

mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled

Added IncludeOptional sites-enabled/*.conf line in /etc/httpd/conf/httpd.conf file
Code:
vim /etc/httpd/sites-available/site1.conf
vim /etc/httpd/sites-available/site2.conf

ln -s /etc/httpd/sites-available/site1.conf /etc/httpd/sites-enabled/site1.conf
ln -s /etc/httpd/sites-available/site1.conf /etc/httpd/sites-enabled/site2.conf

systemctl restart httpd

Below is configuration added to created apache host

Code:
site1.conf
<VirtualHost 192.168.1.11:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/site1
     ServerName example.com
     ServerAlias Example Domain

     <Directory /var/www/html/site1/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

site2.conf
<VirtualHost 192.168.1.12:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/site2
     ServerName example.com
     ServerAlias Example Domain

     <Directory /var/www/html/site2/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

I am using CentOS7 and I already disabled selinux and firewalld
Please help me out here.

Moderator's Comments:
Mod Comment edit by bakunin: Please use CODE-tags. Thank you.

Last edited by bakunin; 08-27-2018 at 11:14 AM..
# 2  
Old 08-27-2018
Did you get it to work using your IP addresses in the URLs versus using the FQDN?
# 3  
Old 08-28-2018
Code:
   <Directory /var/www/html/site1/>
        Options +FollowSymlinks
        DirectoryIndex  index.html
        AllowOverride All
        Require all granted
     </Directory>


|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Solaris 10 virtual - how do I tell physical host? psychocandy Solaris 4 11-29-2017 09:02 AM
Problems with Apache Virtual Host Corona688 Web Programming 27 01-20-2014 03:45 PM
Apache Virtual Path Corona688 Web Programming 7 06-13-2013 04:03 PM
Apache virtual host config vs global config problem freebird8z Red Hat 1 04-05-2013 11:33 AM
Apache question - virtual host related freebird8z Red Hat 2 04-02-2013 04:09 PM
Change hostID of Solaris 10 virtual/guest machine installed by Virtual Box 4.1.12 on Windows-XP host Matt_VB Solaris 4 04-29-2012 12:56 PM
Virtual Host Apache Duffs22 Red Hat 2 07-13-2011 07:34 AM
Bash script to Automate the Virtual Host creation process!! anishkumarv Shell Programming and Scripting 5 07-12-2011 07:25 AM
Apache Virtual URL wuschelz Web Programming 3 02-04-2011 05:58 PM
Solaris virtual machine access on host os ankurk Solaris 2 03-14-2010 07:52 AM
Apache Virtual Server Help ratnamg Linux 0 02-05-2008 08:44 PM
Unix virtual host detection Meridian Solaris 3 01-20-2004 04:55 AM
Unix virtual host detection Meridian Solaris 1 01-14-2004 10:13 PM
Resolving Aliases and Virtual IP's on a Host Scott Pullen UNIX for Advanced & Expert Users 1 12-20-2001 02:11 PM
Apache virtual host 98_1LE UNIX for Dummies Questions & Answers 4 12-11-2001 06:23 PM