Tales of an IT Nobody

devbox:~$ iptables -A OUTPUT -j DROP

Running parallel versions of PHP – Part 1 May 14, 2009

With RC2 of the php5.3 release coming out, I wanted to run the new version alongside the stable version on our development server at M State. I wanted to be able to control this behavior via .htaccess files to control particular projects.

What you’ll need:

  • Reasonable compiling experience
  • Ability to satisfy dependencies
  • Understanding and access to your httpd.conf and to be able to reload/restart apache.

Do NOT compile now unless you completely understand how to install to a directory other than the default!

Start off by downloading and extracting the source and cd into the extracted directory.

Getting ready to configure:

Before you configure, make sure you know which modules you want.
These are enabled by the myriad of --with-gd type switches.
If you don’t know what modules you have, run phpinfo(); and look for the configure string – OR you can try the command line tool php-config (or) php5-config if it’s been installed.

Prefix (*important*)
You’re not going to want php to be installed into the default path, this will rewrite your stable php5. Instead you want it to go into a custom directory – You can do this by setting the --prefix option when you run configure

Example: ./configure --prefix=/home/rovangju/misc/php53

Using current php.ini (Optional, recommended)
Change the paths to wherever your php.ini file is located. If you’re running older php and don’t have the conf.d folder – don’t use that line. This step may save you any nuances setup in your php.ini files.

--with-config-file-path=/etc/php5/apache2 \
--with-config-file-scan-dir=/etc/php5/apache2/conf.d \

Configuration summary
Now we’re ready to run the gauntlet of trying to configure and build. Expect to fulfil dependencies. At a minimum our configure will look like this: ./configure --prefix=/path/you/want

When/if your ./configure throws up that a library isn’t found – this is the least fun part when you have to install the dev libraries for those modules. So if your getting an error about libxml2 – You’ll likely want to install libxml2-dev. If you use apt this can be handy: apt-cache search libxml2 | grep "dev" – once you’ve installed it, try the configure again. It took me about half an hour of configure and installing the dev libs …

You can see my configure string as a comment to this post for example.

Continue to Part 2 when your configure doesn’t throw errors!
Categories: apache php
  • ./configure –prefix=/home/rovangju/misc/php53 \
    –with-config-file-path=/etc/php5/apache2 \
    –with-config-file-scan-dir=/etc/php5/apache2/conf.d \
    –build=i486-linux-gnu \
    –host=i486-linux-gnu \
    –disable-debug \
    –with-regex=php \
    –disable-rpath \
    –disable-static \
    –with-pic \
    –with-layout=GNU \
    –enable-calendar \
    –enable-json \
    –enable-suhosin \
    –enable-sysvsem \
    –enable-sysvshm \
    –enable-sysvmsg \
    –enable-bcmath \
    –enable-ctype \
    –without-gdbm \
    –with-iconv \
    –enable-exif \
    –enable-ftp \
    –with-gettext \
    –enable-mbstring \
    –with-pcre-regex \
    –enable-sockets \
    –enable-simplexml \
    –enable-wddx \
    –enable-tokenizer \
    –with-zlib \
    –with-openssl=/usr \
    –enable-soap \
    –enable-zip \
    –with-system-tzdata \
    –without-mm \
    –with-curl=shared,/usr \
    –with-gd=shared \
    –enable-gd-native-ttf \
    –with-jpeg-dir=shared,/usr \
    –with-xpm-dir=shared,/usr/X11R6 \
    –with-png-dir=shared,/usr \
    –with-freetype-dir=shared,/usr \
    –with-ttf=shared,/usr \
    –with-t1lib=shared,/usr \
    –with-ldap=shared,/usr \
    –with-ldap-sasl \
    –with-mcrypt=shared,/usr \
    –with-mhash=shared,/usr \
    –with-mysql=shared,/usr \
    –with-mysql-sock=/var/run/mysqld/mysqld.sock \
    –with-mysqli=shared,/usr/bin/mysql_config \
    –with-xsl=shared,/usr \
    –with-snmp=shared,/usr \
    –with-tidy=shared \

Leave a Reply

Your email address will not be published. Required fields are marked *