HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit system)

Problems with the Linux version of XAMPP, questions, comments, and anything related.

HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit system)

Postby syntax_error » 09. February 2010 21:02

PHP 5.2.* is still very common on shared hosts and the XAMPP 1.7.1 (last version with PHP 5.2 series) unfortunately came with nasty bug in libxml2.

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
as root (add sudo before the command on Ubuntu).

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.
syntax_error
 
Posts: 14
Joined: 09. February 2010 19:24

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit system)

Postby dmartin » 16. February 2010 17:47

Hi,

I will try the procedure as soon as possible.

However, I need the MySqli librairies which are included from version 5.3 (that's what I've been told)
What do I need to change to compile PHP 5.3 ?

Is there any way to add Mysqli to my current version of PHP ?

Thank you !
dmartin
 
Posts: 2
Joined: 16. February 2010 17:43

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit system)

Postby syntax_error » 16. February 2010 23:47

dmartin wrote:However, I need the MySqli librairies which are included from version 5.3 (that's what I've been told)
What do I need to change to compile PHP 5.3 ?
Is there any way to add Mysqli to my current version of PHP ?


According to documentation, MySQLi is available since PHP 5.0. If you compile PHP 5.2 with parameters in this howto, you will get MySQLi support - take a closer look, there's --with-mysqli=/opt/lampp/bin/mysql_config option in the ./configure parameters.

However, if you are only looking for MySQLi support and/or PHP 5.3, you don't need to compile anything at all. XAMPP comes with the latest PHP 5.3 with MySQLi support out of the box. If you have troubles getting MySQLi to work, it's another topic; search the forum or start another thread please.
syntax_error
 
Posts: 14
Joined: 09. February 2010 19:24

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit system)

Postby dmartin » 17. February 2010 10:53

Hi,

Yes you're right, I don't need to recompile PHP. Actually my problem was coming from something else, I guess it's because there was PHP 5 installed on my computer AND PHP installed from LAMPP.
I have re-installed PHP using KPackageKit, and configured the php.ini correctly.

Thank you and sorry for the wrong post !

Denis.
dmartin
 
Posts: 2
Joined: 16. February 2010 17:43

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit system)

Postby tribe_of_dan » 07. July 2010 04:01

Hi,

I just tried this in ubuntu 10.4 LTS amd64...

The compile didn't work... config.log gave me this output.

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

configure:1888: checking for Cygwin environment
configure:1904: cc -c -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 conftest.c 1>&5
configure: In function 'main':
configure:1900: error: '__CYGWIN32__' undeclared (first use in this function)
configure:1900: error: (Each undeclared identifier is reported only once
configure:1900: error: for each function it appears in.)
configure: failed program was:
#line 1893 "configure"
#include "confdefs.h"

int main() {

#ifndef __CYGWIN__
#define __CYGWIN__ __CYGWIN32__
#endif
return __CYGWIN__;
; return 0; }
configure:1921: checking for mingw32 environment
configure:1933: cc -c -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 conftest.c 1>&5
configure: In function 'main':
configure:1929: error: '__MINGW32__' undeclared (first use in this function)
configure:1929: error: (Each undeclared identifier is reported only once
configure:1929: error: for each function it appears in.)
configure: failed program was:
#line 1926 "configure"
#include "confdefs.h"

int main() {
return __MINGW32__;
; return 0; }
configure:1952: checking for egrep
configure:1967: checking for a sed that does not truncate output
configure:2117: checking host system type
configure:2138: checking target system type
configure:2250: checking for gcc
configure:2363: checking whether the C compiler (gcc -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 ) works
configure:2379: gcc -o conftest -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 conftest.c 1>&5
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.3/libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.3/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status
configure: failed program was:

#line 2374 "configure"
#include "confdefs.h"

main(){return(0);}


I'm fairly new to linux so I'm not sure the way forward. Can anyone help?
tribe_of_dan
 
Posts: 1
Joined: 07. July 2010 03:54

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit system)

Postby fidoboy » 09. August 2010 19:52

Thanks for the guide, i've followed it but after compiling php libxml is 2.7.2 version again, so php was compiled using that version instead the newer 2.7.3. What am i doing wrong?

NOTE: i'm using xampp 1.7.3a on 32bit system.

regards,
fidoboy
 
Posts: 3
Joined: 25. January 2010 02:08

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit sys

Postby russellhoff » 16. May 2011 12:51

A great FAQ which is essential. Xampp developers should do another similar to yours...

!!
russellhoff
 
Posts: 6
Joined: 28. October 2010 11:51
Location: Laudio, Basque Country

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit sys

Postby phptwister » 03. February 2012 15:20

Hello.

I know this topic is a little bit old, but I seriously have checked through a dozen of topics around the internet and came up with no solution. I've tried to use this tutorial to successfully compile PHP 5.3.10 on my Ubuntu x64 system with LAMPP.
However, as the OP states, I do get an error saying:
Code: Select all
ext/gd/libgd/.libs/gdkanji.o: In function `do_convert':
gdkanji.c:(.text+0x80b): undefined reference to `libiconv_open'
gdkanji.c:(.text+0x8b7): undefined reference to `libiconv'
gdkanji.c:(.text+0x93d): undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
root@dpc:~/Downloads/php-5.3.10#


I have tried to play with the CFLAGS and the -L dirs, but to no avail, they all provide me the same errors.
I have all the needed libs on my system, so I don't know where to start.

Can anyone help me out on this one? I'm really desperate to change the PHP version on my LAMPP installation.
phptwister
 
Posts: 7
Joined: 17. December 2011 23:43
Operating System: Ubuntu 11.10

Re: HOWTO: Compiling latest PHP 5.2 for XAMPP (on 64-bit sys

Postby JonB » 11. February 2012 01:30

OK - you wanted answers - I can only give my own...

Basically - there is no point in attempting this as you will need to 'fix' everything. You will probably need a differently tuned php.ini and all the extensions etc as well. This is a huge task, you are basically re-creating the project. Why not pick an older LAMPP to suit your needs? You will find that LAMPP, unlike the XAMPP for Windows, has changed little since 1.6. The reason is that LAMPP is already on 'the right OS' - On Windows, there's the huge "emulation" task to be dealt with - and that is what most of the momentum is about - better Control Panels, newly compiled DLL's (not an issue in a LAMP {not LAMPP} stack).

The whole point of XAMPP as I have said in all the OS forums at various times is that it is a plug and play server suite - XAMPP/LAMPP is not a LAMP stack on Linux and it won't work like one (reasons coming right up). On each OS, its a series of command line executables (on Windows executables can also be services), driven by Control Panels and Scripts (those would be batch files on Windows, and bash/applescripts on Unix/Linux, Solaris and Mac). The OS is totally unaware XAMPP is running, so all the paths you will find in add-on packages, tutorials etc, need to be adjusted manually (sort of infers that you already know how to make [bad pun] everything work. That's the down side.

The up side of this is:
Its a no-brainer install to make it work, and to remove it - you just delete it. You only need know the very most basic things about the OS. About the only exception to this is if you use a Windows Installer (msi) and/or if you make Apache, MySQL, or other components into services under Windows, then you have a tiny cleanup. Also, LAMPP has all the configuration work done for a basic development server, and has a dandy backup script. But everything is driven toward a very tiny subset with pre-defined users and parameters so it can be installed on ANY distrbution kernel without breaking anything. Think about that - I think you know you can't mix and match repos, right?? LAMPP is not like that - put in place -- ding ding -- werky! That's amazing!!!

Why i don't encourage people to do this (modify XAMPP/LAMPP):
It used to be you needed a lot of knowledge at the Command lIne level to make a LAMP stack work. That's just no longer true. Now with well designed installers/setup tools, and 'baked for you' repositories, you almost can't miss just about any distribution. Yast, yum and apt-get have taken all the mystery out of getting a stack running. I did an experiment when I set up my LAMPP box - I built a stack on the same distribution - fedora 15 using yum. Guess what - almost no difference in setup effort. I also discovered that because LAMPP is SO different, if you want to do things outside the box, you have a BIG learning curve. You should have to read through the entire lampp script before you can install, otherwise EVERYTHING IS A MYSTERY. (like the old MS licenses with the F8 at the end). So my conclusion was you need MORE Linux knowledge to make LAMPP do tricks than a standard stack.

The other part of the equation is that there's a lot less interest consequently in LAMPP as a result of the last.

A fair question would be - why have LAMPP then - answer is: (ding) the Linux variants of everything are created FIRST, then ported, as all the constituent pieces originate and are tested and debugged in pure Linux environments. Thus there will always be a LAMPP, as that is teh starting point.

My role here is to facilitate people with the matter of getting LAMPP to work, as it comes out of the box, which I am happy to do. I'm not the only one that has Linux knowledge here, and I'm not preventing anyone from responding or deleting answers (and I know there are a couple of other very expert linux types on this forum). So I'm not the only one who passed.

I need to ask a fair (in my opinion) question - have you spent the time to read through and analyze the lampp script that runs the whole shooting match??? If you have - then Bravo!, as that is the way of power. If not, you should (as that will be key to making things work later).

The bottom line (in my opinion only) on this question -- if you want to experiment on Linux use a standard stack. and plan on being mystified at times, that's just the way things are.

I wish you good luck, and I think you are genuinely interested, but I can't be disingenuous and say "that's a great idea" either.

OK?

8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 31 guests