The goal here is to compile the latest version of PHP 5.2.* (currently 5.2.12) against the latest version of XAMPP package (currently 1.7.3a), which i.a. solves the mentioned bug. Also many of us are running 64-bit operating system so we will have to cross compile PHP, because XAMPP is 32-bit only - but compilation on 32-bit differs only in few details.
I am running Ubuntu 9.10, the process may slightly differ depending on your distribution.
What do you need
- GCC and related tools (in Ubuntu use build-essential package)
- 32-bit compatibility libraries (package ia32-libs in Ubuntu).
- Latest XAMPP for Linux installed, including development package!
- Latest PHP source, 5.2.something (5.3 has different build options)
Configure / compile / install
Extract PHP source package anywhere in your system, possibly in your home directory or /tmp.
Open the console in the extracted directory (cd php-5.2.*).
Now we will execute ./configure script with PHP options and some extra variables:
- Code: Select all
env CFLAGS="-m32 -O6 -I/opt/lampp/include/libpng -I/opt/lampp/include/ncurses -I/opt/lampp/include -L/opt/lampp/lib -L/opt/lampp/lib/mysql -L/usr/lib32" ./configure --prefix=/opt/lampp --with-apxs2=/opt/lampp/bin/apxs --with-config-file-path=/opt/lampp/etc --with-mysql=/opt/lampp --enable-inline-optimization --disable-debug --enable-bcmath --enable-calendar --enable-ctype --enable-dbase --enable-discard-path --enable-exif --enable-filepro --enable-force-cgi-redirect --enable-ftp --enable-gd-imgstrttf --enable-gd-native-ttf --with-ttf --enable-magic-quotes --enable-memory-limit --enable-shmop --disable-sigchild --enable-sysvsem --enable-sysvshm --enable-track-vars --enable-trans-sid --enable-wddx --enable-yp --with-ftp --with-gdbm=/opt/lampp --with-jpeg-dir=/opt/lampp --with-png-dir=/opt/lampp --with-freetype-dir=/opt/lampp --without-xpm --with-zlib=yes --with-zlib-dir=/opt/lampp --with-openssl=/opt/lampp --with-expat-dir=/opt/lampp --enable-xslt=/opt/lampp --with-xsl=/opt/lampp --with-dom=/opt/lampp --with-ldap=/opt/lampp --with-ncurses=/opt/lampp --with-gd --with-imap-dir=/opt/lampp --with-imap-ssl --with-imap=/opt/lampp --with-gettext=/opt/lampp --with-mssql=/opt/lampp --with-sybase=/opt/lampp --with-mysql-sock=/opt/lampp/var/mysql/mysql.sock --with-mcrypt=/opt/lampp --with-mhash=/opt/lampp --enable-sockets --enable-mbstring=all --with-curl=/opt/lampp --enable-mbregex --enable-zend-multibyte --enable-exif --with-bz2=/opt/lampp --with-sqlite=shared,/opt/lampp --with-libxml-dir=/opt/lampp --enable-soap --enable-pcntl --with-mysqli=/opt/lampp/bin/mysql_config --with-mime-magic --with-iconv --enable-dio --with-pdo-mysql=/opt/lampp --with-pdo-sqlite --with-ming=shared,/opt/lampp
Whole command is only one line. Paste it inside terminal (Ctrl+Shift+V in e.g. Gnome Terminal, Shift+Insert possibly in others) and press enter.
If you don't get any errors, you may proceed by:
- Code: Select all
make
and finally
- Code: Select all
make install
If everything goes well, (re)start lampp and enjoy your fresh new PHP.
Notes
- I have omitted support for Interbase, PostgreSQL and Oracle - if you don't have those installed, configuration may fail. If you need those, use following options with the above ./configure command:
- Code: Select all
--with-interbase=shared,/opt/interbase --with-pgsql=shared,/opt/lampp/postgresql --with-pdo-pgsql=/opt/lampp/postgresql --with-oci8=shared,instantclient,/opt/lampp/lib/instantclient
- If you are compiling on 32-bit system, omit the following options from the command: -m32 -L/usr/lib32
- 32-bit libraries may be placed in different location on your system, change the part -L/usr/lib32 accordingly
For the future reference, you can use lampp/bin/php-config script (from the stock XAMPP) to get config options - useful lines are ldflags and configure_options.
Troubleshooting
If the ./configure complains about missing packages, make sure you have installed XAMPP development package. Then search your distribution package repository for the development packages or libraries - again, even on 64-bit system you need 32-bit libraries to compile XAMPP.
Probably best place to ask is community of your distribution, they can point you at the right package.
If make fails with an error like:
- Code: Select all
could not read symbols: File in wrong format
collect2: ld returned 1 exit status
It's probably because compiler is trying to link to 64-bit package. Check the CFLAGS part before the ./configure command, especially options starting with -L. Make sure you have included XAMPP's lib directories (/opt/lampp/lib and /opt/lampp/lib/mysql) and another option points at directory with 32-bit libraries in your system (/usr/lib32).
Kudos to klein web from #Apachefriends for pointing me to ld flags and Oswald for the proper way of changing lib dirs.