Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Getting More Out Of Apache (part 1)
Learn to use server-side includes and Apache's virtual hosting features.

| 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".


NameVirtualHost 127.0.0.1:80


Now, when you point your browser to this page (via the Web server), you should see something like this


NameVirtualHost 127.0.0.1:80


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!


NameVirtualHost 127.0.0.1:80


And the output would be:


NameVirtualHost 127.0.0.1:80


And you can also display the current server time, as illustrated below:


NameVirtualHost 127.0.0.1:80


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"


NameVirtualHost 127.0.0.1:80


and then create HTML pages which looked like this:


NameVirtualHost 127.0.0.1:80


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:


<VirtualHost 127.0.0.1>
    ServerAdmin webmaster@melonfire-alpha.com
    DocumentRoot /www/melonfire-alpha.com
    ServerName melonfire-alpha.com
    ErrorLog logs/melonfire-alpha.com-error_log
    CustomLog logs/melonfire-alpha.com-access_log common
</VirtualHost>


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 http://www.echodev.com/tutorials/ssi/basics/

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.

Note: All examples in this article have been tested on Linux/i586 with Apache 1.3.6. Examples are illustrative only, and are not meant for a production environment. YMMV!


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page print this article  more like this
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback