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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
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

Getting More Out Of Apache (Part 1)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 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:
      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

    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.
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    ADMINISTRATION ARTICLES

    - 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
    - Advanced Concepts on Dealing with Files and ...
    - Dealing with Files and Filesystems





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