Got a Linux PC you want to put to work? Maybe you’re not comfortable with the command-line only version of Ubuntu Server Edition. Here’s how to keep the standard Ubuntu desktop and add web-serving capabilities to it.

Whether you’re not comfortable with a command-line only system, you’re using your Ubuntu desktop for other things, or you just need it installed for a few particular apps, you can add Apache, MySQL, and PHP to any standard desktop installation of Ubuntu very quickly and easily.

The Simple Command

Let’s start installation with the use of a very clever command:

sudo apt-get install lamp-server^

It will NOT work without the caret at the end. Once you’ve got that entered, you’ll see that it auto-selects all of the necessary packages and will ask you to confirm the “large” amount of data to be downloaded.

02 confirm

Just sit back and let it do its thing until you get a blue screen pop up.

03 mysql root password

Enter a password for the MySQL root account, which is what you’ll need to create other users and manage databases, then hit Enter to continue. You’ll be prompted to re-enter your password, so do that and hit Enter again.

That’s it for installation!

Testing Apache and PHP

Let’s test Apache to see if it’s serving properly. Open up a browser and direct it the following URL:


You should see something like this appear if everything installed correctly:

05 testing apache

Next up, we’ll test to see if PHP is working. In terminal, enter the following command to create a new document:

sudo nano /var/www/testing.php

Then, copy the following code:

<?php phpinfo(); ?>

Right-click in your terminal and hit paste.

07 phpinfo

08 nano write-out

Hit CTRL+O to “write-out” or save the file, and then hit CTRL+X to quit.

Next, restart Apache with the following command:

sudo service apache2 restart

And load up the following page in your web browser:


And you should see something like this:

10 php success

Checking MySQL Bind Address

MySQL has a bind address that should match your system’s. To check your system’s bind address, we can use a quick command:

cat /etc/hosts | grep localhost

That’s a “pipe” or a “stem” in the middle, which is shared with the \ key. You’ll get a couple of results, one of which will show you an IP address.

11 find localhost bind address

You can see from the screenshot above that my bind address is

Next, let’s open up the MySQL config file to see what’s listed there.

sudo nano /etc/mysql/my.cnf

Scroll down until you see a line beginning with “bind-address” like below.

12 my.cnf bind address good

As you can see, the bind-address is the same, so we’re good. If yours is different, just change it so it matches what you found above.

Installing phpMyAdmin

If you’re not familiar with MySQL and its commands, then you may have some trouble managing databases and tables. phpMyAdmin helps you tackle that by providing a PHP interface for MySQL administration. It’s easy to install and can really come in handy, so let’s get to it.

sudo apt-get install phpmyadmin

If this command doesn’t work, you may need to enable additional repositories.

14 installing phpmyadmin

You’ll get another blue screen come up asking you to choose which web server to configure. Make sure the red block is next to “apache2” and be SURE to hit the Space bar. This will mark it with an asterisk, and then you can hit Enter.

15 select apache2 for phpmyadmin

You’ll be asked if phpmyadmin should configure a default database for its own use. Choose Yes.

16 yes to default db

Next, you’ll be asked to enter the password of the admin account used to create this database and user. Since we haven’t created any other MySQL users, enter your MySQL root password.

17 enter mysql root password

Lastly, you’ll create a password to use with phpmyadmin, and you’ll have to confirm it again.

18 password for phpmyadmin

Once you’re done, restart Apache.

You can log in to phpMyAdmin by going to the following URL:


20 phpmyadmin success

Use “root” as the username and then enter the root MySQL password.

21 login success

There’s more than a few important passwords here, and you’ll be tempted to use the same password as your root account. If you choose to do this, be sure that it’s a very secure password, something with mixed character classes and a good length. Remember, you are giving others access to your computer by installing this software, so take proper precautions.

If this is your first time playing with a web server, you may be wondering where the files you want to host go. They’re in /var/www/ be default, and will need elevated privileges to access that directory. One idea is to mount a separate partition to that point to be used solely for serving web stuff. Check out our other article, What is the Linux fstab and How Does It Work?, to get some more information for that.

And, now that you have your own web server, why not learn How To Archive, Search, and View Your Tweet Statistics with ThinkUp?