Apache
  Home arrow Apache arrow Page 7 - Secure Installation and Configuration
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
APACHE

Secure Installation and Configuration
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 30
    2004-08-17


    Table of Contents:
  • Secure Installation and Configuration
  • Asymmetric Encryption and GnuPG
  • GnuPG and Apache Signatures
  • Checking and Installing Apache
  • Running Apache and Testing it with Nikto
  • Secure Configuration
  • File Permissions
  • Don’t Give Extra Information Away
  • Apache and SSL
  • Generate Certificates
  • Configuration

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Secure Installation and Configuration - File Permissions
    ( Page 7 of 11 )

     

    File Permissions

    Make sure that Apache’s files and directories are only writable by root. These are the commands suggested by Apache’s web site:

    # cd /usr/local/apache
    # chown 0 . bin conf logs
    # chgrp 0 . bin conf logs
    # chmod 755 . bin conf logs
    # chown 0 /usr/local/apache/bin/httpd
    # chgrp 0 /usr/local/apache/bin/httpd
    # chmod 511 /usr/local/apache/bin/httpd

    Having the wrong permissions set could allow a malicious user to replace the httpd binary, and therefore execute a script as root.

    Understand How Options Are Applied

    Most directives can be defined in different sections of your httpd.conf file:

    1. <Directory> sections

    2. <Directory> sections

    3. <Files> and <FilesMatch> sections

    4. <Location> and <LocationMatch> sections

    5. <VirtualHost> sections
    6. .htaccess (if it is allowed)

    Apache merges the directives found in these sections following this particular order. Also, each section is processed in the order that it appears in the configuration file, except <Directory>, where the shortest directories are processed first. Also, <Directory> refers to actual directories on the file system, <Location> whereas refers to a Web location.

    The configuration files I proposed earlier in the chapter read:

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

    The directive <Directory /> refers to the actual root directory of the server. Immediately after, you can see the following directive, which is processed after the previous one, as it refers to a longer path:

    <Directory "/usr/local/apache2/htdocs">
       AllowOverride None
       Order allow,deny
       Allow from all
    </Directory>

    In this case, I set very restrictive permissions for the server’s root directory, and then I allowed looser security for the document root (/usr/local/apache2/ htdocs). I could have defined different options for a directory inside htdocs:

    <Directory "/usr/local/apache2/htdocs">
    Options +FollowSymLinks +AllowOverride
       AllowOverride None
       Order allow,deny
       Allow from all
    </Directory>
     

    For the directory insecure, the options FollowSymLinks (which allows the following of symbolic links, and should be turned off ) and AllowOverride (which enables the .htaccess file mechanism, and should be disabled if possible) are added (thanks to the + symbol) to the inherited options.

    You should be aware of how this mechanism works. The document http://httpd.apache.org/docs-2.0/sections.html explains exactly how Apache reads its configuration section, and http://httpd.apache.org/docs-2.0/mod/core.html#options explains what options can be set. A complete understanding of both these documents is vital to ensure the security of your Apache installation.

    Don’t Expose Root’s Home Page

    If you need to allow users’ directories (such as http://www.site.com/~username) with the directive Userdir, remember to have this line in your configuration:

    UserDir disabled root

    Delete Any Default Files

    The CGI scripts printenv and test-cgi are installed by default. They have caused problems in the past, because standard Apache scripts that came with the server were inherently vulnerable, and a source of security breaches and problems. Now, when Apache is installed they are not executable. However, in a production environment they should be deleted:

    [root@merc root]# cd /usr/local/apache2/
    [root@merc apache2]#
    ls cgi-bin
    printenv test-cgi
    [root@merc apache2]#
    rm cgi-bin/*
    rm: remove regular file `cgi-bin/printenv'?
    y
    rm: remove regular file `cgi-bin/test-cgi'?
    y
    [root@merc apache2]#

    The same applies to the default web site, which should be deleted:

    [root@merc root]# rm -rf /usr/local/apache2/htdocs/*

    You should then place your own web site in the htdocs directory.

    This chapter is from Hardening Apache, by Tony Mobily. (Apress, 2004, ISBN: 1590593782). Check it out at your favorite bookstore today. Buy this book now.



     
     
    >>> More Apache Articles          >>> More By Apress Publishing
     

       

    APACHE ARTICLES

    - Creating a VAMP (Vista, Apache, MySQL, PHP) ...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek