Apache
  Home arrow Apache arrow Getting Started with Apache 2.0 Part I...
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? 
APACHE

Getting Started with Apache 2.0 Part II
By: Harish Kamath
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2005-03-21

    Table of Contents:
  • Getting Started with Apache 2.0 Part II
  • The Apache Log Files
  • Who Are You?
  • One Server, One Hundred Websites

  • 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
     
     
    The Best Selling PC Migration Utility.
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Getting Started with Apache 2.0 Part II
    (Page 1 of 4 )

    In this second article in a three-part series, you will learn how to customize the the log files generated by the Apache Web server, and much more.

    Last time, I showed you how to install Apache on your own machine from scratch, and explained the configuration directives that help run the Web server. You also learned how to configure the latest versions of PHP and Apache to work together - an exciting combination, though I must admit that there are conflicting opinions on this subject.

    Today, I'll explain the configuration of the "main server." I opted to skip this topic in the last article. Next, I'll talk about the different log files generated by the Apache Web server and how you can customize them to your requirements. Finally, we'll see how to create "Virtual Hosts" that give us the ability to run multiple websites on a single instance of the Apache Web server.

    So, what're you waiting for? Let's get cracking!

    One Server, One Website

    In the previous article, I gave you a quick overview of the "httpd.conf" configuration file but I stopped short of explaining the section that dealt with the "main server" configuration due to space constraints. So, let me talk about it before I run out of bytes again.

    By default, Apache is configured to serve a single website, and the "main server" configuration section encompasses "directives" that drive this default website. Let me explain them one-by-one:

    ServerAdmin webmaster@mysite.com

    The "ServerAdmin" directive allows you to specify an e-mail address for the administrator of the Web server. This comes in handy if an error occurs on the server: Apache will display this e-mail address on the Web page for further action by the visitor who encountered the error.

    Humans being humans, website visitors cannot be expected to remember the bunch of numbers that form the IP address when most fail to even remember their own anniversaries. This is where the use of human-friendly "domain names" and the "ServerName" Apache directive comes in handy, as it is easier to remember a URL such as www.mysite.com than its IP address. Take a look:

    ServerName www.mysite.com:80

    As seen above, this directive allows you to explicitly specify the name for your Web server and the port on which it runs. However, if you do not have a valid host name for your server, you can also opt to list the IP address of the Web server with this directive.

    DocumentRoot /usr/local/apache/htdocs

    This directive specifies the location of the "root" folder of the Web server. By default, all requests are served from the files located under this folder.

    Next, I'll talk about the "Directory" directive - this special directive allows you to specify a list of features for each file-system directory on the Web server. Consider the following snippet:

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    Let us start with the root folder on the server. For obvious security reasons, the default Apache configuration enforces high security for this folder by disabling most features. However, you can customize these very features for subsequent folders located under the root folder. Let me start with the root folder of the "Web server" as specified in the "DocumentRoot" directive:

    <Directory /usr/local/apache/htdocs>
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    The "Options" directive allows you to list the features that you would like to enable for the directory in question; in the above example, you have the "DocumentRoot" folder under scrutiny. For example, the above snippet enables two of them: "Indexes," which directs the Web server to list the contents of the directory in the absence of an index page (for example, index.htm) and "FollowSymLinks," which, as the name suggests, instructs the Web server to follow any "symbolic" links that may be located in the current folder.

    There are other features that you can enable in this "Directory" directive, including the "ExecCGI" directive that allows you to execute CGI scripts on your Web server, the "Includes" directive allows you to include Server-Side Include (SSI) commands in your Web pages and much more. For a complete list, please review the following URL: http://httpd.apache.org/docs-2.0/mod/core.html#options

    Next, the "AllowOverride" directive enables the use of a folder-specific ".htaccess" file, which in turn can contain its own set of Apache directives to drive access and security on a per-folder basis.

    Note that the "directives" that you can use in this ".htaccess" file are governed by the value specified for the "AllowOverride" directive above. If this is set to "None" - as in the code listing above - the ".htaccess" files are totally ignored. For other options, I recommend that you read the following documentation: http://httpd.apache.org/docs-2.0/mod/core.html#allowoverride.

    Finally, you have the "Order," "Allow" and "Deny" directives. These three directives are provided by the "mod_access" Apache module and allow you to implement a fine-grained access policy across the entire Web server. The "Order" directive lists the "order" in which the "Allow" and "Deny" directives should be implemented, whereas the "Allow" and "Deny" directives allow you to specify a domain or an IP address (even partial ones) or a combination of a network/netmask addresses - thereby permitting or restricting access to specific users respectively. For more information on this "mod_access" module and its associated directives, hop over to http://httpd.apache.org/docs-2.0/mod/mod_access.html

    Now, you must be wondering why I've opted to talk about these "main server" specific directives now. The reason is simple. Later in the article, I'll show you how to configure a single Web server to run several websites, and you should be able re-use these directives for each Web site.

    More Apache Articles
    More By Harish Kamath


       · hi i am seting up a multi site this is the warning that i get when is set up my...
     

       

    APACHE ARTICLES

    - Putting Apache in Jail
    - Containing Intrusions in Apache
    - Server Limits for Apache Security
    - Setting Permissions in Apache
    - Installing Apache
    - Apache Installation and Configuration
    - Apache Tapestry and Custom Components: DateI...
    - Tapestry and AJAX: Autocompleter and InlineE...
    - PropertySelection and IPropertySelectionMode...
    - The DatePicker and Shell Components of Apach...
    - Apache Tapestry: ASO and More Components
    - Apache Tapestry and DirectLink, IoC and DI
    - Making a CelebrityCollector with Apache Tape...
    - Apache Tapestry and Listener Methods, Condit...
    - The Properties of Tapestry Pages

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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