Pages: [1]   Go Down
Print
Author Topic: Virtual Host on Apache Server  (Read 456 times)
isAdmin
The Administrator
Administrator
Newbie
*****
Offline Offline

Posts: 20


...Networking, Programming, Designing & Creating!


View Profile WWW
« on: January 21, 2009, 11:57:00 AM »

FYI: Recently we had an issue configuring virtual hosting on Apache, we found lots of useless information and very little relevant but vague information on the subject. Here's the facts!

Issue: URL not accessible from within the network, local ip directs to wrong folder and localhost directs to the right folder.

Solution: Check your vhosts configuration, in Suse 10.x httpd.conf includes your configuration files to keep things easy to maintain, you'll find listen.conf in /etc/apache2 and your vhosts.conf files in /etc/apache2/vhosts.d; Make sure you have the following configured correctly for named virtual hosting in your listen.conf file:

Listen 80
and at the bottom of the file
NameVirtualHost *
both these lines should be uncommented!

Your vhost.conf file should look something like this working example:

# DERFAULT.COM
<VirtualHost *>
    ServerName default.com
    DocumentRoot /srv/www/htdocs
    ServerAdmin you@yourdomain.com
    HostnameLookups Off
    UseCanonicalName Off
    ServerSignature On
    ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
    <IfModule mod_userdir.c>
   UserDir public_html
   Include /etc/apache2/mod_userdir.conf
    </IfModule>
<Directory "/srv/www/htdocs">
   Options Indexes FollowSymLinks
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>
# OTHER.COM
<VirtualHost *>
    ServerName other.com
    DocumentRoot /srv/www/vhosts/other.com
    ServerAdmin you@yourdomain.com
    HostnameLookups Off
    UseCanonicalName Off
    ServerSignature On
    ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
<Directory "/srv/www/vhosts/other.com">
   Options Indexes FollowSymLinks
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

You can also create a seperate .conf file for each VirtualHost, all .conf files will be included from your vhosts.d directory. Keeping VirtualHost files seperated makes it easier to administer changes on a single domain.

Make sure you correctly set up your DNS or DynDNS to point to your external IP Address and if you are using a router, set up port forwarding to your local machine and check that "Filter Internet NAT Redirection" is NOT ticked under your router security settings.

Restart Apache services and everything should work!
« Last Edit: January 21, 2009, 12:03:48 PM by isAdmin » Logged

The Administrator


url: http://iservicesinc.net
admin[at]iservicesinc[dot]net
Pages: [1]   Go Up
Print
Jump to: