Installing LAMP On Ubuntu For Newbies

Want to support HowtoForge? Become a subscriber!
 
Submitted by Cargoship (Contact Author) (Forums) on Fri, 2007-07-13 15:57. :: Ubuntu

Installing LAMP On Ubuntu For Newbies

In this guide I will show you how to install a LAMP system. LAMP stands for Linux, Apache, MySQL, PHP. The guide is intended to help those who have very little knowlegde of using Linux.

 

Install Apache

To start off we will install Apache.

1. Open up the Terminal (Applications > Accessories > Terminal).

2. Copy/Paste the following line of code into Terminal and then press enter:

sudo apt-get install apache2

3. The Terminal will then ask you for you're password, type it and then press enter.

 

Testing Apache

To make sure everything installed correctly we will now test Apache to ensure it is working properly.

1. Open up any web browser and then enter the following into the web address:

http://localhost/

You should see a folder entitled apache2-default/. Open it and you will see a message saying "It works!" , congrats to you!

 

Install PHP

In this part we will install PHP 5.

Step 1. Again open up the Terminal (Applications > Accessories > Terminal).

Step 2. Copy/Paste the following line into Terminal and press enter:

sudo apt-get install php5 libapache2-mod-php5

Step 3. In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:

sudo /etc/init.d/apache2 restart

 

Test PHP

To ensure there are no issues with PHP let's give it a quick test run.

Step 1. In the terminal copy/paste the following line:

sudo gedit /var/www/testphp.php

This will open up a file called phptest.php.

Step 2. Copy/Paste this line into the phptest file:

<?php phpinfo(); ?>

Step 3. Save and close the file.

Step 4. Now open you're web browser and type the following into the web address:

http://localhost/testphp.php

The page should look like this:

Test PHP Page

Congrats you have now installed both Apache and PHP!

 

Install MySQL

To finish this guide up we will install MySQL. (Note - Out of Apache and PHP, MySQL is the most difficult to set up. I will provide some great resources for anyone having trouble at the end of this guide.)

Step 1. Once again open up the amazing Terminal and then copy/paste this line:

sudo apt-get install mysql-server

Step 2 (optional). In order for other computers on your network to view the server you have created, you must first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file.

gksudo gedit /etc/mysql/my.cnf

Change the line

bind-address = 127.0.0.1

And change the 127.0.0.1 to your IP address.

Step 3. This is where things may start to get tricky. Begin by typing the following into Terminal:

mysql -u root

Following that copy/paste this line:

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

(Make sure to change yourpassword to a password of your choice.)

Step 4. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:

gksudo gedit /etc/php5/apache2/php.ini

Now we are going to have to uncomment the following line by taking out the semicolon (;).

Change this line:

;extension=mysql.so

To look like this:

extension=mysql.so

Now just restart Apache and you are all set!

sudo /etc/init.d/apache2 restart

 

The End

Quick note to anyone who encountered problems with setting up the MySQL password, please refer to this page: MysqlPasswordReset

I applaud everyone who has taken the time to read this guide. This guide is also my first ever so I would love to hear back from the public on what you guys think! Just don't be too harsh. ;)

If you have questions about installing any part of LAMP just drop them in the comment box and I will do my best to help you out.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Mon, 2010-04-26 13:59.

how i uninstall all that i installed.

everything was woking but after a restart i tried to change data base password now i get error in phpMyAdmin

Error

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

so it thinking just unstall the whole thing and try again.

Submitted by jeremy (not registered) on Sun, 2010-04-25 08:17.
a lot
Submitted by JimNYC (not registered) on Sat, 2010-04-24 00:11.
I didn't realize how relatively painless this could be on ubuntu. my thanks
Submitted by Anonymous (not registered) on Wed, 2010-04-21 21:36.
Thanks, that was painless.
Submitted by Mykell (not registered) on Mon, 2010-04-19 06:45.

But one more question about phpmyadmin:

 I got it to the point where http://localhost/phpmyadmin says 403 Forbidden. Any suggestions?

 (If it's relevant, I'm using Ubuntu Hardy Heron, and my webpages are in /usr/local/apache/htdocs)

Submitted by pankaj (not registered) on Sun, 2010-04-18 10:07.

thank you..

you made it easy to configure.

thanx a lot

Submitted by Anonymous (not registered) on Sun, 2010-04-18 08:52.

I really appreciate this how-to!

I'm building a website for a club at school, and I needed a LAMP server to create it on. I've looked at several tutorials, and this was the only one that even steered me anywhere near the right direction. Thanks to this, I can finally get to work on the site!

Submitted by Anonymous (not registered) on Thu, 2010-04-15 08:56.
Thank you so much for providing this excellent tutorial on LAMP configuration
Submitted by mah! (not registered) on Thu, 2010-04-15 01:43.
thank you for your guide given... i've learned so many things... thank you again...
Submitted by Anonymous (not registered) on Mon, 2010-04-12 02:59.
This was unbelievably helpful. THANKS
Submitted by Cyndi (not registered) on Thu, 2010-04-08 18:59.
Awesome newbie instruction.  Thanks!!
Submitted by Andiluvslinux (not registered) on Sat, 2010-04-03 08:22.

Hey Cargoship,

Your instructions were absolutely brilliant for me as a newbie in linux. Love the easy understandable instruction, though I wasn't quiet sure about one thing. I had to change the bind-address to my ip. Does that mean I have to change it to the IP address to the one assigned by my LAN or are you refering with that to the WAN address? As I said, these are my first steps in web-server doings. But otherwise awesome site ! Well done !

 regards andiluvslinux 

Submitted by Dazza (not registered) on Fri, 2010-04-02 14:39.

Nice guide.  Brief but all the right info in the right places.

 

Cheers!

Submitted by Artem (not registered) on Tue, 2010-03-30 03:47.

Many Many Many big THANKS!!!

I'm newbie to this and it not just helped, I installed everything almost w/o any troublems... Well one of the comments helped me with one problem but it was nothing big.

Installed it, now to learn how to use all this crap! LOL

THANKS A LOT again!

Submitted by Arpan (not registered) on Fri, 2010-03-26 15:49.

Thanks man!

I installed everything very smoothly with your help.

Can you please tell me a good manual for mysql.

 Thanks in advance for your help

Submitted by Anonymous (not registered) on Sun, 2010-03-21 23:02.
great instructions ! -- thanks
Submitted by MPG (not registered) on Wed, 2010-03-17 02:25.

In phpMyAdmin I get "No Privileges" under the area to create a new database.

 I get this on my account (MPG) and root...

Submitted by 除草 (not registered) on Tue, 2010-03-16 11:41.
Thank you very much. This guice is useful, just for the new PHPer.
Submitted by Mostafa (not registered) on Mon, 2010-03-15 10:17.
When trying to save the php test file to /var/www i get the "you don't have permission to save file here" error. should i change the permission of the folder or not? Actually i'm a noob in ubuntu and i read somewhere that it is better to not change the permission of the var folder. so what shall i do now?
Submitted by Anonymous (not registered) on Thu, 2010-03-25 18:37.

Did you use

sudo gedit /var/www/testphp.php

for editing the file?

The "sudo" is important to temporarily get root privileges.

Submitted by jester (not registered) on Fri, 2010-03-12 05:29.

you also need to include the following line in /etc/apache2/apache2.conf
first type the following command to open up this file:gksudo gedit /etc/apache2/apache2.conf
Add the following line of code inside apache2.conf:Include /etc/phpmyadmin/apache.conf
 save it and restart apache:
sudo /etc/init.d/apache2 restart

Submitted by Anonymous (not registered) on Sat, 2010-05-29 04:38.
Thanks dude, its really help me.out to phpmyadmin work correctly..
Submitted by Chris (not registered) on Fri, 2010-03-12 05:11.

Great post...

You said it was newbies...that wasn't the case since my installations took some turns that newbies might not logically put 1 and 1 together, ya know?

But you surely made it easy for me... Thanks again!

Submitted by Anonymous (not registered) on Fri, 2010-03-12 03:55.
this was quick and easy not hard at all the pasword thing throw me off cause it just pushed me into making a password i didnt need to go through the password step but not hard at all
Submitted by milamoto (not registered) on Thu, 2010-03-11 18:50.

Your tutorial is excellent.

Thanx!

Submitted by anand ganti (not registered) on Fri, 2010-03-05 01:53.

good great post

 

Submitted by Anonymous (not registered) on Wed, 2010-03-03 23:13.
Simply thank you!
Submitted by Ravi Veliyat (not registered) on Wed, 2010-03-03 09:59.

I have used php-mysql in windows already...

but i was totally unknown to Linux or Ubuntu..

then the guidelines provided by you helped me..

i found it very easy to install php in ubuntu..

 

Thanx man..!

