Apache Virtual host issue


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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 10:14 AM..
# 2  
Did you get it to work using your IP addresses in the URLs versus using the FQDN?
# 3  
Code:
   <Directory /var/www/html/site1/>
        Options +FollowSymlinks
        DirectoryIndex  index.html
        AllowOverride All
        Require all granted
     </Directory>

Login or Register to Reply

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

More UNIX and Linux Forum Topics You Might Find Helpful
Problems with Apache Virtual Host
Corona688
I am attempting to add virtual hosts to an apache web server, which has this current configuration: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None ...... Web Development
27
Web Development
Apache virtual host config vs global config problem
freebird8z
Hi folks, I am trying to configure Apache webserver and also a virtual host inside this webserver. For Global server config: /var/www/html/index.html For virtual host config: /var/www/virtual/index.html Both client10 & www10 are pointing to 192.168.122.10 IP address. BUT, MY...... Red Hat
1
Red Hat
Apache question - virtual host related
freebird8z
Hi folks, I recently read about Apache virtual host and was able to configure that as well. I used name based virtual host (lets say http://vhost1.example.com) and it worked just fine. Then I configured another named based virtual host on same apache server (lets say http://vhost2.example.com)...... Red Hat
2
Red Hat
Virtual Host Apache
Duffs22
Hi, I have set up the following virtual host but it cannot find the URL? Apache is running fine and I have disabled iptables. Within the document root I have the following file index.html displaying a sample text message. Any ideas what my problem might be? httpd.conf: ...... Red Hat
2
Red Hat
Apache virtual host
98_1LE
Would this be the correct entry for Apache to answer on the IP 129.250.242.126 if the servers IP is 129.250.242.125? Are any other changes necessary to get Apache to answer this IP for web traffic? < VirtualHost 129.250.242.126> ServerName www.my_domain.com ServerAdmin admin@my_domain.com...... UNIX for Dummies Questions & Answers
4
UNIX for Dummies Questions & Answers