LAMP on Ubuntu 11.10

Install LAMP and phpMyAdmin on Ubuntu 11.10

The Ubuntu development team has made it very easy to install and set up a web server. Open a terminal window and enter the following command.
sudo apt-get install lamp-server^

Please enter the command exactly as it’s shown above. The carat (^) is not a typo and the command will not work without it.

Command to install LAMP

If prompted, enter your password.

The package manager will now display a list of packages to be installed. Hit to confirm that you want to go ahead with the install.

Installing LAMP packages

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.

MySQL password

You will then be prompted to confirm your password.

Confirm MySQL password

Type in the same password and hit . 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 https://localhost/. You should see a page that says “It Works!”

Testing Apache installation
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.
echo “” | sudo tee /var/www/testing.php

Enter your password if prompted.

Now you’ll need to restart the Apache web server. Enter into the terminal:
sudo service apache2 restart

Now open your web browser and enter the following address: https://localhost/testing.php

You should see a web page that displays a bunch of information about your php and Apache environment.

Testing php
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 by default. You can verify your localhost address with the following terminal command.
cat /etc/hosts | grep localhost

You should see output something like this: localhost
::1 ip6-localhost ip6-loopback

Now you need to verify that this address is the bind address MySQL’s my.cnf file. Use the following terminal command.
cat /etc/mysql/my.cnf | grep bind-address

You should see output like this.

bind-address =

If it’s not correct you’ll need to edit /etc/mysql/my.cnf as root to fix it.
Install phpMyAdmin

You now have a functioning LAMP installation. You don’t need to install phpMyAdmin, but it provides a much easier way to administer your MySQL databases if you’re not familiar with MySQL’s commands. You can install phpMyAdmin with:
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

Enter your password if prompted.

Installing phpMyAdmin

Again the package manger will show you the packages it’s about to install. Hit to move forward with the installation.

The package manager will now begin downloading and installing packages. After a short wait you will be prompted to choose the web server to configure for phpMyAdmin. Hit to mark apache2 with an asterisk (*) as it’s shown in the following picture (click on the image to see it in full size). Then hit .

Select apache2

The next screen will ask about some automatic database configuration with dbconfig-common. Hit to accept the default and move on.

Configure phpMyAdmin with dbconfig-common

Next you’ll be prompted for the MySQL administrator password. Enter the password that your created earlier.

Enter MySQL administrator password

Now you’ll be prompted for a MySQL application password. You can allow the system to generate a random password or choose your own.

Enter MySQL application password

If you choose your own password, you will be prompted to verify it at the next screen.

Verify MySQL application password

Your phpMyAdmin installation and configuration is now complete.
Testing phpMyAdmin

Open your web browser and enter the address https://localhost/phpmyadmin/.

You should see a page like this.

phpMyAdmin login screen

Now log in with the user name root and the password that you created earlier in the tutorial.

phpMyAdmin Home screen

Congratulations, you now have a working web development environment set up on Ubuntu 11.10. You can place the files for your website under /var/www. Note that this location is owned by the root user, so you’ll need to copy your files over as root for it to work. Otherwise, you can do some further Apache configuration so you can place the files for your website in a directory somewhere under your home directory.
Fixing some common problems
Fixing phpMyAdmin

One common error that some people make is that they forget to mark apache2 during the phpMyAdmin configuration. When this happens you’ll get a 404 Not Found error when trying to navigate to https://localhost/phpmyadmin/.

phpMyAdmin Not Found

If this happens, enter the following terminal command.
sudo dpkg-reconfigure phpmyadmin

You will be prompted about reinstalling the database. Accept the default of “No” and hit .

Don’t reinstall phpMyAdmin database

Make sure to then mark apache2 by having the cursor next to apache2 and then hitting to mark it with a *, then hit .

Reconfigure phpMyAdmin for Apache

You will then need to reload Apache.
sudo service apache2 reload

You should now be able to load https://localhost/phpmyadmin/. If you’re still seeing the 404 Not Found error, then you will need to clear your web browser cache and try again.

phpMyAdmin login screen
Fixing the Apache fully qualified domain name

During the above steps you may have seen an error message like this when reloading Apache.

apache2: Could not reliably determine the server’s fully qualified domain name,
using for ServerName

This doesn’t seem to cause any problems for me, but if you don’t like seeing that error, you can fix it with this command.
echo “ServerName localhost” | sudo tee /etc/apache2/conf.d/fqdn

Then reload Apache with
sudo service apache2 reload

Enjoy your new web development environment!