Last 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:
After that update your package list and upgrade all packages with available updates:
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:
Then you should install VirtualBox Guest Extensions:
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:
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:
pear channel-update pear.php.net pear upgrade-all
Some recommended PEAR packages include:
pear install HTML_QuickForm HTML_Common HTML_Template_Sigma
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:
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:
Now the most important stuff is installed. You might want to install Subversion:
apt-get install subversion
but I will not go into details about using that here.
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:
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.