Installing PHP and Apache

10 Nov 2004

As part of the work Geoff and I are doing with Apache-Test, I wrote some instructions for installing PHP and Apache with my favorite options.

To install PHP as a shared library:

  1. $ tar -xvzf apache_1.3.33.tar.gz
  2. $ tar -xvzf php-5.0.2.tar.gz
  3. $ cd apache_1.3.33
  4. $ ./configure \
  5.       --prefix=/usr/local/apache \
  6.       --enable-module=most \
  7.       --enable-shared=max
  8. $ make
  9. $ sudo make install
  10. $ cd ../php-5.0.2
  11. $ ./configure \
  12.       --prefix=/usr/local/php \
  13.       --with-apxs=/usr/local/apache/bin/apxs \
  14.       --with-gd \
  15.       --with-mysql=/usr/local/mysql \
  16.       --enable-sockets \
  17.       --with-zlib-dir=/usr/include
  18. $ make
  19. $ sudo make install

To install PHP as a static library:

  1. $ tar -xvzf apache_1.3.33.tar.gz
  2. $ tar -xvzf php-5.0.2.tar.gz
  3. $ cd apache_1.3.33
  4. $ ./configure
  5. $ cd ../php-5.0.2
  6. $ ./configure \
  7.       --prefix=/usr/local/php \
  8.       --with-apache=../apache_1.3.33 \
  9.       --with-gd \
  10.       --with-mysql=/usr/local/mysql \
  11.       --enable-sockets \
  12.       --with-zlib-dir=/usr/include
  13. $ make
  14. $ sudo make install
  15. $ cd ../apache_1.3.33
  16. $ ./configure \
  17.       --prefix=/usr/local/apache \
  18.       --activate-module=src/modules/php5/libphp5.a \
  19.       --enable-module=most \
  20.       --enable-shared=max
  21. $ make
  22. $ sudo make install

If you're planning to attend ApacheCon, you don't want to miss our talk, Testing PHP with Perl. It will (hopefully) change the way you develop PHP applications.