Welcome back! In Part 1 of this tutorial, I looked at installing the tools you need to get your own web server up and running on Ubuntu.
We now have a working web server, but there are a few neat things you can do and we need to put some content on our default website too!. First of all, if you hadn’t already worked it out, you can browse to your website by pointing your browser at http://localhost/.
By default, you won’t see much on the homepage of your site.
Changing your homepage and adding content
Your website information is stored in /var/www - that is where you need to place the files for your website. Out of the box, you won’t have write permission to this folder, so first of all we need to change that by changing the ownership of the folder to your user.
At a terminal, do the following (replacing yourusername with your login name):
$ sudo chown -R yourusername /var/www
Now, you can open up a file manager (from Places > Home Folder) and then navigate to /var/www. Simply place your HTML or PHP files in this folder and they will work as your website.
Testing that PHP is working
To make sure that your PHP installation is configured properly, you may want to run a quick test. Create a blank text file, call it phpinfo.php, and put this in the file. If you now save that file and view it in your browser, you should see a page looking something like this:

This means that your PHP installation is working properly.
Installing PHPMyAdmin
One of the easiest ways to manage your new MySQL database server is to use the graphical tool PHPMyAdmin. Now you can grab the source code and drop it inside a folder in /var/www, but there’s actually an even easier way.
Simply go to your terminal again and enter the following command:
$ sudo apt-get install phpmyadmin
Now just point your browser at http://localhost/phpmyadmin/. Simple as that.
Installing web applications (WordPress)
One thing you might want to do with your server is install a web application onto it. In this example, I’m going to briefly show you how to install WordPress, one of the most popular blogging software tools (which we use here at FOSSwire). These steps can be adapted for most applications though. We can use the old apt-get trick here, but I’m not going to, as you might want to know the traditional way to install an application.
First of all, let’s create a MySQL database for our WordPress installation. Head over to your new PHPMyAdmin installation, login with the username root and your MySQL root password that you set in Part 1.
Type wordpress in the create database box and click Create. When that finishes, click the SQL tab and type in the following:
GRANT ALL ON wordpress.* to wordpress@localhost IDENTIFIED BY ‘newwordpresspassword’;
Replacing the password with a new password that WordPress will use to connect to its database (make it a separate password from the root user’s). Now download the .tar.gz WordPress package from wordpress.org (I’m using version 2.2 for this tutorial).
Once you’ve downloaded the package, right-click it and choose Extract Here to extract the archive. Now move the contents of the wordpress folder to the desired folder (I want my WordPress installation to be in a subdirectory called /blog on my web server, so I’m copying the files to /var/www/blog).
Open up the wp-config-sample.php file in your WordPress directory and change the following lines:
[php]define(’DB_NAME’, ‘wordpress’); // The name of the database
define(’DB_USER’, ‘wordpress’); // Your MySQL username
define(’DB_PASSWORD’, ‘yourwordpressdatabasepassword’); // …and password
define(’DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value[/php]
Substituting in your password, obviously. Save that file, then rename it to wp-config.php.
Now browse to your new blog URL (in my case http://localhost/blog). From there, follow WordPress’s easy install interface to set up your blog!
Finishing up
So we now know that our PHP is working properly, we have PHPMyAdmin set up and running and we’ve managed to install WordPress manually from the download on the site. Your LAMP installation is now officially up and running.
Of course, there’s plenty more you can do and loads of PHP and MySQL based applications you can now download, install and give a try. If you’re the developing type, you now have everything you need to start developing your PHP and MySQL based applications!


FOSSwire » Installing and configuring LAMP on Ubuntu - Part 1 wrote:
[...] Posts Installing and configuring LAMP on Ubuntu - Part 2Welcome back! In Part 1 of this tutorial, I looked at installing the tools you need to get your own [...]
# Posted on 01-Jun-07 at 11:02 am
Derek wrote:
I get the error ” Your PHP installation appears to be missing the MySQL which is required for WordPress.”.
I did exactly as described above (god im such a loser:) What am i doing wrong?
Im new to all things LAMP so would really like to get it going. I did retry things a couple of times. Seemed to go all ok I suppose till I create a new mysql database wordpress. Wordpress (0) creates ok and then I paste the code into the sql tab replacing the password with one ive made up…
any ideas?
thx
D
# Posted on 01-Jun-07 at 3:11 pm
Peter wrote:
Did you follow Part 1 of this tutorial to get the initial software installed?
If not, you might not have installed the MySQL database properly, so try this command:
Alternatively, you may be able to get WordPress installed using the package manager (the easier way, but we showed the universal way in this tutorial):
That command should pull down the MySQL database server as a dependency and should configure stuff for you.
Let us know in the comments how you get on!
# Posted on 01-Jun-07 at 11:28 pm
Derek wrote:
Hi.
Thanks
Well i redone everything and went ‘by the book as they say…Everything seemed to work fine now…Dont know where i went wrong.
This time i simply copied and pasted the apt-get commands for apache and mysql etc…
roll on part 3
Derek
# Posted on 03-Jun-07 at 12:51 pm
Josh wrote:
This tutorial is what I have been looking for… amazing. Simple and to the point. I have been trying to set up a local mirror for my website, and couldnt seem to get LAMP to work… now I have it running great. Thanks for the info… =)
# Posted on 04-Jun-07 at 12:37 am
Dan wrote:
I followed the tutorial word for word and nothing seems to be matching what I’m seeing in print. I am Using Ubuntu Feisty, as well, so I’m confused. First, my Apache2 ended up in /usr/local/apache2… not /var/www.
Second, whenever I try to open a .php document in my newly created Apache setup, it tells me that I am trying to download a file of type .php… do I want to open it with GEDIT or save it to disk. What??? I want to view the web site… not save it as a file.
What did I do wrong? It’s probably something very simple…
Thanks!
# Posted on 12-Jun-07 at 8:56 pm
hanifa wrote:
Great website… Most of the other websites i have seen , usually are talking about the Ubuntu Server edition…
With this tutorial, I was able to set up the LAMP structure within 10 minutes…Kudos to U, guys
# Posted on 15-Jun-07 at 12:29 am
Isal wrote:
Great Tutorial. I like it. Now I have clear guiance how to set up LAM server in Ubuntu. Thanks
# Posted on 17-Jun-07 at 9:20 pm
Christophe wrote:
Great tutorial indeed,
However how do I use php as command line ?
(I think i’ll need it later to run cron jobs, php scripts ..)
Should I install php5-cli to get PHP’s interpreter in my shell ?
Thanks!
# Posted on 14-Jul-07 at 6:26 pm
Tengku Asmadi wrote:
Thanks!
It works! This is the easier and simple tutorial to get my LAMP and Worpress running. I never use Linux before but your article does help me a lot…
God bless you.
# Posted on 28-Jul-07 at 8:21 pm
JohnMcC wrote:
Works like a charm. Thanks.
If only all tutorials were as up to date and work as they are supposed to.
# Posted on 10-Sep-07 at 9:56 pm
Kris Stevens wrote:
Thank you so much for posting this wonderfully informative tutorial. I have just (in the last few days) moved over to Kubuntu from Windows Vista. I was previously running a WAMP server on my XP system but it was a nightmare trying to support it on Vista.
I was advised to give Ubuntu a try, but found I preferred Kubuntu layout more. I was also advised to get the LAMP setup on the Ubuntu system. Now after a few days of tinkering with various pieces of software and even trying some Windows software using Wine and CrossOver, I decided to take the plunge and transfer my web server to the new system.
I went on Google looking for the various bits I needed and was about to start setting them up - THEN I came across your tutorial.
Bearing in mind I have never even seen a Linux system before this week never mind used one - I have manage to get the LAMP server up and running and configured in about 3 hours - It took me 2 days to sort out the WAMP version.
Thanks again for such helpful advise.
Kris Stevens
West Yorkshire, UK
# Posted on 23-Sep-07 at 7:50 am
Guesh wrote:
$sudo chown -R myusername /var/www
I run this command, but couldn’t be the owner of. I couldn’t put any files to /var/www. When i see at the permisions only the root
can read, write, and excute.
This tutorial is superb. By the way, my ubuntu is ubuntu-6.10 somthing( i don’t know if it has another name)
# Posted on 21-Nov-07 at 6:09 am
Peter wrote:
hi Peter,
my name is Peter too and I want only say to you,your
lamp-tutorial is semantic-good or rhetorik-good,its simple
good and understandable (my wordcreation !!)
good times and thank you Peter
# Posted on 04-May-08 at 7:43 pm
Kris wrote:
Thanks for the Great Howto
# Posted on 11-May-08 at 5:05 am