LAMP is an acronym standing for Linux, Apache, MySQL and PHP. The LAMP package will install the Apache2 webserver, MySQL database, and the Hypertext Preprocessor PHP.
Installing LAMP is as easy as this: open up a Terminal and type in the following, hitting the Enter (or Return) key when you are done:
The first command, sudo, switches the user command to root, which has all privileges. This means you will have to provide your password before the terminal will finish processing the rest of the command (by default, the terminal will remember your password for about fifteen minutes, so subsequent sudo commands won't ask for your password again until the fifteen minutes is up).
The command apt-get is the Advanced Packaging Tool that we use in Ubuntu to install and remove programs and packages. It is followed by the sub-command install, which tells apt to install the named package (lamp-server). The caret symbol (^) is required; it essentially calls on apt-get to install a set of packages-- instead of one package named lamp-server, there are actually several related packages. The caret invokes a function similar to another command called tasksel, which installs multiple related packages as part of a task-list.
Apt will list the packages that will need to be downloaded and wait for you to hit the Enter key again to begin installing. There may be notes from apt in there, telling you, for instance, that there are unnecessary files on your drive that can be unloaded by using the command apt-get auto-remove, but that isn't necessary at this moment. Be sure to research the effects of this command on your particular flavor and version of Linux before trying out that command later.
Once installation of the LAMP package begins, you will be asked to provide a password for MySQL root. You should be prompted to re-enter the password again, to make sure you know the password you just entered.
You must remember this password-- during this process you will be asked to provide several passwords, some of which you will rarely need to use, if at all (if you have need to move your blog using the procedures I outline in the third part of this series, then you will certainly need to know these passwords). If you ever have to access MySQL, you will need to know this root password, so be sure to record it somewhere safe. I use a Keyring program on my smartphone to keep track of all my passwords and such. It's separate from my laptop in case my hard drive fails, and I have encrypted backups for when the phone dies.
Once LAMP installation is complete, you can verify that Apache2 is working by opening up your Internet browser and typing http://localhost/
in the navigation bar. If you do not get a web page that says something along the lines of “It Works!” then something went wrong and you will be spending some time online trying to troubleshoot the issue.
'Out of the box' as it were, Apache2 will look in the /var/www folder for localhost applications, so we could test the PHP function by creating a quick test page. The fastest way to do this is by using the built-in text editor gedit (or Kate, in my case, since I am running KDE) as root. In your terminal, type:
Code: Select all
gksudo gedit /var/www/html/testpage.php
The command gksudo is similar to sudo, which we used earlier. This time, we are executing the command as root, but specifies that it's a graphical-interface application we are calling up. The first difference you might notice between the two is that gksudo will open up a separate window asking for your password where sudo makes its request from the terminal. When gedit comes up, enter the following line, save it and exit.
You'll need to restart Apache2 by entering this in the terminal:
Once that is done, you can go to your browser and enter http://localhost/testpage.php
in the navigation bar. If everything is working correctly, you should get a page that shows the version of your PHP installation (and a bunch of other stuff). If not, then you'll be spending some quality time with Mister Google, I'm afraid.
There are a few different ways for dealing with MySQL. Of the the methods I have tried, I have found phpMyAdmin to be the easiest application to work with. Install it with the following command in the terminal:
Code: Select all
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
You will want to select Apache2 as your webserver: make sure Apache2 is highlighted and hit the spacebar and then the Enter key. Next, phpMyAdmin will want to set up the dbconfig-common database. Select Yes using the Tab key and hit Enter.
The installer will ask you for the password you gave for MySQL root. It will then ask you to either assign your own password for phpMyAdmin or hit Enter to obtain an auto-generated one. Either way, be sure to record that password for later.
It's a good idea to add your username to the server group by typing the following (substituting your username in place of the term username) into the terminal and hitting Enter:
By default, Apache2 runs as user www-data in group www-data, we're just adding your username to the group that Apache2 runs under.
Once installation is complete, you can access phpMyAdmin by typing http://localhost/phpmyadmin
in your browser navigation window. Use the password from the previous step to log in as root.
One problem I encountered with this install when invoking sudo apt-get install lamp-server^ on 12.04-beta2-desktop-amd64 was the error:
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
After checking out Bug #349469 for this, I managed to get around the problem this way:
Code: Select all
sudo rm -rf /var/cache/debconf/*
sudo apt-get install -f
This is not a recommended action-- the command rm actually deleted all the files in the /var/cache/debconf folder, which, while being a cache, can still contribute to problems further down the road.