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
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: RHEL 6.5, Debian 7.2 and EOL for Linux 3.0.x
- 5Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10