Get your FREE 30 page Developing SOLID Applications guide!

Installing PHP 5.3 On Ubuntu

Out Of Date Warning

Languages change. Perspectives are different. Ideas move on. This article was published on July 5, 2009 which is more than two years ago. It may be out of date. You should verify that technical information in this article is still current before relying upon it for your own purposes.

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.

Write better object oriented PHP today.

Object oriented programming always leaves you with a headache. What if you could master it instead?

Get the book now! »

Christopher wrote at 7/5/2009 10:03 pm:

Or just use the http://www.dotdeb.org repository.

Er Galvao Abbott (@galvao) wrote at 7/5/2009 10:05 pm:

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

Jan! wrote at 7/6/2009 2:43 am:

While I am mostly for the DIY attitude, I rather like the comfort of Dotdeb’s pre-packaged PHP 5.3. I have been using it since the first RC, and rather like it.

http://www.dotdeb.org/2009/07/03/php-5-3-0-final-preview-packages-available-for-debian-lenny/

Thanks for the detailed explanation, though!

Stephan Hochdoerfer (@shochdoerfer) wrote at 7/6/2009 3:14 am:

In case you want to build a .deb and not install the files through the make process, you can use checkinstall as described here:
http://codeblog.palos.ro/2008/05/06/ubuntu-packages-for-latest-php-snapshots/

Ivan Jovanovic (@ivanjovanovic) wrote at 7/6/2009 3:43 am:

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.

till (@klimpong) wrote at 7/6/2009 4:53 am:

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.

Markus Wolff wrote at 7/6/2009 5:13 am:

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.

Markus Wolff wrote at 7/6/2009 5:16 am:

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

Brandon Savage (@brandonsavage) wrote at 7/6/2009 6:06 am:

@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.

Michael Maclean (@mgdm) wrote at 7/6/2009 8:28 am:

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.

Brandon Savage (@brandonsavage) wrote at 7/6/2009 8:34 am:

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.

Hussein wrote at 7/7/2009 5:27 pm:

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.

Brandon Savage (@brandonsavage) wrote at 7/8/2009 5:54 am:

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.

Markus Wolff wrote at 7/8/2009 6:28 am:

@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.

Hussein wrote at 7/8/2009 1:01 pm:

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.

Brandon Savage (@brandonsavage) wrote at 7/8/2009 1:08 pm:

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.

Hussein wrote at 7/8/2009 3:03 pm:

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

Pawel Barcik wrote at 7/12/2009 1:25 am:

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

PHP 5.3.0 With Advanced Concepts - ToTheTech.Net - Webmaster Blog wrote at 7/12/2009 3:47 am:

[...] install PHP 5.3.0 with Apache 2 check out brandonsavage.net instructions about how to install PHP 5.3.0 in Ubuntu Linux operating [...]

Creating a PHP 5.3 Virtual Development Environment | PHP | Server-Side Magazine wrote at 7/13/2009 10:10 am:

[...] to Brandon Savage for writing a tutorial on installing and compiling Apache, MySQL and PHP 5.3 on Ubuntu. I will take the steps from that [...]

Chuck Burgess (@ashnazg) wrote at 7/13/2009 2:49 pm:

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.

Sylvain wrote at 7/14/2009 6:59 pm:

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

Troels wrote at 7/18/2009 8:28 pm:

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

PHP 5.3 Not In Next Version Of Ubuntu | BrandonSavage.net wrote at 8/4/2009 9:31 am:

[...] support until April, 2010, based on the history of Ubuntu release cycles. However, you can still compile PHP 5.3 on Ubuntu yourself. Share and [...]

Bonzei wrote at 8/9/2009 3:41 am:

When using Ubuntu 9.04 then first install libxpm-dev.

Oz wrote at 8/11/2009 2:35 pm:

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?

Renoir Boulanger (@renoirb) wrote at 9/9/2009 12:04 am:

For the posterity and the internationalization of this good wealth I translated it myself on my own blog. Of course, i credited your work.

