Home | Hardware | Internet News |Web Hosting |IT Management |Network Storage
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials
 News
 Technology Jobs

 Browse by subject.
Free Newsletter

Linux Planet
Linux Today
More Free Newsletters

Be a Commerce Partner


















internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Print this article
Email this article

   LinuxPlanet / Tutorials







Adding PHP to Apache on Linux
Supercharging Your Web Pages

Ken Coar
Thursday, December 23, 1999 07:46:09 AM

Editor's note: With this debut column, Ken Coar joins LinuxPlanet as a monthly columnist. Coar's background as a pioneer in the open-source community is impressive, as a member of the Apache Group and a director and vice president of the Apache Software Foundation. He is also a core member of the Jikes open-source Java compiler project, a contributor to the PHP project, the author of Apache Server for Dummies, and a contributing author to Apache Server Unleashed.

The technology that supports the Web continues to evolve, and one of the latest mutations involves capitalising on its very user-driven interactivity. The days of all-static content are past; the Web has evolved to a point at which many sites actually remember personal preferences for each of their (potentially millions) of visitors. News sites may display stories in only those categories you find interesting; online music stores can provide you with listings of new works sorted in order by your favourite artists; Web search engines can learn to implicitly restrict the types of content they'll list for you. The possibilities are endless, and the key is generating a unique presentation for each viewer.

There are a number of ways of accomplishing this, from the primitive fly-swatter capabilities provided by "server-side includes" to the tactical nuke Extra Strength features found in application servers. The PHP scripting language falls somewhere into the middle ground, supplying phenomenal capabilities for free.

What is PHP?

PHP is a scripting language, with a particular affinity for and emphasis on enhancing Web pages. It has a syntax very similar to C (with a smattering of Perl and shell), and includes lots and lots of functions for things like database access, dealing with CGI requests, and image creation and manipulation.

When PHP is used as an Apache module, and the language elements are embedded in the document pages themselves, the HTML file might look something like the following:

    <head>
     <?
         //
	 // Preload all the functions and other definitions we need.
	 //
	 include("$DOCUMENT_ROOT/scripts/definitions.php3");
	 $pdetails = lookup_visitor();
	 echo "  <title>WhizBang Products: Welcome back, "
	     . $pdetails["first_name"] . "!</title>\n";
     ?>
    </head>
    <body bgcolor="#ffffff">
     <h1 align="center">Super-Duper Whizbang Products</h1>
     <h2 align="center">Welcome back,
      <? echo $pdetails["first_name"] . " "
             . $pdetails["last_name"]; ?></h2>

When a Web client requests a PHP-enabled page, the mod_php module gets to interpret the document and make changes to it before the Web server itself sends the results back. The results of the above PHP fragments might cause the following to be what the Web client actually receives:

    <head>
     <title>WhizBang Products: Welcome back, Ken!<title>
    </head>
    <body bgcolor="#ffffff">
     <h1 align="center">Super-Duper Whizbang Products</h1>
     <h2 align="center">Welcome back, Ken Coar</h2>

Notice how all the stuff between "<?" and "?>" was replaced—interpreted by mod_php—before it reached the browser? That's part of the power of PHP.

Next: Assumptions in This Article »

Skip Ahead

1 Supercharging Your Web Pages
2 Assumptions in This Article
3 How to Get PHP
4 PHP Extensions
5 Building PHP for CGI Use
6 Building PHP as an Apache Module
7 Building mod_php as a Dynamically Loaded Object
8 Testing Your Installation
9 Going Further/In Conclusion
10 Appendix A: Building Apache at Lightspeed
11 Appendix B: Apache Source Components Provided by Linux Distributions
12 Appendix C: Fixing Red Hat 6.1's apxs Script





Linux is a trademark of Linus Torvalds.


internet.com home | search | help! | about us

Jupiter Online Media

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers