Administration
  Home arrow Administration arrow Page 5 - Getting More Out Of Apache (Part 1)
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  
ADMINISTRATION

Getting More Out Of Apache (Part 1)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    2001-01-04


    Table of Contents:
  • Getting More Out Of Apache (Part 1)
  • Virtually Yours
  • Two Birds With One Host
  • Gotcha!
  • Including A Few More Tricks

  • 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


    Getting More Out Of Apache (Part 1) - Including A Few More Tricks
    ( Page 5 of 5 )

    The next item on today's agenda involves something called "server-side includes", or SSI.

    Very simply, server-side includes are sets of instructions which enable Web servers to display data contained in server-side variables (server date and time, file currently in use, and so on). SSI also allows you to include external text files in your HTML pages - this comes in handy when you need to add a common header and footer to every HTML page.

    Adding support for server-side includes is again a matter of tweaking the Apache configuration file, "httpd.conf". By default, the server root is not configured to parse documents containing SSI instructions. In order to enable this support, you need to add the

    Includes
    keyword to the <Directory> directive - it should look something like this:

    Options Indexes FollowSymLinks Includes
    Next, you need to tell the server to recognize SSI files - these typically have the file extension ".shtml". In order to do this, add the following lines to the configuration file:

    # specify MIME type for SSI files AddType text/html .shtml AddHandler server-parsed .shtml
    Restart Apache for the changes to take effect.{mospagebreak title=Hello, World!} With that done, it's time to take see how server-parsed HTML files work. Create the following simple file, and save it as "hello.shtml".

    <html> <head> </head> <body> You have just loaded <!--#echo var="DOCUMENT_NAME" --> </body> </html>
    Now, when you point your browser to this page (via the Web server), you should see something like this

    You have just loaded hello.shtml
    Thus, the SSI directive allows you to obtain the name of the current document without you - the document author - having to explicitly specify it.

    SSI also allows you to display the size and last modification time of the current file - take a look!

    <html> <head> </head> <body> You are currently viewing <!--#echo var="DOCUMENT_NAME" --> (<!--#fsize file="$DOCUMENT_NAME" -->), last modified on <!--#flastmod file="$DOCUMENT_NAME"--> </body> </html>
    And the output would be:

    You are currently viewing hello.shtml ( 1k), last modified on Thursday, 04-Jan-2001 21:28:33 IST
    And you can also display the current server time, as illustrated below:

    <!--#config timefmt="%I:%M %p" --> <html> <body> Current time is <!--#echo var="DATE_LOCAL" --> </body> </html>
    Finally, SSI also allows you to separate common elements of your Web pages into separate files, and include these files on each and every page. For example, if I have a copyright notice that is to be displayed on each and every page, I could place it in a file named "footer.txt"

    This material copyright Melonfire, 2001. All rights reserved.
    and then create HTML pages which looked like this:

    <html> <head> </head> <body> This is where proprietary material goes. <p> <!--#include file="footer.txt"> </body> </html>
    Now, each time a page like the one above is requested from the Web server, Apache will automatically include the contents of the file "footer.txt" in the appropriate place. The final page might look something like this:

    This is where proprietary material goes. This material copyright Melonfire, 2001. All rights reserved.
    Be warned, however, that extensive use of SSI can affect Web server performance, since the server has to first parse the file before sending it to the client browser - so use it judiciously.

    Detailed information on SSI can be obtained from the SSI resources at http://httpd.apache.org/docs/howto/ssi.html

    And that's about it for this time. Come back for the second part of this article, where I'll be discussing URL rewriting, user authentication and a few other tricks.

     
     
    >>> More Administration Articles          >>> More By icarus, (c) Melonfire
     

       

    ADMINISTRATION ARTICLES

    - Network Booting via PXE: the Basics
    - Scalix: Linux Administrator`s Guide
    - Network Administration with FreeBSD 7
    - Components of an Information Architecture
    - The Anatomy of an Information Architecture
    - 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





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