I adjusted with Debian Lenny as of 2009-09-08 updated and i think it reflects whats already stated in those comments here… But in french! ;)

Thanks guys!

http://renoirboulanger.com/blog/2009/09/une-vm-linux-qui-sert-au-developpement-php-5-3-avec-eclipse-partie-iii/

AD wrote at 9/9/2009 4:32 pm:

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!

Dan wrote at 9/9/2009 9:42 pm:

(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

Brandon Savage (@brandonsavage) wrote at 9/9/2009 9:58 pm:

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.

Brandon Savage (@brandonsavage) wrote at 9/9/2009 10:00 pm:

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).

Dan wrote at 9/9/2009 10:12 pm:

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?)

Brandon Savage (@brandonsavage) wrote at 9/9/2009 10:15 pm:

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.

Dan wrote at 9/9/2009 10:34 pm:

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).

Dan wrote at 9/9/2009 11:05 pm:

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!

chopper wrote at 9/10/2009 2:44 am:

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?

Martin wrote at 9/11/2009 7:03 am:

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

Rob Searles » Installing PHP5.3 on Ubuntu Jaunty wrote at 10/4/2009 12:10 pm:

[...] had a quick Google on how to install PHP 5.3 on Ubuntu and found Brandon Savage’s post on the very subject! Whilst he has a great write up it was one or two of his comments mentioning [...]

Riza wrote at 10/16/2009 2:01 pm:

Dear Brandon,

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

Brandon Savage (@brandonsavage) wrote at 10/16/2009 4:53 pm:

Unfortunately I don’t. Sorry.

Riza wrote at 10/16/2009 8:25 pm:

Can I do it just simply add -with-gdchart after ./configure ..??

Riza wrote at 10/16/2009 9:43 pm:

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

Riza wrote at 10/16/2009 11:32 pm:

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

Stevie wrote at 10/19/2009 6:41 pm:

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???

Brandon Savage (@brandonsavage) wrote at 10/20/2009 9:22 am:

Make sure you don’t have basedir limitations configured in your php.ini file.

Stevie wrote at 10/20/2009 10:01 am:

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

Sepehr Lajevardi (@lajevardi) wrote at 10/23/2009 10:08 pm:

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 ;)

PHP 5.3 auf Ubuntu 9.04 | PC-Users.de wrote at 10/25/2009 5:19 pm:

[...] hab ich unzählige Anleitungen wie z.b. http://www.brandonsavage.net/install…5-3-on-ubuntu/ oder [...]

Riza wrote at 10/31/2009 7:50 am:

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

Brandon Savage (@brandonsavage) wrote at 10/31/2009 8:07 am:

PHP emits a warning if you have not set a default time zone, which you clearly haven’t.

Please consider reading the manual, which describes this problem, before posting questions demanding help.

http://php.net/manual/en/function.date-default-timezone-set.php

mariuz (@mapopa) wrote at 11/2/2009 11:00 am:

I have written an followup but with firebird pdo driver and firebird
driver http://wiki.firebirdsql.org/wiki/index.php?page=Installing+PHP+5.3.x+On+Ubuntu+Karmic+with+Firebird+PDO+support

Guillaume Plessis (@w_a_s_t_e) wrote at 11/30/2009 5:37 am:

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 )

teh b wrote at 12/12/2009 8:30 am:

Thanks man,
your article was very helpful!

Not Relevant wrote at 12/13/2009 3:14 pm:

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

Pat Collins wrote at 1/15/2010 11:22 am:

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

Keith wrote at 2/3/2010 7:44 am:

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!

Er Galvao Abbott (@galvao) wrote at 2/22/2010 3:17 pm:

Hey Brandon, I’ve just realized the following:

PHP’s interactive shell (php -a) won’t work properly unless you:

1) sudo apt-get install libreadline6-dev
2) Include –with-readline in the configure line

Ref.: http://bugs.php.net/bug.php?id=48759

Cheers,

Galvao

Er Galvao Abbott (@galvao) wrote at 2/22/2010 3:18 pm:

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