Impossible tri-bar

Digital Phenomena - Your first stop for internet consultancy 
PHP4 Installation Overview

Page 2 — Getting Up and Running (Non-Windows)

Most of the time, you'll find PHP is used on a non-Windows OS, running as a module of the Apache Web server. This means that when you compile PHP from the source, using either the --with-apache or --with-apxs configuration options, you're creating a separate file that goes in the Apache modules directory. You then need to recompile Apache, activating your PHP module in the process. When you recompile Apache, the PHP parsing engine becomes part of the Web server, making request processing a quicker and more streamlined process.

There are two types of modules used with Apache: static and dynamic. Creating a static PHP module means that once you create the module and compile it into Apache, you're done. If you need to add more functionality to PHP, you must recompile PHP and, subsequently, Apache, since you'll be integrating a new version of the module.

The dynamic module (DSO, for "dynamic shared object") version of PHP saves you gobs of time in the long run. If, at some point, you decide recompile a PHP DSO to add or delete functionality, you don't have to recompile Apache when you recreate the DSO. All you need to do is stop and then restart Apache, which is why this combination of Apache and PHP as a DSO has been gaining in popularity since the PHP development team made it a possibility.

It might also be good for you to at least know about the CGI version of PHP. The CGI binary version of PHP isn't a module. Rather it's a standalone binary that lives in cgi-bin and waits for something to do. With the CGI version of PHP, all requests for PHP-driven pages are run through the binary, then served through the Web server, a process that obviously eats up a lot more time than a module.

Personally, I recommend the DSO installation because if you're anything like me, you'll want to add or delete elements of PHP when they become available or you find you don't need the functions anymore. Look at it this way: Suppose you build a simple version of PHP with just database support, then a few days later you decide you want to install encryption support. All you have to do is type "make clean" (to get rid of previous configuration settings and makefiles), add the new configuration option to your configuration command, then type "make" and "make install" to build a new module. This new PHP module will be dumped in the proper location for Apache, and all you have to do is restart Apache for the proper module to be loaded, not recompile it. Want to take something away, like that encryption support you just compiled in? No problem. Again, just type "make clean" to clean out the old stuff, use a configuration command that doesn't include encryption support, then type "make" and "make install" to build the new module, then just restart Apache.

Because the DSO installation is so easy to use, it's by far my favorite. In fact, I recommend it so highly that it's the method I'll be showing you in this tutorial. (If you want to learn about the static installation, there's a fine file called Install in the PHP distribution that you can peruse to your heart's content.)

Before getting started with your installation, you need to have two very important things: the ability to get around the command line and an ANSI C compiler. If you can change directories and edit a file, you've got the first requirement covered. If you don't have a clue what to do with the command line, then you should probably buy a book like Learning the Unix Operating System (Nutshell Handbook) or look in your operating system manuals, take the time to learn about your OS, and come back to this tutorial when you're ready.

The second requirement can be met by executing a "which" or "find" on your machine for gcc, bison and flex. If you have these programs, you're set. If not, you'll have to install them from your OS installation CDs, or visit, grab them from an FTP site, then install them from the downloaded files.

Once you've determined you have the proper tools and abilities, the next step is to to set some things up in Apache to make sure that your PHP installation runs smoothly, so we'll take care of that first.

next page»

|Home|About Us|Services|Search|
W3C validatedW3C validated CSSCompatible with all browsers