LAMP stands for Linux, Apache, MySQL, and php, (or Perl). It’s one of the most popular web hosting platforms. If you’re developing websites, it’s good to have your own private development environment to use while you build and test your websites. This post will show you how to install and configure a LAMP web development environment on Ubuntu 11.10 Oneiric Ocelot to use for testing. It can also be used to set up LAMP on a Virtual Private Server (VPS) or a Dedicated Server, but please note that this post does not cover setting up proper security for serving content to the internet.
Install LAMP
The Ubuntu development team has made it very easy to install and configure a LAMP web server. Open a terminal window and enter the following command.
[term]sudo apt-get install lamp-server^[/term]
Please enter the command exactly as it’s shown above. The carat (^) is not a typo and the command will not work without it.
If prompted, enter your password.
The package manager will now display a list of packages to be installed. Hit <Enter> to confirm that you want to go ahead with the install.
Apt will now start downloading and installing the packages on your computer.
After a short wait, you will be prompted to set a password for MySQL’s administrative user. Enter a password at the prompt and make sure it’s something you will remember or make a note of it.
You will then be prompted to confirm your password.
Type in the same password and hit <Enter>. The package manager will now continue downloading and installing packages. After a short wait the installation will complete.
Testing Apache
Now we’ll run a quick test to make sure that the Apache web server is working. Open a web browser and enter the address http://localhost/. You should see a page that says “It Works!”
Testing php
Now that we’ve verified that Apache works, we need to verify that php is working properly. We’re going to create a file in the /var/www directory called testing.php. Enter the following command in the terminal to create the file.
[term]echo “<?php phpinfo(); ?>” | sudo tee /var/www/testing.php[/term]
Enter your password if prompted.
Now you’ll need to restart the Apache web server. Enter into the terminal:
[term]sudo service apache2 restart[/term]
Now open your web browser and enter the following address: http://localhost/testing.php
You should see a web page that displays a bunch of information about your php and Apache environment.
Configure MySQL
Since this is for a local development environment, the MySQL database needs to be bound to the localhost IP address. This should be 127.0.0.1 by default. You can verify your localhost address with the following terminal command.
[term]cat /etc/hosts | grep localhost[/term]
You should see output something like this:
[term]
127.0.0.1 localhost ::1 ip6-localhost ip6-loopback
[/term]
Now you need to verify that this address is the bind address MySQL’s my.cnf file. Use the following terminal command.
[term]cat /etc/mysql/my.cnf | grep bind-address[/term]
You should see output like this.
[term]
bind-address = 127.0.0.1
[/term]
If it’s not correct you’ll need to edit /etc/mysql/my.cnf as root to fix it.