Submitted by Anonymous (not registered) on Sun, 2010-02-14 11:38.
Many thanks for your Lamp Install guide. As a newbie I found it very easy to follow. It worked perfectly without a hitch.
Submitted by outstanding! (not registered) on Sat, 2010-02-13 01:30.

Thankyou!

 

This was perfect for a newbie like me.  Please, write more guides just like this.

Submitted by Anonymous (not registered) on Thu, 2010-02-11 20:11.

Needed a quick and dirty way of getting a LAMP environment going (I haven't touched *nix in ages) and your guide was a Godsend!

 

Nice job - thank you!  :)

Submitted by James (not registered) on Mon, 2010-02-08 23:45.

This was much easier than the xampp on Ubuntu install I did a couple months ago, which involved searching to solve "after install" problems. But your nice simple straight forward guide?... No problems at all. Everything works. Beauty!

And now I have a bonafide real deal lamp install :) - Sweeeeet!

Submitted by Da Vidis (not registered) on Thu, 2010-02-04 14:27.
Many thanks, the LAMP installation was smooth
Submitted by kostaslivs (not registered) on Wed, 2010-02-03 13:27.
THE BEST!
Submitted by Lippy (not registered) on Sat, 2010-01-30 18:06.
Thanks for the guide.  Made installing everything easy for a course I am taking that requires I create a database and front end website in php for it.
Submitted by kingkeamo (not registered) on Fri, 2010-01-29 10:26.

great tutorial thank you

 

Submitted by Juan Alejandro ... (not registered) on Sun, 2010-01-24 20:59.

Hi I installed the lamp on my ubuntu server and everyhitng is almost perfect just one problem.

 

I finished all but when i try to get into my /ipaddress/phpmydmin it is not working yet.

 

Can you tell me pleae how i can browse in my phpmyadmin page.

 

 

Thanks a lot.

Submitted by A. Self (not registered) on Sat, 2010-01-23 23:44.
I am new to Linux and definitely appreciate the easy walk-through on this process. Thanks!
Submitted by Bilal Malik (not registered) on Tue, 2010-01-19 19:10.

It was great help.

Thanks,

Bilal

Submitted by Joel (not registered) on Sun, 2010-01-17 16:36.
Had installed all the packages but was stuck with trying to figure out how to run the test scripts i was writing for the tutorials. All of them just said to post it to the web server document root and while i knew what that was, dint know where the local root was for apache! Anyway thanks again... i was getting desperate enough to consider just wamp and learning php.
Submitted by johny (not registered) on Fri, 2010-01-15 15:09.
Dont worry, your tutor was really helpful and easy to follow, 5 stars!!! ;-)
Submitted by Mark (not registered) on Wed, 2010-01-13 12:43.

I followed your instructions and it all worked perfectly first time.  The only difference was that the MySQL and PHPMyAdmin both prompted for passwords and usernames etc so there was no need to tinker with configuration files.

 Nicely presented HowTo.

Submitted by sunil (not registered) on Tue, 2010-01-12 20:27.

hi sir

 after completion of Lamp installation on my system and when i am trying to open the following url i.e http://localhost/phpmyadmin it says phpmyadmin was not found on this server.So please do reply

 

Thanks and Regards

Sunil Jadhav 

Submitted by Sree (not registered) on Tue, 2010-01-12 03:23.
Thanks..
Submitted by john (not registered) on Sun, 2010-01-10 19:16.

Hey!!

 Bro that was smoooth sailing for me!! Thanks a lot.

 For your first tutorial it was really good!

 

Submitted by MSK (not registered) on Sun, 2010-01-10 15:56.
extremely useful. thanks
Submitted by Dave (not registered) on Sun, 2010-01-10 13:07.

Had to add LAMP via a remote system and it worked just fine with a few differences:

1) MySQL version  5.1.37-1ubuntu5 prompted for the root password thus eliminating the tricky part.

2) Didn't find the  ;extension=mysql.so  entry in php.ini, so I didn't make that change and as of yet, I am not experiencing any issues.

 Very helpful post

 Thanks

 Dave

Submitted by i hate mondays (not registered) on Sat, 2010-01-09 10:54.

well,thx helped me a lot...

 i had project to make  and it was kind of impossible to make under windows.and now ,after rethinking some stuff,i would love to permanently change my os to linux... 

 u should make more tutorials for newbs...there are a lot of us out here:))

Submitted by deeba (not registered) on Fri, 2010-01-08 11:14.
excellent job.thank u....
Submitted by Uly Marquez (not registered) on Thu, 2010-01-07 03:17.
 quick and easy kungfu for ubuntu.. thank you
Submitted by bryan (not registered) on Wed, 2010-01-06 19:43.
Great job!  This is the first one I found that worked!!
Submitted by Benito Estrada (not registered) on Tue, 2010-01-05 03:32.

Despite minor details your guide really helps, solid gold!

Thanks 1,000! 

Submitted by jellobelt (not registered) on Sat, 2010-01-02 20:59.

Thanks for this tutorial.  Everything is running smoothly now.  My only suggestion is to somehow improve search rank as I found this after three days of trolling.  Would have been great to find on day one. 

 

Submitted by Kris (not registered) on Sat, 2010-01-02 15:33.
tU, Happy New Year and more guides like this one, plz. Very well done.
Submitted by bouchardpie (not registered) on Wed, 2009-12-30 21:30.
Thanks much.  This was a big help.
Submitted by Claude (not registered) on Tue, 2009-12-22 19:25.
Instructions were very easy to follow. Anybody taking the time to thoroughly read the instructions will have no problem with the setup. Congrats on publishing these most helpful instructions. Great site!
Submitted by Woodd (not registered) on Wed, 2009-12-16 05:38.
Had a few problems with  restarting the apache server: "

“Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName”

 But I found a solution to this issue here:

http://mohamedaslam.com/how-to-fix-apache-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127011-for-servername-error-on-ubuntu/ 

Thanks again!

Submitted by MIchael (not registered) on Fri, 2009-12-11 01:52.

I followed the install as noted and it was fine up to the mysql install. The install now asks for information not covered in the guide, overall the guide is good but it needs to be updated.

 Michael

P.S. A nice little test Schema would be a nice touch to verify the mysql is working properly :)

Submitted by vinopavit (registered user) on Thu, 2009-12-10 01:56.

Superb Tutorial i have ever seen to install LAMP

Thank you dude

jus now i installed LAMP in my new ubuntu 9.10(Karmic Koala)

Installed finely except that restarting Apache 2 server

but atlast i edited Apche2.confg

Submitted by DFC (not registered) on Sat, 2010-05-29 02:41.

vinopavit, what did you edit in the apache2.conf file?  I'm having the same problem restarting apache.

 Thanks in advance!

Submitted by Anonymous (not registered) on Wed, 2009-12-09 15:04.
Thank you very much.It has been a very helpful article.
Submitted by hema (not registered) on Tue, 2009-12-08 16:33.
that was reaaly help full thnq for tht
Submitted by Ashish (not registered) on Tue, 2009-12-08 05:30.

Nice Tutorial, but please try considering need to execute this command below for changing phpMyadmin folder  to var/www

sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin

Thanks

 

 

Submitted by J Young (not registered) on Fri, 2009-12-18 16:08.
Thanks! This works great!
Submitted by Anonymous (not registered) on Tue, 2009-12-08 01:31.
Thanks for the awesome tutorial, I come here all the time! :)
Submitted by singermaa (not registered) on Sat, 2009-12-05 19:03.

It's Better then i've seen.

 

thanks you 

I'd looking for just this one

 

Good luck to you for more

Submitted by Ron (not registered) on Tue, 2009-12-01 21:21.

Great tutorial and lots of good tips in the posts.

Thanks

 

Submitted by sam (not registered) on Sun, 2009-11-29 19:09.

Nice post ..very clear explanations... thanks man..

 

Submitted by Jacques (not registered) on Wed, 2009-11-25 22:42.
minus the instruction on how to get phpmyadmin to work, this is A GREAT how-to! Thank you so much!
Submitted by Web design company (not registered) on Wed, 2009-11-25 18:59.
Thanks for the guide !
Submitted by Nater (not registered) on Mon, 2009-11-23 23:03.
I had no trouble following this guide it was well written and very helpful.
Submitted by Anonymous (not registered) on Wed, 2009-11-18 17:28.
This was by far simple and easy to follow. thanks  you are the real boss.
Submitted by HungryTom (not registered) on Mon, 2009-11-16 01:25.

Outstanding job! Up and running in no time. Thanks!

 PHPMyAdmin did not work until the following was added to /etc/apache2/apache2.conf :

Include /etc/phpmyadmin/apache.conf

So thanks to the guy who posted that one too :)

 

Submitted by Ross (not registered) on Sun, 2009-11-15 11:11.

Hi - have just worked through this tutorial and apart from one place where I misread the request (setting up phpmyadmin), and the requirement to provide the IP address - everything went smoothly.  Am not sure yet however whether I have actually succeeded in installing all.  It would have been nice at the end to have had some kind of test to do which would have shown unarguably that it was done (plus reinforce my efforts!) 

