3 AUTHOR: J. Jones <jdj@darkside.dynup.net>
6 This hint should get apache and PHP up and running, with the majority of PHP's features enabled. The methods used here seem (to me) to be the perfect balance between performance and efficient resource usage. PHP will be compiled statically into apache, which gives the best performance, yet most of PHP's extras will be built as shared modules, keeping the httpd binary nice and small (read sexy).
11 I have to assume alot of configuration options in this hint,
12 so if you do stray (mainly on the --prefix's), pay attention! :)
14 =====================================
15 Software used/mentioned/etc in this hint.
18 http://httpd.apache.org/dist/
21 http://php.net/downloads.php
24 Seemingly the most popular free SQL server
25 http://www.mysql.com/downloads/
28 Excellent free SQL server
29 http://postgresql.readysetnet.com/sites.html
33 http://www.sleepycat.com/download.html
35 GD - 1.8.4 is the recommended version at this time.
36 Image creation on the fly
37 http://www.boutell.com/gd/
41 ftp://ftp.freesoftware.com/pub/infozip/zlib/
45 ftp://ftp.uu.net/graphics/jpeg/
49 ftp://ftp.libpng.org/pub/png/src/
52 Patent-free gif library
53 ftp://prtr-13.ucsc.edu/pub/libungif/
56 True Type font library (YOU WANT THIS!)
57 http://freetype.sourceforge.net/
60 Wonderful encryption library
61 http://www.openssl.org/
64 Provides access to several hashing algorithms
65 http://mhash.sourceforge.net/dl
68 Provides access to several encryption schemes
69 http://mcrypt.hellug.gr/
72 GNU readline (It's what makes bash so cool)
73 ftp://ftp.gnu.org/gnu/readline/
76 The new API for aspell/ispell
77 http://pspell.sourceforge.net/
79 Imap - 2000c please, not the latest beta they'd like you to have :)
81 ftp://ftp.cac.washington.edu/imap/old/imap-2000c.tar.Z
85 http://curl.haxx.se/download.html
88 XML DOM library, not to be confused with apache's expat,
89 used by php's xml parser.
90 http://www.xmlsoft.org/#Downloads
93 LDAP server and library
94 http://www.openldap.org/software/download/
98 http://zziplib.sourceforge.net/
100 =====================================
107 Extract the apache source. Move this directory to
108 /usr/local/apache (mv ./apache_1.3.17 /usr/local/apache).
109 Cd into /usr/local/apache.
111 Edit the config.layout file to suit your tastes. After that, run
114 --with-perl=/usr/bin/perl \
115 --enable-module=all \
116 --enable-shared=max \
117 --disable-module=proxy \
118 --disable-module=usertrack \
119 --disable-module=auth_anon \
120 --disable-module=auth_db \
121 --disable-module=auth_dbm
123 This will cause apache to build all of its modules as DSO's (Dynamic Shared
124 Objects), thus reducing the size of the httpd binary. This is how I do it,
125 feel free to stray as much as you wish. It will not affect anything else.
126 Allowing some of those modules to compile statically would probably boost
127 performance, but that's another hint. ;) FEEL FREE TO IMPROVE UPON THIS!
129 We'll come back to apache later.
135 The libraries this package depends on are all fairly easy to install. I won't
136 get into them. I assume a --prefix=/usr on the first three (jpeg, ungif, png)
137 and --prefix=/usr/X11R6 on the last two (ttf/freetype, t1). Also, compile those
138 libraries in the order they are listed, especially the last two.
140 Extract the gd-1.8.4 source. Download the patch (it builds a .so for you :)
141 from ^^^^GD-URL^^^^. Applying this patch should be as simple as:
142 zcat gd-1.8.4-shared.patch.gz | patch -p0
143 Edit the Makefile as you see fit (installation prefixes, possible removal of
144 the freetype flags, which I don't recommend at all). The Makefile will read
145 the $CFLAGS environment variable, so don't worry about those.
153 The newest imap c-client libs are very beta. I recommend sticking with the
154 latest stable release, 2000c. My patch won't work on anything else without
155 some hacking, anyway. ;)
157 Extract the imap-2000c package, download the patch (which creates a .so for
158 you too :) from ^^^^IMAP-URL^^^^. Apply it with:
159 zcat imap-2000c-shared.patch.gz | patch -p0
160 Cd into the imap-2000c directory, and issue the following commands:
164 That should be all there is to it. This source tree is rather nasty in my
165 opinion, so if the build fails for you, yell at me. Email me the WU-imap.sucks
168 ./Build-me >WU-imap.sucks 2>&1
169 and I'll see what I can do.
175 Basically what I do is strip the php interpreter down to the bare minimum,
176 compile it statically into apache, then build php's extras as shared objects
177 which can be loaded by scripts (or at startup in the php.ini).
179 PHP Static Apache module:
180 Extract the php source. Enter the directory. Issue the following, note that
181 you must change these paths toooooo:
184 --prefix=/path/to/apache \
185 --with-config-file-path=/path/to/apaches/conf/files \
186 --with-apache=/path/to/apache \
190 --without-pcre-regex \
192 --with-openssl=/path/to/openssl \
196 Unfortunately the openssl stuff won't yet (or isn't able to) build as a shared
197 object, so if you want it, you have add it now. I have yet successfully
198 hacked it up to build as a .so; if anyone has, let me know! :) (Even the
199 current CVS versions won't).
201 Now, back to apache. Issue the same exact configure command you did
202 previously to apache, adding the following line:
204 --activate-module=src/modules/php4/libphp4.a
206 You can now make all install on apache.
211 This is completely optional, but nice to have, in my opinion. This will
212 create a php binary interpreter, which you can use just like perl or sh. Do
213 NOT use this for web pages.
215 In the php source directory, do the following:
219 --prefix=/usr/local \
220 --with-config-file-path=/usr/local/etc \
221 --enable-force-cgi-redirect \
222 --enable-discard-path \
226 --without-pcre-regex \
229 --with-openssl=/path/to/openssl
232 You will now have a /usr/local/bin/php command line interpreter.
237 Now the fun part. Do a make distclean on the php source tree.
239 NOTES: PHP has a bundled mysql client library, so it doesn't require
240 mysql to be installed to support it. If you are using pspell, you need the
241 patch from ^^^^PSPELL-PATCH^^^^ in order for php to compile successfully.
242 This library was updated recently, and changed the api a bit. That patch
243 will fix php's pspell support. DOM XML (libxml) requires BOTH libxml-1.* and
244 libxml2-* to be installed.
247 --with-apache=/usr/local/apache == Path to apache
248 source tree, build as apache module
252 --with-mysql=shared,/optional/path/to/mysql (see note above)
253 == Include the mysql client
254 For PostGreSQL support...
255 --with-pgsql=shared,/pgsql/install/prefix == Include pg
256 client, prefix to postgres install
257 For DB3 support (YOU HAVE TO TRY THIS! IT SMOKES THE *SQL's!)
258 --enable-dba=shared == enable the db abstraction layer
259 --with-db3=/usr == add db3 support to it!
262 --with-gd=shared,/usr/X11R6 == Use gd, prefix to gd install
263 --with-jpeg-dir=/usr == jpeg libs are prefixed here
264 --with-xpm-dir=/usr/X11R6 == xpm libs are prefixed here
265 --with-ttf=/usr/X11R6 == use ttf, and it's prefixed
267 --with-t1lib=/usr/X11R6 == use type 1 fonts,
269 --enable-gd-imgstrttf
270 --enable-gd-native-ttf
272 Encryption and compression stuff...
274 --with-mhash=shared,/usr == use mhash, prefixed here
276 --with-mcrypt=shared,/usr == use mcrypt, prefixed here
278 --with-zlib=shared,/usr == use zlib functions, and it's prefixed here
280 --with-bz2=shared,/usr == bzip2!
282 --with-zziplib=shared,/usr == zzip!
285 --with-imap=shared,/prefix/to/imap/ == enable the imap functions
286 --with-imap-ssl=/path/to/openssl == add ssl support!
289 --with-pcre-regex=shared == Perl Compatible Regular Expressions! (builtin)
290 --with-pspell=shared,/path/to/pspell == Pspell support
291 --with-curl=shared,/path/to/curl == use curl!
292 --with-ldap=shared,/path/to/openldap == enable ldap functions
293 --with-gettext=shared,/usr == GNU gettext support!
294 --with-readline=shared,/usr == GNU Readline support!
295 --enable-bcmath=shared == bcmath precision calculations (builtin)
296 --with-gmp=shared == GNU precision math lib (builtin)
297 --enable-posix=shared == posix functions (builtin)
298 --enable-calendar=shared == calendar conversion (builtin)
299 --enable-ctype=shared == character type functions (builtin)
300 --enable-filepro=shared == bundled filepro support (builtin)
301 --enable-shmop=shared == shmop support (builtin)
302 --enable-sysvsem=shared == SystemV semaphore functions (builtin)
303 --enable-sysvshm=shared == SystemV shared memory functions (builtin)
304 --with-xml=shared == XML parsing support (builtin)
305 --enable-wddx=shared == XML wddx stuff (builtin)
306 --with-domxml=shared,/path/to/libxml == DOM XML stuff
307 --enable-ftp=shared == enable ftp functions (builtin)
308 --enable-sockets=shared == enable network socket functions
310 --enable-yp=shared == yp support (builtin)
311 --enable-dbase=shared == old dbase read-only support (builtin)
312 --enable-exif=shared == exif support (builtin)
314 The =shared options creates a shared library which php
315 will load, allowing you to update one or more modules/features,
316 without recompiling apache and php.
318 Here's the entire ./configure command, with every option shown above. Be sure
322 --with-apache=/usr/local/apache \
323 --with-mysql=shared,/optional/path/to/mysql \
324 --with-pgsql=shared,/pgsql/install/prefix \
325 --enable-dba=shared \
327 --with-gd=shared,/usr/X11R6 \
328 --with-jpeg-dir=/usr \
329 --with-xpm-dir=/usr/X11R6 \
330 --with-ttf=/usr/X11R6 \
331 --with-t1lib=/usr/X11R6 \
332 --enable-gd-imgstrttf \
333 --enable-gd-native-ttf \
334 --with-mhash=shared,/usr \
335 --with-mcrypt=shared,/usr \
336 --with-zlib=shared,/usr \
337 --with-bz2=shared,/usr \
338 --with-zziplib=shared,/usr \
339 --with-imap=shared,/prefix/to/imap/ \
340 --with-imap-ssl=/path/to/openssl \
341 --with-pcre-regex=shared \
342 --with-pspell=shared,/path/to/pspell \
343 --with-curl=shared,/path/to/curl \
344 --with-ldap=shared,/path/to/openldap \
345 --with-gettext=shared,/usr \
346 --with-readline=shared,/usr \
347 --enable-bcmath=shared \
349 --enable-posix=shared \
350 --enable-calendar=shared \
351 --enable-ctype=shared \
352 --enable-filepro=shared \
353 --enable-shmop=shared \
354 --enable-sysvsem=shared \
355 --enable-sysvshm=shared \
357 --enable-wddx=shared \
358 --with-domxml=shared,/path/to/libxml \
359 --enable-ftp=shared \
360 --enable-sockets=shared \
362 --enable-dbase=shared \
363 --enable-exif=shared \
365 | tee ~/php-config.log
367 This script tends to fly by fairly quick.. so check the ~/php-config.log for
370 PHP's configure script doesn't seem to carry it's -L's and -I's very well. If
371 you get any fatal errors, check the config.log. My workaround for this is
372 adding the following to the beginning of that ./configure line:
374 CFLAGS=$CFLAGS\ -L/usr/local/lib\ -L/usr/X11R6/lib\ -I/usr/local/include\
375 -I/usr/X11R6/include <configure command above>
377 Hopefully this will be worked out in the future.
379 Once everything looks ok, issue a make. Once completed, choose a location to
380 keep these .so's, like /usr/local/lib/php, cd into the modules directory, and
381 cp *.so /usr/local/lib/php/. You may wish to strip -g those modules also.
383 Now, the key here is your php.ini. Copy the php.ini-dist file from the php
385 /config/file/path/you/chose/when/you/built/the/apache/module/php.ini. In this
386 file, change the extension_dir to the /path/you/copied/the/*.so's.
388 If you wish for php to load any of these at startup, add extension=name.so to
389 the php.ini. To load these at runtime, this seems the most effective way.
391 Say I need the mysql support. At the beginning of my script, I'd have this:
392 if (!function_defined('mysql_query')) { dl('mysql.so'); }
395 You may wish to ldd all of these .so's.. they will kill the httpd children if
396 they are dl()'d and can't find a library they need (it's better than killing
397 apache altogether though, eh?).
399 Feel free to email me with any questions about this process or using these
400 shared objects. I welcome any suggestions for improving upon this too.