OpenBSD Journal

[Tip] Compiling php-3.0.14 as a DSO on OpenBSD

Contributed by Dengue on from the return-of-php dept.

Here's how to build php-3.0.14 as a DSO (Dynamically Shared Object) for Apache 1.3.9.

OpenBSD 2.6 includes Apache 1.3.9, with shared object support available. With this in mind, I decided to add PHP as an Apache DSO. For those unfamiliar with this concept, instead of a monolithic static Apache binary, I opted instead to create a dynamic Apache module that can be loaded at runtime. Thanks to work by Kevin Lo , PHP support can be built either from the ports tree , or from source.

As an OpenBSD port

The OpenBSD ports tree is available via anoncvs or you can use the CVSWEB interface to download the Makefile and other files associated with the port.

The port builds without error on 2.6 using the standard OpenBSD ports building method: make && make install Before you build however, it is best to customize the Makefile to your particular needs. Kevin only includes the following options in the standard port:

CONFIGURE_ARGS=         --with-apxs=/usr/sbin/apxs
CONFIGURE_ARGS+=        --without-pcre-regex
To customize this for your site, simply add other configure arguments to the makefile. For instance, if you want MySQL support add:
CONFIGURE_ARGS+=	--with-mysql
Other options can be seen by running ./configure --help in ./work/php-3.0.14 and looking at the available options.

This is the easiest way to add Php support to OpenBSD 2.6.

From Source

Php can be a troubled child for OpenBSD users, often not building well. That is also the case with version 3.0.14. Fortunately, the problem is documented at Php's impressive online bugs database. In a nutshell, attempts to build php-3.0.12-14 will fail with:   Definition of symbol `_pcre_*' (multiply defined) errors. The way to get around this, as documented at is:

  1. configure php
    ./configure --with-mysql  
    <<This is important
  2. make php
    # make
  3. Install php, this will automagically copy the module to the proper directory, and insert the correct AddModule lines in your httpd.conf
    # make install
That's all there is to it. Restart Apache and tail your log file,
# apachectl restart ;tail -f /var/www/log/error_log
and you should see this:

[Thu Jan 13 22:44:46 2000] [notice] Apache/1.3.9 (Unix)
OpenSSL/0.9.4 configured -- resuming normal operations 

That's all there is to it.

(Comments are closed)

  1. By Feynman () on

    The PHP support is the easy part... how did you get mySQL to compile ?


Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]