I guess I will find out soon enought whether things have installed properly and will now work. If they haven't I'll be looking for help!!

Cheers  R

Submitted by williambuell (not registered) on Wed, 2009-11-11 17:28.

Everything seemed to work like a charm!

Very clear instructions.

Now all I need to do is figure out how to get into mysql with some admin app.

My first try an any sort of installation was avg antivirus. I downloaded and installed the file, but I cannot figure out how to launch the app.

I will appreciate any tips on tutorials which will in crease my skills in installing and using apps in Ubuntu.

I suppose you could supplement this tutorial with a part 2 which then walks someone through the launching of these apps and creation of some simply application with table.

 

Submitted by Anonymous (not registered) on Wed, 2009-11-11 13:55.

Thanks for the tutorial for installation...

Now I want to know how to run the php file in it?

Any one can guide me on that?

Submitted by joelotz (not registered) on Wed, 2009-11-11 04:04.

Great tutorial. I followed your instructions and sucessfully installed on Ubuntu 9.10

I used "sm1one" suggestion to add

ServerName localhost

to the httpd.conf file and it worked fine. The installation asked me for the MySQL password so I had no problems there also.

 Smooth installation - thanks!!

Submitted by dandellion (not registered) on Fri, 2009-11-06 11:33.

Great tutorial. Thanks a lot! Just one thing... please move the note about passwords from the end of the tutorial to the place where password should be changed ;)

 

Submitted by StigMcSobol (not registered) on Fri, 2009-11-06 03:09.

Hard work, but a well paced guide.

Thanks for making the first effort.


 

Submitted by Evgeny Ustimenko (not registered) on Sun, 2009-11-01 14:19.

ivan@805-room:~/Documents/jmonitor$ sudo /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 ]

Hello, I have a problem.

I think that it isn't clear... What I should do?

 

P.S.: I have an Ubuntu 9.10


Submitted by sm1one (not registered) on Sun, 2009-11-08 11:14.

To fix that problem, you need to edit the httpd.conf file. Open the terminal and type,

sudo gedit /etc/apache2/httpd.conf

Now, simply add the follwing line to the httpd.conf file.

ServerName localhost

Save the file and exit from gEdit.

Finally restart the server.

sudo /etc/init.d/apache2 restart
Submitted by Brian UbuntuUser (not registered) on Sat, 2009-10-31 16:05.

Thanks for a great LAMP tutorial worked fine for me on Ubuntu 9.10

Setting up passwords where completed via the intall process so had to by-pass that point in your tutorial.

Thanks

Submitted by Anonymous (not registered) on Sat, 2009-10-24 07:47.

Excellent overview. Helped me a lot. However, I think you may have overlooked the need to add the following to apache2.config:

Include /etc/phpmyadmin/apache.conf

Submitted by Anton Agestam (not registered) on Fri, 2009-11-13 17:47.
Thanks, phpMyAdmin refuses to work without that!
Submitted by Joseph (not registered) on Wed, 2009-10-21 05:33.
Thank you for the tutorial.  I have set up LAMP before, this is about as easy as I have ever had it. 
Submitted by tskrich (not registered) on Sat, 2009-10-17 13:31.

Fabulous instructions!!!!

 I followed each instruction and was able to successfully setup this correctly for the first time.

 

Submitted by ronald schilperoort (not registered) on Thu, 2009-10-15 22:15.

Hello

 

Many thanks for the greate tutor you made how to setup a LAMP configuration in Ubuntu.

It helps me a lot to locally test Joomla packages

 

Thanks again

 

Best regards Ronald

Submitted by Ivaylo (not registered) on Thu, 2009-10-15 17:15.

The simplest way I know of installing a LAMP server in Ubuntu or Debian is to let Tasksel do it:

sudo tasksel

- select 'LAMP Server' and then follow the prompts.  You can make adjustments to the configuration as needed after the install but you will have a working LAMP server right out of the box!

 Cheers!

Submitted by Vikram TV (not registered) on Thu, 2009-10-15 12:25.

Thanks a lot.. I have been trying to configure my lamp server and succeeded now.. Nice explanation..

 

Cheers:-)VIKRAM

Submitted by OFF732 (not registered) on Sun, 2009-11-08 09:32.
I had that same problem and found out that I had not restarted apache. Once I... sudo /etc/init.d/apache2 restart it worked great
first page
previous page
4
next page
last page