Adding PHP to Apache on Linux - page 6
Supercharging Your Web Pages
To use embedded PHP code in Web pages, build it in one of two different ways, depending upon whether it is to be loaded dynamically or built permanently into the Apache server. The only difference between the interpreter and dynamic module builds is the
configure command; the sequence for building it as a static module is considerably more complex.
In order to allow Apache to recognise PHP-enabled HTML files as being grist for
mod_php's mill requires a line like the following in the
AddType application/x-httpd-php3 .php3
Then the Web server will know to invoke the PHP module to process the file.
Linking it Statically
'Static' modules are linked into the Apache server itself, and cannot be removed without recompiling. This means that they can consume resources, such as memory, even if not used or activated. It also means rebuilding the entire server any time a single module is altered (such as upgrading the PHP installation). The Apache Group now strongly encourages the use of DSOs (dynamic shared objects) in preference to static modules because of their flexibility. While static modules are far from deprecated, I'm including the steps here only for completeness; Linux has no problem with dynamic modules´┐Żuse the dynamic-module method instead of the static.
In order to build
mod_php for static inclusion in the Apache server it's necessary to jump back and forth between the Apache and PHP directories, following a series of interdependent configuration and compilation steps. You indicate that you're building
mod_php statically by using the
--with-apache switch on the
./php/php3/configure script invocation.
% # % # Preconfigure Apache so that PHP knows where things are % # % cd ./apache-1.3 % ./configure --prefix=/usr/local/web/apache % # % # Now configure and build PHP as a module % # % cd ../php/php3 % rm -f config.status config.cache % ./configure --with-apache=../../apache-1.3 other-switches % make % make install % # % # Now *really* configure Apache, and build it % # % cd ../../apache-1.3 % ./configure --prefix=/usr/local/web/apache \ > --activate-module=src/modules/php3/libphp3.a % make % # % # Install the resulting httpd application % # % /usr/local/web/apache/bin/apachectl stop % cp src/httpd /usr/local/web/apache/bin % cd ../php/php3 % cp php3.ini-dist /usr/local/lib/php3.ini % /usr/local/web/apache/bin/apachectl start
(You will probably have to execute the last five commands as
See how complicated this is? Repeat for every PHP module rebuild.
- Skip Ahead
- 1. Supercharging Your Web Pages
- 2. Supercharging Your Web Pages
- 3. Supercharging Your Web Pages
- 4. Supercharging Your Web Pages
- 5. Supercharging Your Web Pages
- 6. Supercharging Your Web Pages
- 7. Supercharging Your Web Pages
- 8. Supercharging Your Web Pages
- 9. Supercharging Your Web Pages
- 10. Supercharging Your Web Pages
- 11. Supercharging Your Web Pages
- 12. Supercharging Your Web Pages