Typo
[linux_from_scratch_hints.git] / OLD / apache+php4+sql.hint.txt
blobf064e3c61eb65ff10435dc1447b28048b7d9aa0f
1 TITLE:          PHP4 hint
2 LFS VERSION:    2.4
3 AUTHOR:         J. Jones <jdj@darkside.dynup.net>
5 SYNOPSIS:
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).
8 HINT:
9         Version:        1.0-test1
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.
17 Apache
18   http://httpd.apache.org/dist/
20 PHP
21   http://php.net/downloads.php
23 MySQL
24   Seemingly the most popular free SQL server
25   http://www.mysql.com/downloads/
27 PostGreSQL
28   Excellent free SQL server
29   http://postgresql.readysetnet.com/sites.html
31 Berkeley DB3
32   Screw SQL, use this!
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/
39     zlib
40       Compression library
41       ftp://ftp.freesoftware.com/pub/infozip/zlib/
43     libjpeg
44       Jpeg library
45       ftp://ftp.uu.net/graphics/jpeg/
47     libpng
48       PNG library
49       ftp://ftp.libpng.org/pub/png/src/
51     libungif
52       Patent-free gif library
53       ftp://prtr-13.ucsc.edu/pub/libungif/
55     libttf/libfreetype
56       True Type font library (YOU WANT THIS!)
57       http://freetype.sourceforge.net/
59 OpenSSL
60   Wonderful encryption library
61   http://www.openssl.org/
63 mhash
64   Provides access to several hashing algorithms
65   http://mhash.sourceforge.net/dl
67 (lib)mcrypt
68   Provides access to several encryption schemes
69   http://mcrypt.hellug.gr/
71 readline
72   GNU readline (It's what makes bash so cool)
73   ftp://ftp.gnu.org/gnu/readline/
75 pspell
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 :)
80   WU's imap library
81   ftp://ftp.cac.washington.edu/imap/old/imap-2000c.tar.Z
83 Curl
84   Client URL library
85   http://curl.haxx.se/download.html
87 libxml
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
92 LDAP
93   LDAP server and library
94   http://www.openldap.org/software/download/
96 zziplib
97   The zlib of zip files
98   http://zziplib.sourceforge.net/
100 =====================================
101 Where to start...
103 ----------------
105 APACHE
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
113                 ./configure \
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.
131 ----------------
134         
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.
147         make all install
149 ----------------
151 Imap
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:
161         chmod a+x Build-me
162         ./Build-me
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
166 file created by:
167         make clean
168         ./Build-me >WU-imap.sucks 2>&1
169 and I'll see what I can do.
171 ----------------
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:
183         ./configure \
184         --prefix=/path/to/apache \
185         --with-config-file-path=/path/to/apaches/conf/files \
186         --with-apache=/path/to/apache \
187         --disable-pear \
188         --without-mysql \
189         --disable-xml \
190         --without-pcre-regex \
191         --disable-posix \
192         --with-openssl=/path/to/openssl \
193         --enable-trans-sid
194         make all install
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.
209 PHP CGI interpreter:
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:
217         make distclean
218         ./configure \
219         --prefix=/usr/local \
220         --with-config-file-path=/usr/local/etc \
221         --enable-force-cgi-redirect \
222         --enable-discard-path \
223         --disable-pear \
224         --without-mysql \
225         --disable-session \
226         --without-pcre-regex \
227         --disable-posix \
228         --disable-xml \
229         --with-openssl=/path/to/openssl
230         make all install
232 You will now have a /usr/local/bin/php command line interpreter.
235 PHP's extras:
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.
246 ./configure options  
247         --with-apache=/usr/local/apache == Path to apache 
248                 source tree, build as apache module
250 Database stuff... 
251         For MySQL support...
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!
261 For GD support...
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
266             here
267         --with-t1lib=/usr/X11R6  ==  use type 1 fonts,
268             and prefix is here
269         --enable-gd-imgstrttf
270         --enable-gd-native-ttf
272 Encryption and compression stuff...
273         For mhash...
274                 --with-mhash=shared,/usr  ==  use mhash, prefixed here
275         For mcrypt...
276                 --with-mcrypt=shared,/usr  ==  use mcrypt, prefixed here
277         For zlib...
278                 --with-zlib=shared,/usr  ==  use zlib functions, and it's prefixed here
279         For bzip2...
280                 --with-bz2=shared,/usr  == bzip2!
281         For zziplib
282                 --with-zziplib=shared,/usr == zzip!
284 Imap support...
285         --with-imap=shared,/prefix/to/imap/  == enable the imap functions
286         --with-imap-ssl=/path/to/openssl  == add ssl support!
288 Miscellaneous...
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 
309             (builtin)
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
319 to fix the paths.  ;)
321         ./configure \
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 \
326         --with-db3=/usr \
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 \
348         --with-gmp=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 \
356         --with-xml=shared \
357         --enable-wddx=shared \
358         --with-domxml=shared,/path/to/libxml \
359         --enable-ftp=shared \
360         --enable-sockets=shared \
361         --enable-yp=shared \
362         --enable-dbase=shared \
363         --enable-exif=shared \
364         --disable-nls \
365         | tee ~/php-config.log
367 This script tends to fly by fairly quick.. so check the ~/php-config.log for
368 the results.
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
384 source directory to
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'); }
393         Please note the ! :)
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.
401 ----------------