[thelist] [apache] multiple applications (domains) on one server

jsWalter jsWalter at torres.ws
Sun Oct 31 17:29:37 CST 2004


> Hi there,
> I am an Apache N00b who is getting to grips with documentroot,
> virtualhost ect.
>
> Q: I have ny current documentroot (dev server) set up to one application
> directory eg: /public/application1/
>
>
> Trouble is I now want to also run and develop for /public/application2/
> and apache sees doc root as inside public/application1 /
>
> I know it is possible to run multiple sites / applications on one server
> and have had a luckless try with virtualhost in the httpd.conf file, can
> anyone give me some pointers as to how this can be set up?
>
> (this is on apache 1.3.27 -> Win2k if that makes a difference)

Win2k is the not tissue here.

The issue is whether you are using this for internal development/testing
or for public access..

If internal, it's easy.

If external, just a bit harder.

you need each domain to resolve to either:
 1) it own IP
 2) the same IP

Your DNS server must tell your server tis info as well.

(I have this info in my HOST file, since I do this for internal dev/test
only).

I have this at the bottom of my httpd.conf file:

#
# This directory is used to store configuration files for individually
# packaged modules, such as mod_ssl, mod_perl, and php.
# This will open ONLY .conf files!
#
include conf.d/*.conf


#
# This directory is used to store configuration files for virtual hosts
# on this system
#
# This will open ONLY .conf files!
#
include conf.vh/*.conf


in the conf.d directory, I have all my confioguration files for Per, PHP,
mod_perl, SSL

in the conf.vh directory I have an individual file for each domain I handle.

This is the first file in there..

    a_virtual_hosts.conf

It HAS to load first, thus the 'a underscore'.

That file has...

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
ServerName 192.168.1.10:80



# ========================================================

# for more info, check out...

# http://httpd.apache.org/docs-2.0/vhosts/name-based.html

# This file MUST be first to load!


#NameVirtualHost *
NameVirtualHost 192.168.1.10:80
#NameVirtualHost 192.168.1.10:443


# This defines the default server... localhost

<VirtualHost terra:80>
	ServerName    terra:80
	ServerAdmin   walter at torres.ws
	ServerAlias   localhost

	DocumentRoot  /etc/httpd/htdocs
#	ScriptAlias   /cgi-bin /home/freelance_work/httpd/cgi-bin

	ErrorLog      /etc/httpd/logs/web_error.log
	TransferLog   /etc/httpd/logs/web_access.log
	ScriptLog     /etc/httpd/logs/script_access.log

	Alias /trident "/home/freelance_work/htdocs/Trident/tridentfs"

	# We are not using encryption here
	SSLEngine off
</VirtualHost>

# eof

this file for example [vh_gene6ftp.conf] is setup so I can exeriment with
a webv based management system for the gene6 FTP server. Its file looks
like this...

[
in my HOST file I have...

     192.168.1.10       gene6ftp
]

#################################################
# gene6

<VirtualHost gene6ftp:80>
        ServerName    gene6ftp.com:80
        ServerAlias   *.gene6ftp
        ServerAdmin   webmaster at torres.ws

        DocumentRoot  /home/gene6ftp/htdocs
        ScriptAlias   /cgi-bin /home/gene6ftp/httpd/cgi-bin

        ErrorLog      /home/gene6ftp/httpd/logs/error.log
        TransferLog   /home/gene6ftp/httpd/logs/access.log
        ScriptLog     /home/gene6ftp/httpd/logs/script.log
</VirtualHost>

# eof


In my browser, all I have to so is key in

    http://gene6ftp/

And the main page loads right up!

I also have phpMyAdmin setup on my server...

[
in my HOST file I have...

     192.168.1.10       phpMyAdmin
]

#################################################
# phpMyAdmin

<VirtualHost phpMyAdmin:80>
	ServerName    phpMyAdmin:80
	ServerAdmin   walter at php

	ServerAlias   *.phpMyAdmin

	DocumentRoot  /home/phpMyAdmin/htdocs
	ScriptAlias   /cgi-bin /home/phpMyAdmin/httpd/cgi-bin

        ErrorLog      /home/phpMyAdmin/httpd/log/web_error.log
        TransferLog   /home/phpMyAdmin/httpd/log/web_access.log
        ScriptLog     /home/phpMyAdmin/httpd/log/script_access.log

	<Directory /home/phpMyAdmin/htdocs>

		# Let Apache built a directory Index
		Options Indexes
		# Make the index "fancy"
		IndexOptions FancyIndexing

		# Let Apache read .htaccess files
		# and follow directives within
		AllowOverride Options

	</Directory>
</VirtualHost>

# eof

I think you get the idea.

For each domain you want to process, just add an entry into HOST, ad a
.conf file, restart the server and your running.

Hope this helps.

Walter




More information about the thelist mailing list