Installing Ubuntu 10.04 Lucid Lynx for PHP development

By | June 15, 2010

Lucid-LynxLast year I have written a small how-to for installing an Ubuntu 9.04 work environment as virtualbox environment (though it also works for native systems). Recently I have updated this guide to 10.04 as kind of check list to get a working environment to develop PHP/MySQL applications.

Installation of System

First of all you have install from scratch, which means putting the CD-Rom in your drive or create a VirtualBox and use the ISO file as mount. Then just follow the menu to install Ubuntu.

After basic installation

Start by opening a console window and become superuser:

1
sudo -i

After that update your package list and upgrade all packages with available updates:

1
2
apt-get update
apt-get upgrade

In case you are using a VirtualBox environment, you have to restart the system and boot up again. After that open a console again and get superuser rights:

1
sudo -i

Then you should install VirtualBox Guest Extensions:

1
2
cd /cdrom
./VBoxLinuxAdditions-x86.run

Installation of LAMP environment

To test your code base you need a working webserver environment with PHP and MySQL Client / Server. If you want to use a separate MySQL Server for your databases then you can skip installing the MySQL Server.

First we start with Apache2:

1
2
3
4
5
apt-get install build-essential
apt-get install apache2 apache2-threaded-dev
a2enmod ssl
a2enmod rewrite
a2enmod include

a2enmod is used to activate apache2 modules like mod_ssl, mod_rewrite and mod_include.

To use php5-curl later, you need to install curl first:

1
apt-get install curl

Now it’s time for PHP5:

First we install some (more or less) necessary PHP5 packages (including imagemagick):

1
2
3
apt-get install php5 php5-cli php5-dev php-pear
apt-get install imagemagick
apt-get install php5-gd php5-mcrypt php5-imagick php5-curl php5-xmlrpc php5-xsl php5-mhash

The php5-dev package contains phpize which is necessary for installing and compiling PEAR/PECL extensions for PHP.

Since you might want to use PEAR packages, an upgrade of the channels and already installed packges is advised:

1
2
pear channel-update pear.php.net
pear upgrade-all

Some recommended PEAR packages include:

Template Engines:

1
pear install HTML_QuickForm HTML_Common HTML_Template_Sigma

PHP-Unit:

1
2
3
4
5
pear channel-discover pear.phpunit.de
pear remote-list -c phpunit
pear install phpunit/PHPUnit
pear channel-discover components.ez.no
pear install phpunit/phpcpd

Now the MySQL part:

You can either use standard MySQL/MySQLi or PDO. Since PHP 5.1 PDO comes preinstalled. To install everything just do the following:

1
2
3
apt-get install mysql-client mysql-server libmysqlclient15-dev
apt-get install mysql-query-browser mysql-admin
apt-get install php5-mysql

Those packages include MySQL Query Browser and MySQL Administrator which are quite handy tools to manage MySQL databases and tables.

For debugging your code (e.g. from the Eclipse environment) you have to install XDebug:

1
pecl install xdebug

As a default configuration you should put the following into /etc/php5/conf.d/xdebug.ini:

1
2
3
4
5
6
7
8
xdebug.profiler_enable_trigger = 1
xdebug.profiler_enable=0
xdebug.profiler_output_dir = /tmp
xdebug.remote_enable=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_log="/tmp/xdebug.log"

This enables you to use XDebug as profiler (by using the parameter XDEBUG_PROFILE=1 as GET/POST parameter when executing your website). It creates a cachegrind file to be analysed (e.g. with kCacheGrind, I will explain that in another tutorial).

At the end don’t forget to reload Apache2 before starting to work with your system:

1
apache2ctl restart

Now the most important stuff is installed. You might want to install Subversion:

1
apt-get install subversion

but I will not go into details about using that here.

Applications

To use Eclipse, Aptana or Zend Studio (if you have a license) you need a Java Runtime Engine. Best is to install the default-jre:

1
apt-get install default-jre

Now you just need to download your favorite IDE (e.g. Eclipse) and you can start developing your applications. Some hints to do that:

  • you can run your local webserver with your user account, just change it in /etc/apache2/envvars
  • to use PEAR packages you need to uncomment the include_path part for linux based operating systems in /etc/php5/apache2/php5.ini.

