Problems with Apache Virtual Host


 
Thread Tools Search this Thread
Top Forums Web Development Problems with Apache Virtual Host
# 1  
Old 01-15-2014
Problems with Apache Virtual Host

I am attempting to add virtual hosts to an apache web server, which has this current configuration:

Code:
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I have been trying to add a configuration like this, based off another working server:

Code:
<VirtualHost *:80>
        ServerName subname.servername.com
        DocumentRoot /path/to/new/documentroot
</VirtualHost>

...but it totally ignores the new configuration, going straight to /var/www in defiance of the new virtualhost whenever subname.servername.com is accessed. So I get the 'it works!' page, instead of someone's particular wordpress instance.

I can tell it's at least reading the configuration though, since adding the virtualhost somehow breaks apache's ability to follow symbolic links.

What might I be doing wrong?
# 2  
Old 01-15-2014
Hi.

Which OS / version of Apache are you using?

Did you enable the NameVirtualHost directive? Is there a hosts/DNS entry for the new virtual host?
# 3  
Old 01-15-2014
I tried lots and lots of things, including NameVirtualHost in various combinations.

The system is Ubuntu. I am trying to find the apache version.

If I add "NameVirtualHost *:80" to the top, apache2 will complain "NameVirtualHost *:80 has no VirtualHosts" in defiance of the default virtual host and however many virtual hosts I add.

As for hosts/DNS entry, whatevername.mywebsite.com already works, the site can tell what name you call it with. Except that virtual hosting does not work.
# 4  
Old 01-20-2014
its simple:

1. nano /etc/apache2/sites-available/mynewdomain.com
2. enter following

Quote:
<VirtualHost *:80>
ServerName mynewdomain.com
DocumentRoot /home/www/mynewdomain.com
</VirtualHost>
3.Save the file
4.Add the new site with the following command
Quote:
a2ensite mynewdomain.com
5.Restart apache

you can read more here: newexception.com/apache-virtual-host
# 5  
Old 01-20-2014
Does not work.

Does the exact same thing as described above, the exact same way as described above: Sites continue going to /var/www despite the virtualhost telling them to go somewhere else.

I even have the 'NameVirtualHost *:80 has no VirtualHosts' error despite having obvious virtualhosts, just like described above.

Any further thoughts?
# 6  
Old 01-20-2014
is this linux box your home pc? or a vps/dedicated server?

did u tried to add the domain in /etc/hosts?
read the article
# 7  
Old 01-20-2014
Adding 127.0.0.1 to /etc/hosts would be counterproductive since I want to access this site from the server's main address -- the server really does have a working domain name, and I am accessing it from the outside. I will attempt adding the real IP to /etc/hosts...

It is a home server, and not any sort of VPS.

[edit] Adding the IP to /etc/hosts made no difference.

[edit] Just for laughs, I tried 127.0.0.1 in /etc/hosts too. It didn't make any difference.

I am trying to get access to the domain name to verify it has the right settings.

Last edited by Corona688; 01-20-2014 at 12:00 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

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... (2 Replies)
Discussion started by: sunnysthakur
2 Replies

2. Solaris

Solaris 10 virtual - how do I tell physical host?

uname -a reports type Generic so I know its virtual. Assume its an ldom somewhere. How do I find out what physical host server is? (4 Replies)
Discussion started by: psychocandy
4 Replies

3. Red Hat

Apache virtual host config vs global config problem

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... (1 Reply)
Discussion started by: freebird8z
1 Replies

4. Red Hat

Apache question - virtual host related

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)... (2 Replies)
Discussion started by: freebird8z
2 Replies

5. Solaris

Change hostID of Solaris 10 virtual/guest machine installed by Virtual Box 4.1.12 on Windows-XP host

Trying to set or modify the randomly set hostID of a Solaris 10 virtual/guest machine that I installed on a Windows-XP host machine (using Virtual Box 4.1.12). I was able to set/modify the hostname of the Solaris 10 virtual/guest machine during installation as well as via the Virtual Box... (4 Replies)
Discussion started by: Matt_VB
4 Replies

6. Red Hat

Virtual Host Apache

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: ... (2 Replies)
Discussion started by: Duffs22
2 Replies

7. Solaris

Unix virtual host detection

Is it possible to reliably detect the virtual host of a Sun Solaris box, within a shell or Perl script? Can a system have multiple virtual host or not host at all ? I was recently made aware of hostname command, but was not sure if this option was the only one available. Any help is much... (3 Replies)
Discussion started by: Meridian
3 Replies

8. Solaris

Unix virtual host detection

I have a need to write scripts that can reliably determine the virtual host of a Sun Solaris system. (1 Reply)
Discussion started by: Meridian
1 Replies

9. UNIX for Advanced & Expert Users

Resolving Aliases and Virtual IP's on a Host

I am currently going through the servers in our network and trying to compile a list of the current aliases for each box and any virtual IP addresses. I can check for the ones that are supposed to be there but how do I list the ones that I don't even know exist? ANY help would be greatly... (1 Reply)
Discussion started by: Scott Pullen
1 Replies

10. UNIX for Dummies Questions & Answers

Apache virtual host

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... (4 Replies)
Discussion started by: 98_1LE
4 Replies
Login or Register to Ask a Question