Works perfectly, thanks!
To install phpmyadmin, Just run the command in the terminal
sudo apt-get install lamp-server^ phpmyadmin
It’s all covered on page 2 of this post: http://tuxtweaks.com/2011/10/install-lamp-and-phpmyadmin-on-ubuntu-11-10/2/
thank you! Perfectly Working…
thank you so much for your help!! Your troubleshooting section was a very nice addition
Thank you, All Ok. Now Im want to install PHPMYADMIN
Run the following command
sudo apt-get install lamp-server^ phpmyadmin
http://tuxtweaks.com/2011/10/install-lamp-and-phpmyadmin-on-ubuntu-11-10/2/
worked very well !!!! Thanks for your help !!!!!
If you are facing some problem with phpmyadmin then consult this post [http://codesprints.blogspot.in/2012/04/phpmyadmin-not-working-ubuntu.html].
Or you can fix it easily with this: http://tuxtweaks.com/2012/05/fixing-common-problems-with-lamp-on-ubuntu/
Great piece there. Thanx a lot.
Great tutorial, thanx! One question – does an FTP server get installed with the lampserver install? Or does it have to be set up separately?
I don’t believe that an ftp server gets installed with this process, so you will have to do that separately.
buenisima la explicacion. instalacion completa gracias a esto.
great explication, thank you.
Gracias muy amable, me sirvió mucho..
thank u very much, this was utility
it works fine , Thank you
but i can not create any files using the GUI, i mean when i be in the /var/www i can not create any file
/var/www is owned by root, so you either need to change the ownership to yourself, or you could start a file manager as root. Assuming you use regular Ubuntu, you can launch the Nautilus file manager with root permissions with:
[term]gksudo nautilus –no-desktop[/term]
Another option is to put your files in a folder under your user ID and configure Apache to load them from there.
it works..thanks
WERY GOOD
Dzi?ki !!!!!
very nice work here.
Hello sir i m using the ubuntu 11.10 with Apache/2.2.20 (Ubuntu) with php5.
I have problem with urlrewriting, i want to use .htaccess file but i dont know how to give permission…
Thanking u in advance…
very good, thank you very much
yay….
it works !!!!
great !!!!
tq so much
Thank you so much! This is by far the best walk-through I have found so far. I’ve been wasting away for hours trying to troubleshoot some things, but a couple minutes reading this page seems to have fixed everything.
your username is root and your password is what they asked before you installed the LAMP
YES! Done. needs
sudo /etc/init.d/apache2 restart
after, and that’s it.
Thanks for your help. We beginners need all the help we can get.
Cheers
That’s a valuable piece of research. I’ll file it away. Thanks very much.
I actually un-installed the lamp-server and re installed it and this time it went through the password stage. I can log in to mysql as root.
HOWEVER I can’t get phpmyadmin to be found on localhost. Error 404
I already un and re installed it and re configured it once. I’ll try again.
Thanks in advance for any future advice.
If you’re sure you’ve configured it correctly, try clearing your browser cache. I’ve had problems with Firefox especially. Once you get the 404 error, Firefox doesn’t really try to reload the page from the server. It just reloads from the cache. Firefox has had me chasing my tail more times than I can think of. Maybe that’s why the logo is a fox chasing its tail 🙂
That’s a good thought. I cleared Firefox of all history, cache, cookies, the lot. But the problem persists.
phpinfo() works but not phpmyadmin. It works okay on my laptop with U10.10?
“URL not found on this server” ? Got to be something basic.
That’s a good thought. I have now cleared the cache in Firefox but still the problem persists.
error 404 url phpmyadmin not found on server.
I might try this one and see what happens.
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d
What do you think?
Hi there. I wasn’t prompted for a password after the first step. Now I can’t connect to mysql. I get permission denied to root @localhost password = no/yes (I tried my sudo password.)
Apache and php are working and mysql is running.It’s just the password issue for mysql.
What’s up? Should I uninstall lamp and try again. I used “sudo apt-get install lamp^”
After a little bit of research, I’ve found that you can reset the MySQL root password by reconfiguring the installation with this command:
[term]sudo dpkg-reconfigure mysql-server-5.1[/term]
You should then get prompted to enter a new password, and then confirm the new password.
Please, don’t worry because I have figured it out. I can now access phpmyadmin. The only problem now is that when I want to create a new database, I will get a message that says; ‘No privileges”. Please, what could be responsible for that and how can I create a new database?
Thanks.
Sunny
The password that you created for phpMyAdmin during installation was for the root user. Are you logging in as root? Root should have full administrative access and be able to create and delete databases.
Hi!
Following your instructions, I successfully installed LAPM on my system using Ubuntu 11.10. Tested everything and it worked, but when I open myphpadmin, I was prompted to enter my username and password, I did, but got this message: “#1045 Cannot log in to the MySQL server’. What could be the problem because I remember during installation I was only asked to enter my password alone. Please, what do I do?
Thanks.
Sunny
hi!
thanks for helping me with this tutorial, now my phpadmin is running without any kind of problem. So God bless u in everything u do.
i say it again, THANK YOU!!!
I want to create & use cgi and pl files in my lamp environment. If that also has been added with this tutorial then I think this tutorial would be complete. Yesterday I installed LAMP successfully without any problem as per this tutorial.
Thanks for the feedback. I’m not much of a web developer, so I haven’t really messed with that, but I’ll look into it. 🙂
Wow. Tutorial ran perfectly. Needed recent version of PHP and MySQL to do development and this got me started quick.
Thanks again
Thanks for this clean and elaborate step by step instruction for installing LAMP in our Ubuntu 11.10 OS. As a learner of Web Designing this page is very useful for us. I have installed LAMP without encountering any error as per the procedure given in the page.
Thanks for sharing nice article, about lamp and php.
how do u change the name of a file it keeps telling me that i dont hav the permissions to do so……?
You can use the mv command from the terminal. Since you don’t have permission you will need to use sudo.
[term]sudo mv name1 name2[/term]
Have been running Lampp for a few months now and I always got the
“apache2: Could not reliably determine the server’s fully qualified domain name,
using 127.0.1.1 for ServerName”, with no problems running PHP with Zend framework.
The echo “ServerName localhost” | sudo tee /etc/apache2/conf.d/fqdn”, worked for me a treat… Thanks for that…
For anyone wanting to install Lampp under Ubuntu 11.10, this is the only tutorial you should need…
Thanks again…
Thanks!!Awesome!!
Great info thanks for the sharing
Thank a lot for Fixing phpMyAdmin solution 🙂
Thank You! Your instructions worked to a “T”. You made the process easy.
1. type on terminal -> sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d
THEN
2. sudo /etc/init.d/apache2 restart
3. WORKS !!!
this is if you can’t access http://localhost/phpmyadmin
solution found at http://ubuntuforums.org/showthread.php?t=1694505
to get ownership of directory with command
sudo chown /var/www
DONE!
Got one problem. When I try to make new folder or file in www folder ubuntu error pops up :
” Could not save the file /var/www/newfile.html
You do not have the permissions necessary to save the file. Please check that you typed the location correctly and try again. ”
Now if we can not create new folder or file then how can we develop webs in there… lol
any help to mend this issue will be appreciated
.
Hi
Thanks for such a detailed tutorial on installing Local AMP on ubuntu 11.10.
I recently moved to ubuntu 11.10 and followed it step by step and it worked like a charm.
Thanks once again.
– Param
Nothing can match the moral boost one gets with Open Source & GPL OS
Thank you! Up and running in just a few minutes.
Thanks you have done great job :).
I have configure LAMP web development environment successfully. but i am getting a error message in the phpmyadmin. that is as
connection for controluser as defined in your configuration failed.
Thanks
Sorry, I haven’t seen that error before. I suggest trying the Ubuntu Forums or phpMyAdmin Forums.
Finally..Ur info was right on. Owe u a beer one day…
Really helpful. Thanks a lot 🙂
Much appreciated =)
thank you so much for this detailed guide. :))
For all that I have peformed this install several times over the last 3 years, I STILL forget to leave the asterisk when configuring the phpmyadmin. Thanks for the reconfigure advice or I would have been scratching my head for days; and thanks to them as what take the time to post this install advice which makes my life so easy.
Thank you for this detailed info
thanx for this usefull tutorial
Thank you !!
i am getting this error every time i try
plz help
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package lamp-server^
E: Couldn’t find task ‘lamp-server’
E: Couldn’t find any package by regex ‘lamp-server^’
hi,
I am trying to have LAMP / server installed on my laptop so I can test php. I followed each of the step and passed all the test above.
When i try to install php web package , it shows blank page.
can you pls advise what went wrong? thanks
Thanks a lot….
Thanks for the great article . You have given the great support to install.
Here is a video tutorial on setting up phpmyadmin
http://www.youtube.com/watch?v=AdV2Yhg__YE
That works like a pro. 🙂
Thanks.
I keep this page for my personal reference on http://www.webnapps.co.uk/helpful-links
I hope this will be OK with you.
Cheers.
It is a useful topic, I have done lamp and phpmyadmin setup to study this above topic.
Thanks for all the support
Thanks, did something wrong when i tryed to set up some virtual hosts, my lamp server didn’t host anything. But i did run http://tuxtweaks.com/2010/01/how-to-uninstall-lamp-in-ubuntu-9-10-karmic-koala/ and this guide and now my Lamp works better then before.
😀
I was searching this for 3 days. Thanks very much ..!! problem was 404 not found .!! now it’s sorted.! 100% working.
This is the first time I see a crisp and clear work instruction like this. Superthanks!
Thanks a lot
Thanks a lot! A very informative article which made easy the LAMP installation within short time;Can you please add squirrelmail server also
download and install lamp on ubuntu 11.10 done easy.
terminal in ubuntu 11.10 is accessed by pressing ctrl + alt + T.
installation done!!
Would you be willing to do an article like this for a LAPP (Linux Apache PostgreSQL PHP) server install? It would be great if there was a sudo apt-get install lapp-server^ option.
Thanks, great article! I particularly like the sudo apt-get install lamp-server^ information and the fix common problems with phpmyadmin because that is exactly what I did wrong. Oh, the tee command was nice too! 🙂
Thanks a lot , It was like cake – walk .
all went smoothly, thanx a bunch, except the last bit. i got this error.
tanuwa@tanuwa-Satellite-L310:~$ echo “ServerName localhost” | sudo tee /etc/apache2/conf.d/fqdn
ServerName localhost
tanuwa@tanuwa-Satellite-L310:~$ service apache2 reload
* Reloading web server config apache2 ulimit: 88: error setting limit (Operation not permitted)
httpd not running, trying to start
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action ‘graceful’ failed.
The Apache error log may have more information.
[fail]
Oops. I forgot to include a sudo before the last command. It should read
[term]sudo service apache2 reload[/term]
Thanks for your comment. I’ll fix the instructions.
Excellent help many thanks.
Not 100% sure of Ubuntu 11.10, much prefer 10.04. but I guess I’ll get use to it…
Don 🙂
Yeah, I’m still using 10.04 as my main desktop. I can’t stand Unity, so I’ve installed the fallback session on 11.10.
nothing, i can’t connect or ping http://localhost/phpmyadmin
i had clean cache, etc but nothing.
🙁
support please
I think that you did not press for this step “Make sure to then mark apache2 by having the cursor next to apache2 and then hitting to mark it with a *, then hit .”
plz repeat this portion
“Fixing some common problems
Fixing phpMyAdmin” from the above link
I had same issue like u
Thanks for the common fixes bit. I forgot to select the Apache2. Maybe you should write that the user should click the spacebar in the Tut for those of us who are new to Ubuntu Server.
thanks again.
Thank You…It’s very helpful 🙂
A+!! Cheers for this.. Very simple walk through.. Also, thank you for the 404 fix for phpmyadmin! When I first installed I assumed that apache2 was already selected due to the red box.. Who would have thought to press space!!!
apprecialble support!!!!!