Apache/2.2.25 VirtualHost not working


 
Thread Tools Search this Thread
Operating Systems Linux Apache/2.2.25 VirtualHost not working
# 1  
Old 09-15-2013
Hammer & Screwdriver [SOLVED] Apache/2.2.25 VirtualHost not working

I am having problems in implementing the virtual hosts here in my server. I have this one cloud dev server: Amazon Linux AMI release 2013.03 (based on RHEL like CentOS) with Apache 2.2.25 installed and I'm trying to create 2 virtual hosts: test-kalc.tk and test2-kalc.tk.

If I go to test-kalc.tk, the expected output should be "Hello from test-kalc.tk!" and I have no problems seeing that. The output for test2-kalc.tk should be "Hello from test2-kalc.tk!" but I don't know why every time I go to test2, I still see the same page from my first host.

I googled about this and checked other forums out there but I still couldn't find the answer to this.

Here's my /etc/httpd/conf/httpd.conf:
Code:
NameVirtualHost *:80

<VirtualHost *:80>
     DocumentRoot /var/www/test-kalc.tk
     ServerName test-kalc.tk
     ServerAlias test-kalc.tk *.test-kalc.tk
</VirtualHost>
<VirtualHost *:80>
     DocumentRoot /var/www/test2-kalc.tk
    ServerName test2-kalc.tk
    ServerAlias test2-kalc.tk *.test2-kalc.tk
</VirtualHost>

I've already tried changing *:80 to * and also tried using the IP address (private/public) but that didn't help me either.

The hosts were also included in /etc/hosts.
Code:
127.0.0.1   localhost localhost.localdomain test-kalc.tk test2-kalc.tk

Here are the other info that you might need:
Code:
[root@web-server-dev html]# httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server test-kalc.tk (/etc/httpd/conf/httpd.conf:1013)
         port 80 namevhost test-kalc.tk (/etc/httpd/conf/httpd.conf:1013)
                 alias test-kalc.tk
                 wild alias *.test-kalc.tk
         port 80 namevhost test2-kalc.tk (/etc/httpd/conf/httpd.conf:1018)
                 alias test2-kalc.tk
                 wild alias *.test2-kalc.tk
Syntax OK

Code:
[root@web-server-dev html]# service iptables status
iptables: Firewall is not running.

Code:
[root@web-server-dev html]# netstat -apn | grep 80
tcp        0      0 :::80                       :::*                        LISTEN      20007/httpd

Let me know if you need anything else.

Thanks in advance! Smilie

Last edited by jpdoria; 09-15-2013 at 10:05 AM..
# 2  
Old 09-15-2013
First perhaps a silly question: does the index.html in /var/www/test-kalc.tk differ from the one in /var/www/test3-kalc.tk ?
# 3  
Old 09-15-2013
Hi Scrutinizer, thanks for the time but I was able to find a fix to this finally. What I did was I changed NameVirtualHost *:80 to NameVirtualHost test-kalc.tk and added a new NameVirtualHost for test2-kalc.tk.

Here's how they look like:
Code:
NameVirtualHost test-kalc.tk
NameVirtualHost test2-kalc.tk

I also changed <VirtualHost *:80> to <VirtualHost test-kalc.tk>. I did the same thing to other host.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Apache not working

I have installed apache2 on ubuntu 16.00 and checked the logs and no errors apt list --installed | grep apache2 WARNING: apt does not have a stable CLI interface. Use with caution in scripts. apache2/xenial-updates,xenial-security,now 2.4.18-2ubuntu3.5 amd64 ... (0 Replies)
Discussion started by: DOkuwa
0 Replies

2. Shell Programming and Scripting

SVN for actual VirtualHost

hi, Earlier I had this thread posted on "UNIX for Experts" Group here in unix.com, but somehow no one bothered to respond, so I thought someone might be able to help me here. In short, I have to make accessible a directory via SVN to all 5 developers, call it /var/www/html/beta3 ... (0 Replies)
Discussion started by: busyboy
0 Replies

3. Red Hat

Apache chown on its files not working

Hello, My apache user generate one file : # ls -lsa /tmp/reference_file.csv 76 -rwxrwxrwx 1 apache apache 69921 Aug 16 14:14 tmp/reference_file.csv the user and the group belong to apache, but when i am trying to change it : su -l apache -s /bin/bash -bash-3.00$ whoami apache... (7 Replies)
Discussion started by: cterra
7 Replies

4. UNIX for Dummies Questions & Answers

Subdomain is not working, debian, apache

Hi, I use debian jessie, apache. I am not allowed to post links here at this forum, I am new user. I made subdomain porodin.predicsasa.com and it is working, vhost file is porodin.conf in /etc/apache2/sites-available then I copied vhost file and made it hosting.conf, did a2ensite hosting and it... (5 Replies)
Discussion started by: alanford
5 Replies

5. Red Hat

apache httpd virtual hosts setup keep hitting the same VirtualHost

I'm trying to set up two virtual hosts. Here's my httpd config: <Directory /Users/userX/dev/sandbox-2> Order deny,allow deny from All Allow from localhost </Directory> NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "/Users/userX/dev/sandbox-2" ... (0 Replies)
Discussion started by: GlideK
0 Replies

6. Shell Programming and Scripting

virtualhost script

can anyone help me to write a script to delete the virtualhost entry in apache vhosts.conf file: hint: when i enter ./deletedomain test.com it should delete the test.com virtualhost entry from vhosts.conf file (2 Replies)
Discussion started by: pssooraj72
2 Replies

7. Web Development

Apache virtualhost dinternal domain

Hello, I have have installed two web applications on one server with one IP address and one domain name (mynet.intra). Is it possible to configure in apache 2.2 that access to one application would be from "app1.mynet.intra" and to another application from address "app2.mynet.intra"? Document... (1 Reply)
Discussion started by: kreno
1 Replies

8. Web Development

Apache to Tomcat forwarding not working properly

Hi, I am facing some problem with Apache to Tomcat forwarding. I have Tomcat (6.0.18) behind Apache (2.2). I want to use ‘https' for receiving request from the client. This request, when forwarded by Apache to Tomcat, will use ‘http'. My application's name is ‘abc', which is deployed in... (1 Reply)
Discussion started by: Technext
1 Replies

9. Web Development

Apache: Forward Proxy Via Virtualhost

I've set up a forward proxy within a VirtualHost (see below) on Apache 2.2.11. I then browse using mydomain.com:80 as the proxy - I've also tried using the IP address of the VirtualHost xxx.xxx.xxx.xxx:80. It works fine, the only problem is that in both cases the server's main IP address is always... (2 Replies)
Discussion started by: krunksta
2 Replies

10. UNIX for Dummies Questions & Answers

Apache httpd.conf <VirtualHost> issue

I have just configured httpd.conf on a new Redhat 9 install. Below are my additions to httpd.conf. Everything works fine except that when typing http://spetnik.d2g.com into my web browser, I am sent to the "Default catch all" site. Any clues? NameVirtualHost *:80 #Default catch all ... (5 Replies)
Discussion started by: Spetnik
5 Replies
Login or Register to Ask a Question

Featured Tech Videos