13 thoughts on “Installing Ubuntu 10.04 Lucid Lynx for PHP development

  1. DoubleJ

    At the “pecl install PDO” , i have this :

    /bin/bash /var/tmp/pear-build-root/PDO-1.0.3/libtool –mode=compile cc -I. -I/tmp/pear/temp/PDO -DPHP_ATOM_INC -I/var/tmp/pear-build-root/PDO-1.0.3/include -I/var/tmp/pear-build-root/PDO-1.0.3/main -I/tmp/pear/temp/PDO -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/PDO/pdo.c -o pdo.lo
    libtool: compile: cc -I. -I/tmp/pear/temp/PDO -DPHP_ATOM_INC -I/var/tmp/pear-build-root/PDO-1.0.3/include -I/var/tmp/pear-build-root/PDO-1.0.3/main -I/tmp/pear/temp/PDO -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/PDO/pdo.c -fPIC -DPIC -o .libs/pdo.o
    /bin/bash /var/tmp/pear-build-root/PDO-1.0.3/libtool –mode=compile cc -I. -I/tmp/pear/temp/PDO -DPHP_ATOM_INC -I/var/tmp/pear-build-root/PDO-1.0.3/include -I/var/tmp/pear-build-root/PDO-1.0.3/main -I/tmp/pear/temp/PDO -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/PDO/pdo_dbh.c -o pdo_dbh.lo
    libtool: compile: cc -I. -I/tmp/pear/temp/PDO -DPHP_ATOM_INC -I/var/tmp/pear-build-root/PDO-1.0.3/include -I/var/tmp/pear-build-root/PDO-1.0.3/main -I/tmp/pear/temp/PDO -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/PDO/pdo_dbh.c -fPIC -DPIC -o .libs/pdo_dbh.o
    /tmp/pear/temp/PDO/pdo_dbh.c: In function ‘pdo_stmt_instantiate’:
    /tmp/pear/temp/PDO/pdo_dbh.c:410: error: ‘zval’ has no member named ‘refcount’
    /tmp/pear/temp/PDO/pdo_dbh.c:411: error: ‘zval’ has no member named ‘is_ref’
    /tmp/pear/temp/PDO/pdo_dbh.c: In function ‘pdo_stmt_construct’:
    /tmp/pear/temp/PDO/pdo_dbh.c:435: error: ‘zend_fcall_info’ has no member named ‘object_pp’
    /tmp/pear/temp/PDO/pdo_dbh.c:458: error: ‘zend_fcall_info_cache’ has no member named ‘object_pp’
    /tmp/pear/temp/PDO/pdo_dbh.c: In function ‘zim_PDO_setAttribute’:
    /tmp/pear/temp/PDO/pdo_dbh.c:752: error: ‘zval’ has no member named ‘refcount’
    /tmp/pear/temp/PDO/pdo_dbh.c: In function ‘zim_PDO_getAttribute’:
    /tmp/pear/temp/PDO/pdo_dbh.c:818: error: ‘zval’ has no member named ‘refcount’
    /tmp/pear/temp/PDO/pdo_dbh.c: In function ‘pdo_hash_methods’:
    /tmp/pear/temp/PDO/pdo_dbh.c:1122: warning: assignment discards qualifiers from pointer target type
    /tmp/pear/temp/PDO/pdo_dbh.c:1126: warning: assignment discards qualifiers from pointer target type
    make: *** [pdo_dbh.lo] Erreur 1
    ERROR: `make’ failed

  2. DoubleJ

    Ehhh…, i’d also like to say hello and thansk for tutos… 😉 😉

    (slapping myself).

  3. DoubleJ

    also for PDO_mysql :

    checking for PHP extension directory… /usr/lib/php5/20090626+lfs
    checking for PHP installed headers prefix… /usr/include/php5
    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… gawk
    checking for MySQL support for PDO… yes, shared
    checking for mysql_config… /usr/bin/mysql_config
    checking for mysql_query in -lmysqlclient… yes
    checking for mysql_commit… yes
    checking for mysql_stmt_prepare… yes
    checking for mysql_next_result… yes
    checking for mysql_sqlstate… yes
    checking for PDO includes… checking for PDO includes…
    configure: error: Cannot find php_pdo_driver.h.
    ERROR: `/tmp/pear/temp/PDO_MYSQL/configure’ failed

  4. Tien

    This is of great help to a newcomer to PHP and Ubuntu.
    Thank you

  5. Nick Marinho

    But this only installs the PDO extension.
    Now i need PDO_MYSQL and simply I can’t found solution to this error

    checking for PDO includes… checking for PDO includes…
    configure: error: Cannot find php_pdo_driver.h.
    ERROR: `/tmp/pear/temp/PDO_MYSQL/configure’ failed

  6. Carlos Gómez

    Hi Nick Marinho, you need to edit your configure file and look for the line where it search php_pdo_driver and change to look for php5 folder instead php

  7. Greg

    Many thanks for putting this together. It has saved a huge amount of time. It will now be my default reference for new *nix installs.

    I wished I had found it a week ago!

  8. Dan Dascalescu

    I found that on Ubuntu 11, for some reason installing php5-mysql doesn’t add the “extension=pdo_mysql.so” line to any PHP INI files. To do that, run this:

    sudo bash -c ‘echo extension=pdo_mysql > /etc/php5/cli/conf.d/pdo_mysql.ini’

    1. Christian Post author

      Thanks for the info Dan, think I will write an updated post about Ubuntu 11 in the next couple of days/weeks.

  9. Pingback: Un tuto de plus sur une installation lamp avec driver PDO pour mysql | LorfDotNet

Comments are closed.