Administration
  Home arrow Administration arrow Page 6 - How To Build the Apache of Your Dreams
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ADMINISTRATION

How To Build the Apache of Your Dreams
By: Darren Chamberlain
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2000-09-19

    Table of Contents:
  • How To Build the Apache of Your Dreams
  • Building Apache
  • Module Definitions and Groupings
  • Diversion: Shared Modules (mod_so)
  • Diversion: Layouts
  • Building Apache, Really
  • Last Thoughts
  • References

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    How To Build the Apache of Your Dreams - Building Apache, Really
    (Page 6 of 8 )

    OK, enough background; let's compile Apache. The actual build process is relatively speedy, for all of the planning that goes into it. Compilation happens in a series of steps, where each module is compiled separately, turned into libraries, and then all those libraries get linked together into a single executable, except when using mod_so, inc which case this step is skipped for modules that are to remain shared.

    Case One: ISP (www.foo.isp)

    The simplest case is that of the default configuration, for example, something an ISP might use. Since we can accept all the default modules, configuration is a matter of:

    # ./configure
    That's it. It doesn't get much easier than this. configure is nice, and warns you about using the default configuration, but in this case, it's what we want so we can ignore it, and proceed with make, make test, and make install. Our completed binary looks like this:

    # /usr/local/apache/bin/httpd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_access.c mod_auth.c mod_setenvif.c

    Case Two: Corporate Web Site (www.content-heaven.com)

    For this example, we are going to build a copy of Apache for a well-designed commercial website (by well-designed, I mean that we have complete control over what types of files will go on it).

    We have no imagemaps or asis files, so we can disable mod_imap and mod_asis. There are no user directories on it, and all directories have index files, so we can disable mod_userdir and mod_autoindex. And, finally, none of our pages require any sort of authentication, so can can disable mod_auth (the other mod_auth_* modules are not compiled in by default). We will keep mod_access, however, to protect our server-status page.

    We need mod_status so we can keep track of the status of the server, and mod_access to limit access to that page to our domain only (for internal usage). mod_dir lets us specify that each directory has a default index file of index.shtml. (Using mod_actions, we have defined files with a .shtml extension to be handled by mod_include, which means that the web server will parse them for special processing directives, which it will execute. We have also, through mod_dir, told Apache to serve a file called index.shtml whenever someone requests a directory, i.e., a URL that ends with a /.) These are all enabled by default, and require no extra enable-module directives. Since our marketing department saw fit to publish mixed-case URLs in our advertisements, we will need mod_speling, which makes URLs case insensitive (--enable-module=speling).

    Don't forget that when specifying modules to enable or disable, you need to list the name of the module, without the "mod_" prefix.

    The standard Apache layout is almost exactly what we need, except for one thing, we would like log files to go into our NFS mounted log directory, /logs/httpd. We can accomplish this by passing --logfiledir=/logs/httpd to the configure script.

    Here is what we will type at the command line:

    # cd /usr/local/src/apache_1.3.12 # ./configure --with-layout=Apache \ --logfiledir=/logs/httpd \ --enable-module=speling \ --disable-module=imap \ --disable-module=asis \ --disable-module=userdir \ --disable-module=autoindex \ --disable-module=auth \ --verbose
    Apache will store this in a file called config.status in the root of the source tree (where the configure script lives), so the build can be duplicated easily (it is informative to look at this file, to see what configure thinks you meant). After this finishes running, you will get your prompt back; type make and watch the messages fly across the screen. Once the compiling is completed (again, when you get your prompt back), make install will put the files into the directories specified by the layout chosen (this may require root access to the machine, depending on where the files are going).

    Our finished binary looks like:

    # /usr/local/apache/bin/httpd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_dir.c mod_cgi.c mod_actions.c mod_speling.c mod_alias.c mod_access.c mod_setenvif.c
    Slim, compact, and to the point.

    Case Three: Graphics Server (graphics.content-heaven.com)

    In addition to the general HTML-serving httpd, Content Heaven, Inc has decided to use a dedicated server specifically for serving their images and graphics. In this common scenario, only a few of Apache's modules are needed, since the server will be doing one thing, and one thing only: sending files from disk over the network. Thus, we can disable many of the standard modules that we left untouched before, such as mod_access, mod_include, mod_index, and mod_cgi, in addition to the ones we had disabled earlier. Finally, let's include mod_rewrite in the graphics server, for redirecting direct requests for graphics.content-heaven.com to www.content-heaven.com.

    Our configure command looks like this:

    # ./configure --with-layout=Apache \ --logfiledir=/logs/httpd \ --disable-module=imap \ --disable-module=asis \ --disable-module=userdir \ --disable-module=autoindex \ --disable-module=auth \ --disable-module=access \ --disable-module=include \ --disable-module=dir \ --disable-module=cgi \ --disable-module=env \ --disable-module=setenvif \ --disable-module=negotiation \ --enable-module=rewrite \ --verbose
    Notice that is looks very similar to the previous example. Once it has completed compiling, our binary looks like this:

    # /usr/local/apache/bin/httpd -l Compiled-in modules: http_core.c mod_log_config.c mod_mime.c mod_status.c mod_actions.c mod_alias.c mod_rewrite.c
    This is even more slimmed down that the previous one, and contains only the exact modules we need.

    {mospagebreak title=Apache Module Registry}

    The Apache Module Registry is your key to a really cool customized web server. There are tons of modules to do things like authentication and parameter parsing, embedded languages like mod_perl, Java (with Apache JServ, allowing for embedded Java, and The Jakarta Project, a JSP implementation), mod_snake (for Python), and mod_tcl, and others.

    More Administration Articles
    More By Darren Chamberlain


     

       

    ADMINISTRATION ARTICLES

    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization
    - Advanced Concepts on Dealing with Files and ...
    - Dealing with Files and Filesystems
    - More Hacks for the User Environment in BSD
    - Personalizing the User Environment in BSD
    - Customizing the User Environment in BSD




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway