in PHP 5

Installing PHP 5.3 On Ubuntu

With the release of PHP 5.3 to the world, I wanted to be one of the first to try it. The problem is that the typical package managers for Ubuntu won’t include PHP 5.3 for some time – perhaps as long as a year. This is a problem, since I really want to try PHP’s latest and greatest features for myself.

The problem is, there seems to be a lack of clear, coherent instructions online about compiling PHP on Ubuntu from source. Either it’s so insanely simple that anyone who does it figures everyone else knows how, or everyone relies on the pre-built binaries released by the world that any time I search for “Ubuntu PHP source” I get “why don’t you just use the built-in package manager?” And so, I wanted to write a set of instructions for how I configured and compiled PHP, on Ubuntu Jaunty.

For the most part we’ll use standard out-of-the-box packages that Ubuntu provides. Since the features I’m looking for are in PHP 5.3, I’m fine with having slightly outdated packages for other software as long as they’re compatible with PHP 5.3.

Warning!!!! WordPress has added HTML entities in order to help display this post. Do NOT copy and paste the ./configure line as it will cause you to get strange results. Prepare your own configure line that matches your needs!
Warning: Messing with Apache and PHP on a live web server can cause serious problems! Do this only on a development system or on a system that is not critical to your operation! Trying to install a new version of PHP with a current version running might work, or it might sleep with your wife and eat your children. You’ve been warned!
Warning: Remove any existing instances of PHP, either compiled from source or installed by package, and all related files, before proceeding!

1. Install Apache.

The first step is to install Apache. You can feel free to use your own web server, but for this example I opted for Apache based on the simplicity of installing PHP as an Apache module. This command should also install the development tools, which PHP will need to properly configure itself for Apache.

aptitude install apache2 apache2-mpm-prefork apache2-prefork-dev apache2-utils apache2.2-common

2. Install MySQL and PostgreSQL

Most people use MySQL, but almost all PHP installations seem to have PostgreSQL installed as well. I think it’s always good to keep your options open, and you might take a look at Postgres at some point. If you opt not to install Postgres, that’s fine; just alter your configure statement to exclude it.

aptitude install postgresql-8.3 postgresql-client-8.3 postgresql-client-common postgresql-common postgresql-server-dev-8.3

aptitude install mysql-client mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 mysql-server-core-5.0

3. Install required libraries

PHP itself is very easy to configure and install. However, if you want to get the most out of it you’ll need to install the dependency libraries it uses for various functions like mcrypt and gd. This can be the most challenging part of installing PHP; many hours can be spent issuing a configure command only to have it fail, have to install another library, and repeat the process.

These libraries are the libraries that were needed to install the options in the configure statement below. You may need more or fewer libraries depending on your individual needs and desires.

aptitude install libtidy-dev curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 libfreetype6-dev libbz2-dev libxpm4-dev libmcrypt-dev libmcrypt4

4. Download the PHP Source Code

Visit http://www.php.net and download the latest version of PHP 5.3. The following commands may be helpful:

cd ~
wget http://us3.php.net/get/php-5.3.0.tar.gz/from/this/mirror
tar xvfz php-5.3.0.tar.gz

5. Configure.

Change your working directory to the unpacked PHP source code. Execute the following command.

./configure –with-apxs2=/usr/bin/apxs2 –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –with-pgsql=/usr –with-tidy=/usr –with-curl=/usr/bin –with-curlwrappers –with-openssl-dir=/usr –with-zlib-dir=/usr –enable-mbstring –with-xpm-dir=/usr –with-pdo-pgsql=/usr –with-pdo-mysql=/usr –with-xsl=/usr –with-ldap –with-xmlrpc –with-iconv-dir=/usr –with-snmp=/usr –enable-exif –enable-calendar –with-bz2=/usr –with-mcrypt=/usr –with-gd –with-jpeg-dir=/usr –with-png-dir=/usr –with-zlib-dir=/usr –with-freetype-dir=/usr –enable-mbstring –enable-zip –with-pear

Edit: Many commenters suggested using the –prefix=PREFIX directive to place your PHP files and limit the potential problems should you decide to remove or replace PHP. This is a good idea.

The screen should scroll quickly as it does a check of the files and libraries it will need for compiling, and, if everything is installed correctly, it will build the makefiles for the next step. If it fails, it will give you an error message (usually related to a missing library) and tell you to try again.

6. Make & Make Install

In order to have PHP installed, we have to first compile it from the source code. This involves the compiler accessing the libraries it needs. Once compiled, we’ll be able to install it. The first command in this process is easy enough:

make

There will once again be a lot of information on your screen. Take your time, go for a walk. This takes a bit of time, and the more you compile into PHP the longer the process takes. PHP is an advanced, complicated language, so be patient.

Once it completes successfully, you should see a warning to run “make test”. You may run this, though you don’t have to at this stage.

The final step in the PHP compilation process is invoking the installer.

make -i install

Why do we use -i on the installer? Ubuntu uses an unusual configuration for Apache which causes the installer not to know how to install PHP properly. This will produce a fatal error and cause the install to stop. The -i flag tells it to ignore the errors; we’ll set up Apache to use PHP 5.3 next.

7. Add the PHP Module to Apache

In order to have PHP run as a part of the web server, we’ll need to create a module for it. This is typically done automatically, but due to the unusual setup of the Ubuntu Apache installation, we’ll have to do it ourselves.

First, change directories:

cd /etc/apache2/mods-available

Create a new file called php5.load and paste the following line into it:

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

Save that file. Now create another file called php5.conf and paste the following into it:

AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps

Now we’re all set! We just need to enable the module and restart Apache:

# a2enmod php5
Enabling module php5.
Run ‘/etc/init.d/apache2 restart’ to activate new configuration!
# /etc/init.d/apache2 restart
* Restarting web server apache2
… waiting …done.

8. Test the PHP Installation

Now we just need to see that PHP is in fact installed!

First let’s check the PHP binary:

$ php -v
PHP 5.3.0 (cli) (built: Jul 1 2009 18:53:06)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

If you get output similar to the above, your PHP installation is correct. Note that the point release may be different since these directions were written; however, you should see PHP 5.3.x as the version.

Next, let’s get the info from PHP to see what’s installed. Find your webroot, create (or edit) an index.php file and add the following:

<?php

phpinfo();

?>

Type the URL of your web server into the browser and you should see something that looks like this:

phpinfo

If you do, congratulations! You’ve successfully installed PHP 5.3 on Ubuntu from source.

Be the first to get Modern Object-Oriented PHP!

Long to learn how you can develop modern applications using object-oriented PHP? Curious about how to apply all these best practices to your code?

Modern Object-Oriented PHP is a brand-new book focused on teaching you the techniques you need for writing modern, well-designed object-oriented applications!

The book lands in April. Sign up today for a sample chapter plus special launch day discounts!

Powered by ConvertKit

53 Comments

  1. Greetings, Brandon.

    Kudos on the excellent article. I’m using Kubuntu 9.04 here and I’m preparing myself to install PHP 5.3 as you describe, but I’ve already found one problem:

    apt-get states that there’s no package for libxpm4-dev, but there’s one named libxpm-dev. Would that be enough?

    Tia,

    Galvao

  2. If one would like to test PHP5.3 on some machine prior to updating the version on the system and there is already PHP5.2 installed, just need to put non-default installation path in ./configure –prefix=INSTALLATION_PATH in order to install it away from default PHP installation path. This way there could be more versions on the system, and also some scripts could help to automatically switch between versions on Apache and in CLI.

  3. Good stuff, just one suggestion: I would have added a prefix to ./configure so it installs PHP into a single path and it’s easier to get rid off the source install later on in order to replace it with a “official” package.

    A prefix would also mean that it’s hard (if not impossible) for the installs to conflict with one another — e.g., say you had multiple (different) versions.

  4. Great write-up, this will save many people quite a bit of time ;-)

    I have built my PHP5.3 environment a few weeks ago, also on Ubuntu, and had this article to help me shortcut the dependency issues:

    http://phpmelb.org/articles/installing-php-53/

    In that article, the author describes the creation of a dummy httpd.conf file, so that the installation won’t fail because the script can’t find the LoadModule directives. I did not see any such mention in your post, so I was wondering why your method works. Whenever I forgot to do this, the install failed.

  5. Ah, I see it now: The “-i” option does the trick – maybe I should read posts thoroughly before I comment on them :-P

  6. @Galvo: Yes, that should be sufficient. If not, search with “aptitude search libxpm” and you can find some packages.

    @Christopher: Thanks for the repo info. I’ve looked for a long time. Still, I’m happy to compile from source as it gives me much more control.

  7. A fairly handy feature of apt-get allows you to pull in all the dependencies required to build a particular package in one shot. So, if you’re compiling a PHP which has roughly the same setup as the default Ubuntu one, do:

    sudo apt-get build-dep php5

    to grab all the compilers, -dev packages, etc. You can probably then do

    sudo apt-get autoremove

    later on to get rid of the -dev packages if you don’t want them on there any more. I’d highly recommend using “configure –prefix=$SOMEWHERE” (my $SOMEWHERE is normally somewhere in /opt) to keep out of the way of the system PHP, to avoid breakage. Even better, use dotdeb.org’s packages and save all of the above mentioned hassle.

  8. Michael, you make a good point regarding dependencies. The problem I’ve found is that PHP itself is easy to install; it’s the added extensions that require libraries. For most people, simply doing ./configure & make & make install will install PHP just fine. It’s not until you want to add MySQL and PostgreSQL and gd and…

    A note on the prefix: this does make it easy to remove the package if you ever decide to upgrade. However, it will require more configuration in the long run as some of the PHP utilities (PECL) will need your help to find the files they’re looking for.

  9. hey Brandon, thanks for the simple steps it all worked out perfectly.

    however, I just cannot seem to install APC.
    “sudo pecl install apc” fails on make, any ideas?

    thanks.

  10. My suggestion would be to download the package itself and compile it from source. You can use phpize to create a configure file and then run ./configure & make & make install. APC isn’t dependent on any libraries so it shouldn’t have issues with make; you might Google the error you’re getting and see what the problem is.

  11. @Hussein: You probably tried to install the latest stable version of APC, 3.0.19. There are newer versions available that have better support for PHP 5.3, but are considered Beta. You have to set the pecl installer to accept beta packages to install them:

    pecl config-set preferred_state beta
    pecl install APC

    …then it should work.

  12. Thanks Markus and Brandon,

    I was able to get APC installed last night with a build from the beta, but for some reason no matter how I compile PHP 5.3, my phpinfo() has nothing in the configure command, it just shows ‘./configure’ and no .inis are loaded.

    I saw your screen shot brandon and you have the same issue with the ini’s loaded. I tried creating php.ini and even chmodding it, but I am not getting any results on loading a php.ini that will in turn enable APC.

    Hussein.

  13. Hussein, here’s what I did to get my php.ini to load:

    1. cp /path/to/source/php.ini-development /usr/local/lib/php.ini
    2. Customize your php.ini file to your liking.
    3. sudo apache2ctl stop
    4. sudo apache2ctl start
    5. Visit a page that invokes phpinfo();

    Let me know if that helps.

  14. Thanks a lot Brandon, everything is working fine now :) just need to add phpmyadmin and I’m all set.

  15. Hi all :)

    This is what I did to make all work on Ubuntu 8.04 x86_64 with workaround because of the bug in gcc 4.2

    apt-get -y install build-essential #this suppose to install g++ and libstdc++
    #####apache stack

    aptitude -y reinstall apache2
    aptitude -y install apache2 apache2-mpm-prefork apache2-prefork-dev apache2-utils apache2.2-common

    #aptitude install postgresql-8.3 postgresql-client-8.3 postgresql-client-common postgresql-common postgresql-server-dev-8.3

    #this will ask for password
    aptitude -y install mysql-server
    aptitude -y install mysql-common
    aptitude -y install mysql-client
    aptitude -y install mysql-server-core

    #### new GCC + libstd

    cd /usr/local/src
    wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.2.4.tar.bz2
    tar -xjf gmp-4.2.4.tar.bz2
    cd gmp-4.2.4
    ./configure
    make
    make install
    make check

    apt-get -y install lib32stdc++6
    apt-get -y install libc6-dev-i386
    apt-get -y install lib32gcc1
    apt-get -y install zip

    cd /usr/local/src
    wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.1.tar.bz2
    tar -xjf mpfr-2.4.1.tar.bz2
    cd mpfr-2.4.1
    ./configure
    make
    make install
    make check

    # vim /etc/ld.so.conf
    # add
    # /usr/local/lib

    # this:
    # /sbin/ldconfig -v
    # will set up the correct links for the shared binaries and rebuild the cache.
    # /sbin/ldconfig -n /lib
    # as root after the installation of a new shared library will properly update the shared library symbolic links in /lib.

    cd /usr/local/src
    wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.4.0/gcc-4.4.0.tar.gz
    tar -xzf gcc-4.4.0.tar.gz
    cd gcc-4.4.0

    make distclean
    ./configure –disable-multilib
    #export LDFLAGS=’-L/usr/lib/gcc/x86_64-linux-gnu/4.2 -R/usr/lib/gcc/x86_64-linux-gnu/4.2′
    make
    make install

    ##### php 5.3 from source
    aptitude -y install libtidy-dev curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 libfreetype6-dev libbz2-dev libxpm4-dev libmcrypt-dev libmcrypt4
    aptitude -y install libxpm-dev
    aptitude -y install libxpm4
    aptitude -y install libmysql++-dev
    aptitude -y install libsqlite

    cd /usr/local/src
    wget http://uk3.php.net/get/php-5.3.0.tar.gz/from/uk2.php.net/mirror
    tar -xvzf php-5.3.0.tar.gz
    cd php-5.3.0

    ./configure -prefix=/usr/local -with-apxs2=/usr/bin/apxs2 -with-mysql=/usr -with-mysqli=/usr/bin/mysql_config -with-pgsql=/usr -with-tidy=/usr -with-curl=/usr/bin -with-curlwrappers -with-openssl-dir=/usr -with-zlib-dir=/usr -enable-mbstring -with-xpm-dir=/usr -with-pdo-pgsql=/usr -with-pdo-mysql=/usr -with-xsl=/usr -with-ldap -with-xmlrpc -with-iconv-dir=/usr -with-snmp=/usr -enable-exif -enable-calendar -with-bz2=/usr -with-mcrypt=/usr -with-gd -with-jpeg-dir=/usr -with-png-dir=/usr -with-zlib-dir=/usr -with-freetype-dir=/usr -enable-mbstring -enable-zip -with-pear
    make
    make test
    make install

  16. Enjoyed the article, Brandon…

    One thing I’d highlight is the make option “-j”, which allows parallelizing the compiling steps. Typical value for the parallel level is “# of CPUs + 1”, so the typical dual-core machine can do “make -j3” to make full use of the CPU. Obviously this will monopolize your CPU, but if you going for coffee while the compilation runs, … ;-)

    I enjoy the speed at which both “make -j5” and “make -j5 test” run on my dual-Xeon box. That “-j” option rocks… I’ve enjoyed it since my Gentoo days.

  17. In case you try to install PHP 5.2.10 instead of PHP 5.3 (because this one is too young to get others updated extensions like ioncube): you should not use –with-curlwrappers if you want to manage to install pear because there is a conflict with curl. See the bug report in php.net : http://bugs.php.net/bug.php?id=48603

  18. Thanks – I fought with this for half a day, before I found your post. Very helpful.

    If you want to use your old (package managed) ini files, you can use the following options:

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

  19. I have the same issue as Hussein; I installed APC using:

    pecl install apc-beta

    Then I added the extension into php.ini:

    extension = apc.so
    apc.enabled =”1″
    apc.max_file_size=”2M”
    apc.slam_defense=”50″
    apc.shm_size = “32”
    apc.shm_segments = 1
    apc.optimization = 0
    apc.num_files_hint = 1000
    apc.ttl = 0
    apc.gc_ttl = 3600
    apc.cache_by_default = 1
    apc.filters = null
    apc.mmap_file_mask = null
    apc.file_update_protection = 2
    apc.enable_cli = 0
    apc.stat = 1

    Then, I killed (and restarted) the server and all php processes. APC doesn’t show in phpinfo and apc.php says:

    “No cache info available. APC does not appear to be running.”

    Any ideas?

  20. Env (Ubuntu 9)
    The install as detailed above worked – I can see that Php works on the Command Line – not so for Apache and libphp5.so

    * Restarting web server apache2
    apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: undefined symbol: OnUpdateLong
    …fail!

  21. (lemme preface my question by saying I’m a linux, MySQL newbie, so thanks for your patience…)

    I noticed (in your instructions) that you install several MySQL packages (aptitude install mysql-client mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 mysql-server-core-5.0).

    What’s the difference between something like mysql-server and mysql-server-5.0 and mysql-server-core-5.0?

    What does each package do or why is it installed for?

    Thanks!
    -Dan

  22. Sounds like something went wrong with your compilation. I’ve never seen the error you’re describing. Make sure your path to apache was right.

  23. Many packages are top-level packages which will install dependencies. For example, mysql-client installs the mysql-client-5.0 which requires mysql-common (shared libraries between the client and the server).

  24. So since mysql-client installs mysql-client-5.0, does the latter still need to be included in the aptitude install statement? (i.e., is there unnecessary duplication in the aptitude install statement?)

  25. Yes and no. I included everything so people wouldn’t ask “why isn’t this thing included?” Installing mysql-client-5.0 will also install mysql-client and vice-versa. However, installing mysql-client will upgrade you to the latest version of mysql-client whenever there’s an update. So it’s up to you.

  26. Thanks for the explanation!

    One last question: Do you know how to do an unattended install of MySQL. I keep getting the whiptail (bluescreen) asking me for a root password to be set.
    I’ve tried adding the following line before doing a apt-get install mysql-server-5.0:
    export DEBIAN_FRONTEND=noninteractive

    I end up getting the same blue screen prompts for a root password.

    I’ve also tried:

    echo “mysql-server mysql-server/root_password select” | sudo debconf-set-selections

    and

    echo “mysql-server-5.0 mysql-server/root_password password password” | sudo debconf-set-selections

    before the install, but they don’t fully work (I get a blue prompt asking me to repeat the password I just set).

  27. Nevermind – I got it to work with the following:

    echo mysql-server-5.0 mysql-server/root_password password PASSWORD | sudo debconf-set-selections
    echo mysql-server-5.0 mysql-server/root_password_again password PASSWORD | sudo debconf-set-selections

    Thanks for all your help in explaining things! It was really helpful!

  28. I followed the step you mention to build php5.3.0, except for not installing postgresql and using
    -with-mysql=shared,mysqlnd –with-mysqli=shared,mysqlnd

    actually, i had mysql installed and i am very much using it right now,i wanted to switch to mysqli for that i thought its better to switch to php5.3.0

    the problem is configure run fine but make aborts after giving the following error message ‘make: *** [sapi/cli/php] Error 1’

    did you face similar problem? how to fix this?

  29. If you have problems with the configure-command (for example ‘invalid host type’), check if there’s a copy&paste error! It seems that wordpress transfers — into an html-entity and you will not be able to use this code anymore.

    ./configure –with-apxs2=/usr/bin/apxs2 –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –with-pgsql=/usr –with-tidy=/usr –with-curl=/usr/bin –with-curlwrappers –with-openssl-dir=/usr –with-zlib-dir=/usr –enable-mbstring –with-xpm-dir=/usr –with-pdo-pgsql=/usr –with-pdo-mysql=/usr –with-xsl=/usr –with-ldap –with-xmlrpc –with-iconv-dir=/usr –with-snmp=/usr –enable-exif –enable-calendar –with-bz2=/usr –with-mcrypt=/usr –with-gd –with-jpeg-dir=/usr –with-png-dir=/usr –with-zlib-dir=/usr –with-freetype-dir=/usr –enable-mbstring –enable-zip –with-pear

  30. Dear Brandon,

    Many thanks for your articles… Then how to install GDCHART in your PHP 5.3 installation procedures?

  31. I got below error messages during configuration…

    root@ariza-laptop:/usr/src/php-5.3.0# ./configure –with-apxs2=/usr/bin/apxs2 –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –with-pgsql=/usr –with-tidy=/usr –with-curl=/usr/bin –with-curlwrappers –with-openssl-dir=/usr –with-zlib-dir=/usr –enable-mbstring –with-xpm-dir=/usr –with-pdo-pgsql=/usr –with-pdo-mysql=/usr –with-xsl=/usr –with-ldap –with-xmlrpc –with-iconv-dir=/usr –with-snmp=/usr –enable-exif –enable-calendar –with-bz2=/usr –with-mcrypt=/usr –with-gd –with-jpeg-dir=/usr –with-png-dir=/usr –with-zlib-dir=/usr –with-freetype-dir=/usr –enable-mbstring –enable-zip –with-pear –with-gdchart
    configure: warning: –with-apxs2=/usr/bin/apxs2: invalid host type
    configure: warning: –with-mysql=/usr: invalid host type
    configure: error: can only configure for one host and one target at a time
    root@ariza-laptop:/usr/src/php-5.3.0#

    please advise

  32. Dear All!

    Unable to install GDCHART in PHP 5.3 in ubuntu 9.04 as following

    root@ariza-laptop:/etc/apache2/mods-available# pecl install gdchart
    downloading gdchart-0.2.0.tgz …
    Starting to download gdchart-0.2.0.tgz (52,417 bytes)
    ………….done: 52,417 bytes
    14 source files, building
    running: phpize
    Configuring for:
    PHP Api Version: 20090626
    Zend Module Api No: 20090626
    Zend Extension Api No: 220090626
    configure.in:150: warning: AC_CACHE_VAL(lt_prog_compiler_static_works, …): suspicious cache-id, must contain _cv_ to be cached
    ../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from…
    ../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from…
    aclocal.m4:3555: AC_LIBTOOL_LINKER_OPTION is expanded from…
    aclocal.m4:5493: _LT_AC_LANG_C_CONFIG is expanded from…
    aclocal.m4:5492: AC_LIBTOOL_LANG_C_CONFIG is expanded from…
    aclocal.m4:2972: AC_LIBTOOL_SETUP is expanded from…
    aclocal.m4:2952: _AC_PROG_LIBTOOL is expanded from…
    aclocal.m4:2915: AC_PROG_LIBTOOL is expanded from…
    configure.in:150: the top level
    configure.in:150: warning: AC_CACHE_VAL(lt_prog_compiler_pic_works, …): suspicious cache-id, must contain _cv_ to be cached
    aclocal.m4:3510: AC_LIBTOOL_COMPILER_OPTION is expanded from…
    aclocal.m4:7620: AC_LIBTOOL_PROG_COMPILER_PIC is expanded from…
    configure.in:150: warning: AC_CACHE_VAL(lt_prog_compiler_pic_works_CXX, …): suspicious cache-id, must contain _cv_ to be cached
    aclocal.m4:5606: _LT_AC_LANG_CXX_CONFIG is expanded from…
    aclocal.m4:5605: AC_LIBTOOL_LANG_CXX_CONFIG is expanded from…
    aclocal.m4:4641: _LT_AC_TAGCONFIG is expanded from…
    configure.in:150: warning: AC_CACHE_VAL(lt_prog_compiler_static_works, …): suspicious cache-id, must contain _cv_ to be cached
    ../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from…
    ../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from…
    aclocal.m4:3555: AC_LIBTOOL_LINKER_OPTION is expanded from…
    aclocal.m4:5493: _LT_AC_LANG_C_CONFIG is expanded from…
    aclocal.m4:5492: AC_LIBTOOL_LANG_C_CONFIG is expanded from…
    aclocal.m4:2972: AC_LIBTOOL_SETUP is expanded from…
    aclocal.m4:2952: _AC_PROG_LIBTOOL is expanded from…
    aclocal.m4:2915: AC_PROG_LIBTOOL is expanded from…
    configure.in:150: the top level
    configure.in:150: warning: AC_CACHE_VAL(lt_prog_compiler_pic_works, …): suspicious cache-id, must contain _cv_ to be cached
    aclocal.m4:3510: AC_LIBTOOL_COMPILER_OPTION is expanded from…
    aclocal.m4:7620: AC_LIBTOOL_PROG_COMPILER_PIC is expanded from…
    configure.in:150: warning: AC_CACHE_VAL(lt_prog_compiler_pic_works_CXX, …): suspicious cache-id, must contain _cv_ to be cached
    aclocal.m4:5606: _LT_AC_LANG_CXX_CONFIG is expanded from…
    aclocal.m4:5605: AC_LIBTOOL_LANG_CXX_CONFIG is expanded from…
    aclocal.m4:4641: _LT_AC_TAGCONFIG is expanded from…
    building in /var/tmp/pear-build-root/gdchart-0.2.0
    running: /tmp/pear/temp/gdchart/configure
    checking for grep that handles long lines and -e… /bin/grep
    checking for egrep… /bin/grep -E
    checking for a sed that does not truncate output… /bin/sed
    checking for cc… cc
    checking for C compiler default output file name… a.out
    checking whether the C compiler works… yes
    checking whether we are cross compiling… no
    checking for suffix of executables…
    checking for suffix of object files… o
    checking whether we are using the GNU C compiler… yes
    checking whether cc accepts -g… yes
    checking for cc option to accept ISO C89… none needed
    checking how to run the C preprocessor… cc -E
    checking for icc… no
    checking for suncc… no
    checking whether cc understands -c and -o together… yes
    checking for system library directory… lib
    checking if compiler supports -R… no
    checking if compiler supports -Wl,-rpath,… yes
    checking build system type… i686-pc-linux-gnu
    checking host system type… i686-pc-linux-gnu
    checking target system type… i686-pc-linux-gnu
    checking for PHP prefix… /usr/local
    checking for PHP includes… -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
    checking for PHP extension directory… /usr/local/lib/php/extensions/no-debug-non-zts-20090626
    checking for PHP installed headers prefix… /usr/local/include/php
    checking if debug is enabled… no
    checking if zts is enabled… no
    checking for re2c… re2c
    checking for re2c version… 0.13.5 (ok)
    checking for gawk… no
    checking for nawk… nawk
    checking if nawk is broken… no
    checking whether to enable gdchart support… yes, shared
    /tmp/pear/temp/gdchart/configure: line 4499: cd: ext/gd: No such file or directory
    checking for ld used by cc… /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld… yes
    checking for /usr/bin/ld option to reload object files… -r
    checking for BSD-compatible nm… /usr/bin/nm -B
    checking whether ln -s works… yes
    checking how to recognise dependent libraries… pass_all
    checking for ANSI C header files… yes
    checking for sys/types.h… yes
    checking for sys/stat.h… yes
    checking for stdlib.h… yes
    checking for string.h… yes
    checking for memory.h… yes
    checking for strings.h… yes
    checking for inttypes.h… yes
    checking for stdint.h… yes
    checking for unistd.h… yes
    checking dlfcn.h usability… yes
    checking dlfcn.h presence… yes
    checking for dlfcn.h… yes
    checking the maximum length of command line arguments… 32768
    checking command to parse /usr/bin/nm -B output from cc object… ok
    checking for objdir… .libs
    checking for ar… ar
    checking for ranlib… ranlib
    checking for strip… strip
    checking if cc static flag works… yes
    checking if cc supports -fno-rtti -fno-exceptions… no
    checking for cc option to produce PIC… -fPIC
    checking if cc PIC flag -fPIC works… yes
    checking if cc supports -c -o file.o… yes
    checking whether the cc linker (/usr/bin/ld) supports shared libraries… yes
    checking whether -lc should be explicitly linked in… no
    checking dynamic linker characteristics… GNU/Linux ld.so
    checking how to hardcode library paths into programs… immediate
    checking whether stripping libraries is possible… yes
    checking if libtool supports shared libraries… yes
    checking whether to build shared libraries… yes
    checking whether to build static libraries… no

    creating libtool
    appending configuration tag “CXX” to libtool
    configure: creating ./config.status
    config.status: creating config.h
    running: make
    /bin/bash /var/tmp/pear-build-root/gdchart-0.2.0/libtool –mode=compile cc -I. -I/tmp/pear/temp/gdchart -DPHP_ATOM_INC -I/var/tmp/pear-build-root/gdchart-0.2.0/include -I/var/tmp/pear-build-root/gdchart-0.2.0/main -I/tmp/pear/temp/gdchart -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/libgd -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/gdchart/gdchart.c -o gdchart.lo
    mkdir .libs
    cc -I. -I/tmp/pear/temp/gdchart -DPHP_ATOM_INC -I/var/tmp/pear-build-root/gdchart-0.2.0/include -I/var/tmp/pear-build-root/gdchart-0.2.0/main -I/tmp/pear/temp/gdchart -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/libgd -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/gdchart/gdchart.c -fPIC -DPIC -o .libs/gdchart.o
    In file included from /tmp/pear/temp/gdchart/gdchart.c:35:
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:27:16: error: gd.h: No such file or directory
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:28:21: error: gdfonts.h: No such file or directory
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:29:21: error: gdfontt.h: No such file or directory
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:30:22: error: gdfontmb.h: No such file or directory
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:31:21: error: gdfontg.h: No such file or directory
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:32:21: error: gdfontl.h: No such file or directory
    In file included from /tmp/pear/temp/gdchart/gdchart-src/gdc.h:33,
    from /tmp/pear/temp/gdchart/gdchart.c:35:
    /tmp/pear/temp/gdchart/gdchart-src/gifencode.h:7: error: expected ‘)’ before ‘im’
    /tmp/pear/temp/gdchart/gdchart-src/gifencode.h:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘php_gd_gdImageCreateFromGif’
    In file included from /tmp/pear/temp/gdchart/gdchart.c:35:
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:143: error: expected declaration specifiers or ‘…’ before ‘gdIOCtx’
    /tmp/pear/temp/gdchart/gdchart-src/gdc.h:148: error: expected ‘)’ before ‘im’
    make: *** [gdchart.lo] Error 1
    ERROR: `make’ failed
    root@ariza-laptop:/etc/apache2/mods-available# /etc/init.d/apache2 restart
    * Restarting web server apache2 apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
    … waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
    [ OK ]
    root@ariza-laptop:/etc/apache2/mods-available#

    Please advise,
    Riza

  33. I’ve installed php 5.3 on my virtual server with plesk 9.2.2 and all worked fine… (means 5.3 is displayed in the phpinfo)

    BUT sometimes sporadic following error is displayed (if is open a php web page in the browser)

    Warning: Unknown: open_basedir restriction in effect. File(/var/www/vhosts/injc.net/subdomains/pma/httpdocs/index.php) is not within the allowed path(s): (8¦ú ) in Unknown on line 0

    Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

    Fatal error: Unknown: Failed opening required ‘/var/www/vhosts/injc.net/subdomains/pma/httpdocs/index.php’ (include_path=’.:/opt/php5.3/lib/php’) in Unknown on line 0

    someone an idea what i could do???

  34. It’s an official bug of php5.3
    I’ve installed the newest snapshot and there are no errors like this

  35. If you’re getting an “invalid host type”, try typing the configure command by hand and that’s gonna work for you.
    Thanks for the article ;)

  36. Greetings Brandon,

    I got below error message after run phpinfo in browser

    Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Kuala_Lumpur’ for ‘MYT/8.0/no DST’ instead in /var/www/test.php on line 3

    Please advise.
    Riza

  37. Many people here seems to be fans of installing PHP 5.3 from Dotdeb :) Then I let you know that PHP 5.3.1 packages are now available.

    Fetching the source packages can also be a good start to build your own packages (Dotdeb packages are built for Debian, rebuilding them for Ubuntu is a good idea/training : apt-get build-dep php5 && apt-get source -b php5 )

  38. for those of you experienceing the zend_parse_paramater error from apache2, while loading libphp5.so:

    /apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: undefined symbol: zend_parse_parameters

    take a look at the ./configure output. if you get a message saying something similar to:

    configure: warning: bison versions supported for regeneration of the Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 (found: none).

    try installing bison: sudo apt-get install bison

    then make distclean
    then ./configure …
    then make
    then make -i install

    http://www.linuxforums.org/forum/redhat-fedora-linux-help/87975-configuring-php-work-apache.html

  39. I’ve created some build scripts that will download and install PHP 5.3 and dependencies (uses Ruby and Rake to emulate the build dependencies) into a standalone folder, helpful for testing out custom PHP builds in an isolated environment. Check it out:

    http://github.com/patcoll/buildphp

  40. Thanks for the advice! A useful feature I’ve found in Ubuntu for building from source is the “build-dep” command for apt-get. Running:

    sudo apt-get build-dep php5

    Will install most of the dependencies above automatically.

    On a side note, I haven’t ever installed two version of PHP side-by-side before. If I started with an installation on PHP5 from the repos, and then install PHP 5.3 from source with –prefix=/usr/local, can I then toggle between the different versions for testing? Anyone know where the version of PHP5 from the repos installs to by default?

    Last question: it looks like the new install doesn’t know where to find some of the existing modules (e.g. xdebug). From phpinfo(),

    “Scan this dir for additional .ini files” is listed to (none).

    Is this the option that needs to be set in order for the new install to find xdebug, etc? Any idea what needs to be changed in the above configure command? The modules from the repo install are located in: /usr/lib/php5/20060613+lfs/.

    Any advice would be greatly appreciated :)

    Thanks!

  41. Oh, and another important thing: PECL modules won’t install properly unless you install autoconf:

    sudo apt-get install autoconf

    (automake will be installed as a dependency of autoconf by default)

    Galvao

Comments are closed.