Hello Chris and Interworx users,
One of our common clients had come to me for assistance with the compilation of PHP5 on his IWorx machine with the hope of using Auracle Support Engine, our helpdesk (which forces the PHP5 requirement) in conjunction with whois.cart(). Being that I always advocate source compilation, the steps that follow describe the steps taken to successfully compile PHP5 from source.
1. CONFIG :The first step usually involves lifting a compilation command from the phpinfo output. Usually, this config directive is re-usable (since one assumes that it figures in the PHP info directive because it was successful in the first place). Unfortunately, with the PHP config installed by Interworx RPM, this isn’t the case. Some doctoring is at hand. The final result:
./configure --with-apxs2=/usr/sbin/apxs --prefix=/usr --bindir=/usr/bin --mandir=/usr/share/man --disable-debug --disable-rpath --with-bz2 --with-db4=/usr --with-curl --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-gd --with-gdbm --with-gettext --with-ncurses=shared --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-png --with-xml --with-expat-dir=/usr --with-dom --with-dom-xslt --with-dom-exslt --with-xmlrpc --with-readline --with-pcre=/usr --with-zlib --with-pear=/usr/share/pear --with-mhash --with-ldap --with-mcrypt --with-mysql=/usr --with-unixODBC=/usr --with-pgsql --without-oci8 --with-snmp=/usr --enable-ucd-snmp-hack --enable-bcmath --enable-exif --enable-ftp --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path --enable-yp --enable-wddx --enable-memory-limit --enable-bcmath --enable-shmop --enable-calendar --enable-dbx --enable-dio --enable-mcal --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --enable-inline-optimization --enable-gd-native-ttf --enable-pic
Note that these directives must exist on a single line. These aren’t my settings of choice, but simply a replication of the environment that was specified by the Interworx PHP4 build that was operational at the time.
2. PREP: Set up a home base, I usually mkdir /devel and work from there. Save your phpcompile file into that folder, and cd /devel
3. APR: One of the problems on the box in particular was that the php compilation would fail with a missing apu-config command (which is commonly installed alongside httpd-devel in my experience). It appears that it was dissociated in this case, so the installation of apr was necessary. Let me interject, I hate RPMs, but gave them a try this time…disastrous failure - the dependencies trickle down into db4 which is required by too manythings. If I can offer any timesaving advice, go get the source instead; which bides the steps that follow:
3a. wget http://apache.mirrored.ca/apr/apr-0.9.7.tar.gz
3b. tar -zxf apr-0.9.7.tar.gz
3c. cd apr-0.9.7
3e. make && make install
3f. cd …
3f. wget http://apache.mirrored.ca/apr/apr-util-0.9.7.tar.gz
3g. tar -zxf apr-util-0.9.7.tar.gz
3h. cd apr-util-0.9.7
3i. ./configure --with-apr=/usr/local/apr/bin/apu-config
3j. make && make install
3k. cd …
3l. create a symlink to apu-config on your system to /usr/bin:
ln -s /usr/local/apr/bin/apu-config /usr/bin/apu-config
4. PHP SOURCE: Time to get the PHP source from php.net, from your /devel:
4a. wget http://ca.php.net/get/php-5.1.2.tar.gz/from/www.php.net/mirror
4b. tar -zxf php-5.1.2.tar.gz
4c. cp phpcompile ./php-5.1.2/phpcompile
4d. cd php-5.1.2
4e. chmod 700 phpcompile
The system will attempt to configure your php compilation using the flags in the phpcompile file above. Note that this varies on a per-system basis, if you run into problems, make sure that the options in your phpcompile flag can be ‘backed’. That is if you have --with-mysql in there, make sure that your mysql is actually installed! You can get away with stripping options whose components are missing - just make sure you don’t strip anything that interworx needs. Sometimes it’s just a game of specifying the right path to the component, see the config file directives section at php.net for more info.
4g. If the compile command is successful, issue: make && make install
5. Preparing HTTPD: There seems to be a BSD-style config file system going on on these IWorx machines. When running make install on the PHP source, it’ll automagically add the LoadModule directive to your /etc/httpd/conf/httpd.conf. Thus,
5a. pico /etc/httpd/conf.d/php.conf and comment out:
#LoadModule php4_module modules/libphp4.so
5b. pico /etc/httpd/conf/httpd.conf and make sure that the only “LoadModule phpX” module that’s there, is the one that loads PHP5. I prefer to leave it in httpd.conf - otherwise, PHP will continuously add that line upon recompilation. One could argue that I could have specified the config-file path in the config directive. In defense, where one’s fingers are already overworked, all this extra typing seems…unsurmountable…defaults are good.
6. ZEND OPTIMIZER : Download Zend Optimizer from zend.com - it’s a free download. Unpack, and access its directory to issue: ./install-tty.sh Follow the steps prescribed, it’s pretty painless. The ZO installer will ask you for the default location for php.ini, on this machine, it was in /etc/php.ini. ZO’s installer usually figures out the rest on its own (presents the options as default values).
6a. Not sure if this is an Interworx requirement, but I didn’t change it to be on the safe side - PHP apparently expected php.ini to be in /usr/bin. Thus, symlink it:
ln -s /usr/local/Zend/etc/php.ini /usr/lib/php.ini
7. PHP.INI CLEANUP : pico /usr/local/Zend/etc/php.ini. Few strange things I saw, not sure if these are Interworx required/related…but perhaps worth mention:
-consider setting extension_dir to the standard /usr/lib/php/extensions/ instead of local values (.) which could permit your users to load .so objects from their home directories!
-consider turning mysql persistent links OFF. These are a waste - the resources required to spawn a thread on mySQL are FAR less than the resources used to maintain persistent links.
7a. For use with Auracle, which requires mailparse, add the line:
extension = mailparse.so
To the dynamic module section
Save your php.ini
If you specified Mailparse should be loaded, issue:
pecl install mailparse
Then copy mailparse.so from /usr/lib/php/extensions/no-debug… to /usr/lib/php/extensions/
8. RESTART APACHE:
service httpd restart
In this case, everything worked.
There are great benefits to installing from source, when PHP 5.1.3 comes out for example, all you’ll need to do is unpack the archive, copy your phpcompile file from your 5.1.2 directory to the 5.1.3 source directory and issue ./phpcompile, make && make install, and then restart apache. Easy 123!
In any case, I hope this helps a few of you, I saw some many conjectural comments circumambulating the topic of upgrading to PHP5 on your boxes in these forums whilst investigating for int - hopefully this’ll demystify the issue. I’d add that PHP5 is leaner, faster and much more powerful than PHP4, and that “well-written” PHP4 code (ie. no self-assignment of $this variables etc.) will not break on the crossover. IMHO, code that does break, breaks because it needs a rewrite. Now armed with your new setup, your Apache and PHP5 can rule the galaxy as Luke and Darth might have done had he accepted. Hope this helps!
(diagnostics pack to help out, at http://auraclesupport.com/requirements.php)