Installing LAMP with PHP 5.3 on Ubuntu 11.04 Natty Narwhal / 11.10 Oneric Ocelot
I wont cover what’s new in php 5.3 since it would be another article, however it contains alot of improvements including PHP Namespaces, Late Static Bindings, lambda functions, closures…etc. I would strongly recommend using it.
I’ll be explaining how to install LAMP stack with PHP 5.3.8 without compiling
It’s fairly easy using the dotdeb repository
Step 1: Add the dotdeb repository:
first we need to add the dotdeb application sources to our sources list
sudo nano /etc/apt/sources.list
And copy and paste the following lines and save using ctrl+o
deb http://packages.dotdeb.org stable all deb-src http://packages.dotdeb.org stable all
Step 2: Import the GPG key for the dotdeb repository
Then we’ll add the GPG key for the dot deb repository by the following command:
wget http://www.dotdeb.org/dotdeb.gpg && cat dotdeb.gpg | sudo apt-key add -
Now we’ll refresh the packages list by the following command:
sudo apt-get update
Step 3: Installation
Now we’re ready to install our LAMP stack
sudo aptitude install apache2 apache2-mpm-prefork mysql-client-5.5 mysql-server-5.5 php5 php5-cli php5-mysql libapache2-mod-php5 php5-dev php5-mcrypt php5-curl php5-gd phpmyadmin
Now we’re all set, just need to test it
go to http://localhost/ to test apache
and we can test php by writing in the bash
php -v
you should see something like the following:
PHP 5.3.8-1~dotdeb.2 with Suhosin-Patch (cli) (built: Aug 25 2011 13:30:46)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
Update:
Since the new distros of the Ubuntu uses php 5.3, the magical command in step 3 will be sufficient, however if you need a more updated version use the dotdeb repository, if you don’t care much about which version to use 5.3.x just skip to step 3.

5.28.2011
I think these two lines are not necessary as it supposed to be used for old debian builds.
deb http://php53.dotdeb.org stable all
deb-src http://php53.dotdeb.org stable all
7.11.2011
Nice article,
thanks a lot for sharing such info
7.27.2011
Hi,
I am a DotNet Developer with over 2 years of experience, but I just fell in love with ubuntu, and wanted top have some test of a newbie with open source development. And this is the first post which helped me out dealing with all difficulties of installing LAMP on ubuntu 11.04.
Thanks and keep writing good stuff!
8.08.2011
Thanks! This is really helpful.
10.25.2011
hi Omar,
I have gone through the following post http://www.omaroid.com/installing-lamp-with-php-5-3-6-on-ubuntu-11-04-natty-narwhal/
I ended up with the same meesage:
PHP 5.3.8-1~dotdeb.2 with Suhosin-Patch (cli) (built: Aug 26 2011 09:36:27)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
when I try to start apache by service apache2 start I get an error… which is the correct command to start apache after your procedures?
I tried to instal Lamp before (last 2 days) and mysql never asked me for Password… I have tried via Synaptic and console and no success…
I managed to install Xampp 1.7.4. and It worked but then I tried to connect to http://localhost/project (joomla installation) i get an 404 ERROR Not found…
I have tried everything found on posts… no success… I read that Xampp 1.7.4. is a piece of crap. I use Kubuntu 11.04 and trying to instal Joomla 1.6.6.
PLEASE HELP! you can email me to amayordomo82@gmail.com if you come up with any idea.
Many thanks in advance!
Albert
10.25.2011
i forgot to add the following when apache fails to start:
* Starting web server apache2 apache2: Syntax error on line 227 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/conf.d/phpmyadmin.conf: No such file or directory
Action ‘start’ failed.
The Apache error log may have more information.
10.25.2011
you can start the apache by
sudo /etc/init.d/apache2 startor
sudo service apache2 startHowever it seems like you have got a problem with phpmyadmin, did it produce any errors during the installation?
try to remove the pma
sudo apt-get remove --purge phpmyadminthen install it
sudo apt-get install phpmyadminplease let me know if worked or not
12.14.2011
If your sql is not connecting after you do this update.
Type:
mysqld
If you receive this error:
111213 15:53:17 [Note] Plugin ‘FEDERATED’ is disabled.
111213 15:53:17 InnoDB: Initializing buffer pool, size = 8.0M
111213 15:53:17 InnoDB: Completed initialization of buffer pool
111213 15:53:17 InnoDB: Started; log sequence number 0 44233
111213 15:53:17 [ERROR] mysqld: unknown variable ‘lc-messages-dir=/usr/share/mysql’
111213 15:53:17 [ERROR] Aborting
111213 15:53:17 InnoDB: Starting shutdown…
111213 15:53:22 InnoDB: Shutdown completed; log sequence number 0 44233
111213 15:53:22 [Note] mysqld: Shutdown complete
Edit your my.cnf file with this:
nano /etc/mysql/my.cnf
and replace the line
lc-messages-dir=/usr/share/mysql
with
#lc-messages-dir=/usr/share/mysql
Then save that file and type
start mysql
and you should be golden.
12.28.2011
help please
i tried many time to install LAMP i’m still getting this error :
E: Unable to locate package apache2
E: Unable to locate package apache2-mpm-prefork
E: Unable to locate package mysql-client-5.1
E: Couldn’t find any package by regex ‘mysql-client-5.1′
E: Unable to locate package mysql-server-5.1
E: Couldn’t find any package by regex ‘mysql-server-5.1′
E: Unable to locate package php5
E: Unable to locate package php5-cli
E: Unable to locate package php5-mysql
E: Unable to locate package libapache2-mod-php5
E: Unable to locate package php5-mcrypt
E: Unable to locate package php5-curl
E: Unable to locate package php5-gd
E: Unable to locate package phpmyadmin
can tell me what can be the cause ?
thnx
2.29.2012
@abdul rahim are you sure you edited the sources list and performed an update?
5.08.2012
nice worked great
7.07.2012
thanx a lot!