Home » Linux OS and Software » How-To » Direct IP addresses to separate directories
Wed, 01 September 2010 09:26 Go to next message
Drao  is currently offline Drao
Registered: May 2010
Messages: 4
Hi VPSvillains,

I have a city server with SugarCRM installed and being customized in var/www and both my ip address redirect to that directory.

I have a ruby developer that I'm hiring for a separate application and was wondering how to redirect one if the ip addresses to a different directory so I can keep things clean. Suggestions?

"Don't cross the streams"
Wed, 01 September 2010 20:44 Go to previous messageGo to next message
Registered: April 2009
Messages: 14
If you're using apache for the webserver you're interested in what they call a VirtualHost.

I'm using this feature to redirect two webpages that point to the same IP address using two different domain names to two separate directories in /var/www. Now I didn't completely set this up myself because gentoo comes with a nice template for virual hosting but I'm rather confident it can do exactly what you're asking for.

Searching around for some VirtualHost how-tos will likely result in exactly what your looking for. If not I can quickly paste my vhost.conf files and take a guess at what an IP mapping might look like.

Thu, 02 September 2010 15:41 Go to previous messageGo to next message
Drao  is currently offline Drao
Registered: May 2010
Messages: 4
Would you mind posting you vhosts.conf and it's location? Apache has a list of vhost examples http://httpd.apache.org/docs/2.0/vhosts/examples.html but I've so far had no luck and their is no vhosts.conf currently.
Thu, 02 September 2010 21:41 Go to previous message
Registered: April 2009
Messages: 14
vhost.conf isn't a real file i was just using it to give a name to a file you might want to create and include from your systems apache2 conf file.

In Gentoo this actually ends up looking like the below.
I've modified the above as little as possible. I basically used mydomain as the name of my domain.

Near end of /etc/apache2/httpd.conf
# Virtual-host support
# Gentoo has made using virtual-hosts easy. In /etc/apache2/vhosts.d/ we
# include a default vhost (enabled by adding -D DEFAULT_VHOST to
# APACHE2_OPTS in /etc/conf.d/apache2).
Include /etc/apache2/vhosts.d/*.conf

<VirtualHost *:80>
  ServerName mydomain.com
    ServerAlias *.mydomain.com
  Include /etc/apache2/vhosts.d/mydomain_vhost.include

  <IfModule mpm_peruser_module>
    ServerEnvironment apache apache

ServerAdmin webmaster@mail.mydomain.com

DocumentRoot "/var/www/mydomain.com/htdocs"

# This should be changed to whatever you set DocumentRoot to.
<Directory "/var/www/mydomain.com/htdocs">
  Options Indexes FollowSymLinks

  # AllowOverride controls what directives may be placed in .htaccess files.
  AllowOverride All

  # Controls who can get stuff from this server.
  Order allow,deny
  Allow from all

<IfModule alias_module>
  Alias /cgi-bin/ "/var/www/mydomain.com/cgi-bin/"

# "/var/www/mydomain/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
<Directory "/var/www/mydomain.com/cgi-bin">
  Options ExecCGI

  AllowOverride None

  Order allow,deny
  Allow from all

  AddHandler cgi-script .cgi
  AddHandler cgi-script .perl

Which, if the includes where collapsed, could all be placed into one vhost.conf file.

The below also appears in the default vhost file that is active on my system. I believe it is needed for the above example to work and it would likely be more correct to include a second version of this in my mydomain_vhost.conf file.

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
Listen 80

# Use name-based virtual hosting.
NameVirtualHost *:80

Hope this extra example helps.

Previous Topic:rsync how-to
Next Topic:How to install red5 or Flash media server ?
Goto Forum:

Current Time: Fri Feb 21 14:09:17 EST 2020
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2006 FUD Forum Bulletin Board Software