
If you are doing any type of development on a Linux box you are probably going to need the LAMP suite. That is, Linux, Apache, Mysql, and PHP. This is by far the most common collection of apps used to serve web content. It is often used to serve open source projects like Wordpress and many others. The other benefit is that it is free!
In this guide I am going to assume you already have Ubuntu 8.10 (intrepid) installed. If not you can head over to Ubuntu.com and grab it.
Installation
Apache
The first app we will install is the web server Apache. To get started open your console and type:
After you put in your password and accept and a short wait you should have a working installation of Apache. To test it point your web browser to http://localhost

PHP
Once this finishes we need to restart Apache. This will apply the changes.
Now lets test it by replacing ‘/var/www/index.html‘ with index.php adding the following line:

MySQL
Install all the MySQL stuff:
When you get a prompt enter a password you would like to use as the root MySQL user.
Once done open, ‘/etc/mysql/my.cnf‘ and change the bind-address to your local IP. (usually 192.x number).

Extra Stuff
phpmyadmin
After phpmyadmin is installed you can see it view it, http://localhost/phpmyadmin/.
mod_rewrite
Chances are you want to use mod_rewrite in your applications to make URLs a bit more pretty. It is also required by lots of software, like Wordpress.
/etc/init.d/apache restart
Starting and Stopping Apache
Run, Stop, Test, And Restart Apache
Use the following command to run Apache :
To stop it, use :
To test configuration changes, use :
Finally, to restart it, run :
Was this information useful?
31 Responses
-
More simply, the LAMP stack can be installed using this one-liner:
sudo apt-get install lamp-server^
The carrot is NOT a typo; it needs to be there. More information here: https://help.ubuntu.com/community/Tasksel
-
Mark Sanborn
2-11-2009
Awesome tip, didn’t know about the debian/ubuntu tasksel program. Thanks adam!
-
Cool guide thanks, I be diggin
-
Shawn
2-15-2009
Just wondering if you had any tips for someone trying to follow this guide instead of a prior xampp installation.
I have followed up until the point of installing apache2 and when I test localhost, my url gets defaulted to localhost/xampp.
Now I’m not sure what to do at this point b/c all prior documentation tells me that to remove xampp I just run rm -rf /opt/lampp where that is the folder I installed xampp in.
any advice?
-
[...] This will get you up and running fast: Installing Apache Mysql and PHP on Ubuntu 8.10 [...]
-
Vijay Patil
3-7-2009
Nice step by step instruction. For those who wants to install the stuff individually. Keep up the good work.
-
Fredrick onyango
3-13-2009
This tutorial is fantastic.Though I’m new to Linux It made everything look cheaper than I thought.Thanks a lot
-
I’m basically a Windows user… But installing Apache, PhP, Mysql on Windows is a pain in the ass… So thought to install ubuntu and this guide is so cool… It made the installation in a ziffy… Thanks.. Digged!
-
Felix
3-26-2009
just followed the procedures:
after installing myphpadmin and testing http://localhost/myphpadmin/ i get 404 not found error
any ideas why?
-
Mark Sanborn
3-26-2009
Because you didnt follow the procedure carefully enough
You type phpmyadmin, not myphpadmin. -
Etomak
4-9-2009
Nice guide but having problem saving index.php on /var/www
Thanks.
-
Etomak
4-9-2009
this is the error.
“You do not have the permissions necessary to save the file. Please check that you typed the location correctly and try again”
any idea?
-
Mark Sanborn
4-10-2009
Use sudo or root to modify the file for this test purpose.
-
Etomak
4-10-2009
Thank you, everything work right…
-
Etomak
4-10-2009
pardon for may innocence.
I encounter this error
Fatal error: Call to undefined function mysql_connect() in /var/www/myapp/con.php on line 4
here is the function that causes the error
function connect(){
$link = mysql_connect(“localhost”, “usr”, “pass”)
or die(“Could not connect to the Database Server!”);
$db = mysql_select_db(“mydb”, $link) or die(“Could not select Database!”);}
thanks in advance
BTW I can’t edit ‘/etc/mysql/my.cnf‘ again I do not have the right to made changes on the file.
I would like to change the permission but did not know if it is right.
-
That means you don’t have mysql support in your php install.
sudo apt-get install php5-mysql
Should take care of that.
Just sudo gedit and open the file to edit your mysql conf!
-
Etomak
4-11-2009
thanks for the reply, I did what you told me but still throwing same error.
-
Mark Sanborn
4-11-2009
Jade is correct, you need to install php5-mysql as per his instructions and also in the article.
You also need to remember to restart the apache service when you are done for the changes to take effect.
-
Etomak
4-12-2009
It works after restarting the apache..
thanks guys….
-
Excellent guide – Clean and simple!
Just a comment about the last step when restarting Apache (again). If you follow the guide from the start, you should restart Apache using “sudo /etc/init.d/apache2 restart”, not “/etc/init.d/apache restart” as the guide says in the step for mod_rewrite.Anyways, awesome step-by-step guide that makes life easier for everyone!
-
nop2
4-15-2009
thanks a lot..
-
Kingsley
4-20-2009
Hi Thanks for your article. Now how do i install Oracle and connect to it on Ubuntu?
-
h2o
4-25-2009
Thanks!
-
this is awesome! thanks
-
senthil
7-8-2009
thanks for ur guide i have problem like i could not save the file in www directory .how can solve pls reply me
-
senthil
7-8-2009
The requested URL /phpmyadmin/ was not found on this server.
this the message i got while openning the phpmyadmin
-
senthil
7-14-2009
hai i can access a file linux apache www root folder
it shows i not have access permission bit try command like sudo instead it show user is not on sudouser file pls help me …. -
I’m testing each of them one by one on my SSH terminal. But that’s really quite a lot to digest. Seems it’d take a long time before I read through every article of this blog.
-
thank you very much. it help me alot especially installation on lamp. nice work and keep this guidance forever for those who needed. i will always support open source.
-
adr
1-24-2010
I’ve been trying to get this to work but get as far as installing phpmyadmin but when I go to check I get the 404 Not Found error message.
I’ve spent two days trying to find out what’s gone wrong. Any ideas where I should be looking?
-
David
2-14-2010
I am new linux and this was very helpful. Thank you so much.




2-11-2009