httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Smiley Jonathan <smileyjonat...@yahoo.com.au>
Subject Running multiple Apache 2 instances (long)
Date Tue, 21 May 2002 09:28:25 GMT
  I've seen a couple of posts asking about running multiple instances
of Apache in the past week or two so I thought I'd post my quick-fix
solution to the problem.

  This is a UNIX/Linux solution which requires building Apache httpd
from the source, but don't let that scare you.  Please don't ask me
for a binary distribution or RPM, it's really not that hard to do it
yourself.  I can't offer any advice on other operating systems.  I've
tested it with Apache 2.0.36.  It takes me about 15 minutes to set up
a new instance of Apache httpd, including compile time, and I'm
running Linux on a 4 year old laptop.

  This approach relies on installing multiple instances of the httpd
software.  I typically do this when I need to test a new version of
Apache without disturbing the existing instances, or run an old
version next to a new one, or run two versions with different build
configurations, etc.  By default, these instances all have their own
htdocs directories, but by editing httpd.conf, you can organise them
to share htdocs directories too.

  To ensure clean and systematic separation of all of the files making
up each instance, I followed the Filesystem Hierarchy Standard 2.2
(FHS).  It's a standard that specifies where the various files making
up a piece of software should be placed.  See
http://www.pathname.com/fhs/ for details.

  But first some standard legal responsibility ducking.  All the usual
disclaimers apply.  If you foolishly choose to follow my advice and
something awful happens, you're on your own.  Having said that, what I
describe works just fine for me though.  :-)

  OK, here we go (in 11 easy steps)...

0.  Download and unpack the Apache 2 *source* distribution.  "cd" into
    the top level of the directory hierarchy you unpacked.  If you're
    in the right place there should be a file named "config.layout".
    (If instead of unpacking the distribution you're working from an
    existing source distribution it's vital that you "make distclean"
    before continuing).

1.  Add the following lines (between the "---snip---" lines, but not
    including them) at the bottom of the "config.layout" file.  This
    defines a new layout telling the install process where to place
    the files that make up an Apache instance:

---snip---
#   According to the Linux Filesystem Hierarchy Standard 2.2 (FHS) with
#   the full product name and version in the directory names.  For more
#   information see the specification at http://www.pathname.com/fhs/.
#
<Layout LinuxFHSFullName>
    prefix:        /opt/apache-httpd-2_0_36
    exec_prefix:   ${prefix}
    bindir:        ${exec_prefix}/bin
    sbindir:       ${exec_prefix}/sbin
    libdir:        ${exec_prefix}/lib
    libexecdir:    ${exec_prefix}/libexec
    mandir:        ${prefix}/man
    sysconfdir:    /etc${prefix}
    datadir:       /var${prefix}/share
    installbuilddir: ${datadir}/build
    errordir:      ${datadir}/error
    iconsdir:      ${datadir}/icons
    htdocsdir:     ${datadir}/htdocs
    manualdir:     ${prefix}/manual
    cgidir:        ${datadir}/cgi-bin
    includedir:    ${prefix}/include
    localstatedir: /var${prefix}
    runtimedir:    /var/run/apache-httpd-2_0_36
    logfiledir:    /var/log/apache-httpd-2_0_36
    proxycachedir: /var/cache/www/apache-httpd-2_0_36/proxy
</Layout>
---snip---

    I've specified a full product name and version number in the
    directory names for this layout so that I can run multiple
    versions of Apache httpd at the same time.  I've put Apache and
    httpd into the name in case I have to install other Apache
    software or other httpd products in /opt at a later date.

    Replace every occurrence of "apache-httpd-2_0_36" in the layout
    you added with a unique instance name of your choice.  I usually
    append a hyphen and an instance name,
    e.g. "apache-httpd-2_0_36-test", or "apache-httpd-2_0_36-dev".

2.  Run the configure script to configure the build process.  Specify
    --enable-layout=LinuxFHSFullName as an argument along with any
    other options you need.  The configure script usually produces a
    few screens full of output.  In my case I use something like this:

    $ ./configure --enable-layout=LinuxFHSFullName \
      --enable-modules="rewrite auth-dbm so ssl"

    Don't assume my configure arguments are right for you.  Read the
    documentation in the "INSTALL" file if you want to know more.

3.  Build the software

    $ make >make.log 2>&1

    This takes a while to finish, but when it does, check "make.log"
    for any obvious errors.

4.  If you're not already doing this as root, now you'll need to
    become superuser to install, configure and start the freshly built
    software.  As root, make sure you're in the top level directory
    where you built the software and type:

    # make install >make-install.log 2>&1

    Then check the "make-install.log" file for any obvious errors.

5.  There's a bug in the Apache install procedure which means the
    "runtimedir" in your "config.layout" entry is not created.  You
    need to create the directory manually (usually as the superuser).
    Make sure you use exactly the same directory name as you have in
    "config.layout" or httpd won't start.  You should also check that
    the owner and permissions on the directory you create are
    appropriate.  (I've already reported the bug)

6.  Edit the configuration file for the new instance.  If you're
    running multiple Apache instances you'll probably need to have
    them listen on different ports or interfaces, etc.  As a starting
    point check the "ServerName" and "Listen" directives.  Refer to
    the Apache documentation in the "docs/manual" directory for more
    details.  My quick fix approach is to just use a different port
    for each instance, but that probably isn't suitable for globally
    visible servers.

7.  Start your new instance using the "apachectl" script in the
    "sbindir" from your "config.layout" entry.  For the sample layout
    above you'd type:

    # /opt/apache-httpd-2_0_36/sbin/apachectl start

    Common mistake: "apachectl" is in the "sbin" directory rather than
    the "bin" directory.  Doh!

8.  Check the "error_log" file in the "logfiledir" from your
    "config.layout" entry for any errors.  Remember to use the
    instance name you chose.

9.  You can stop being the superuser now.  Check that httpd is working
    by pointing a web browser at the index page at the top of your
    document root.  Before doing this you might want to make a change
    to the page to make sure you are actually using a separate httpd
    instance.  I usually go to the "htdocsdir" I specified in the
    "config.layout" and edit "index.html.en", inserting an extra
    paragraph at the end with the instance name in it.

    Remember to use a suitable URL for the port (or any other changes)
    you specified when you edited the "httpd.conf" file for this
    instance.  For example if you specified "Listen 8080" you need a
    URL like "http://yourhostname:8080/".

10. To install another instance of Apache httpd,

    $ make distclean

    in the top level directory (where "config.layout" resides").
    Without this your next install will simply use the previous
    layout you specified.

    Now edit the "config.layout" file entry you added in step 1 and
    substitute a new instance name for the old one.  Be very careful
    to change *all* of the instance names or you'll clobber your
    previous installation when you install the new one.

    As an alternative you may choose to keep a separate layout entry
    for each instance you create.  In that case you'll need a unique
    name for each <Layout> and you'll need to specify the correct name
    for the --enable-layout option when you run the configure script
    in step 2.

    Follow steps 2-9 above for the new instance.

  Finished!  I've glossed over a few configuration details, but the
people that need that kind of information aren't likely to be trying
this anyhow.  Failing that, the manual is in the "docs/manual"
directory.

  If you've got any comments or suggestions, please post them to the
mailing list rather than to me so everyone can share the knowledge.

                                                 Jonathan Knispel


http://briefcase.yahoo.com.au - Yahoo! Briefcase
- Save your important files online for easy access!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message