Installing a LAMP on Linux

If you know much about Linux, you may have already set up and installed PHP and MySQL. If not, your best bet is probably to look at XAMPP for Linux, which is available at http://apachefriends.org/en/xampp-linux.html.

The process is relatively simple. After downloading, go to a Linux shell and log in as the system administrator (root) by typing:

su

Enter your system administration password. Many desktop Linux systems allow you to use your personal account’s password for the administration password. Some systems, including the popular Ubuntu, encourage you not to use su to log in as root, but to precede each system administration command with sudo instead. You’ll know what to do if you’ve performed any administrative tasks on your system. Now extract the downloaded archive file to /opt with the following command (inserting the appropriate filename if the version you downloaded is a later version):

tar xvfz xampp-linux-1.6.8a.tar.gz -C /opt

Any XAMPP version that was already installed will be overwritten by this command.

Once the command finishes, XAMPP will be installed below the /opt/lampp directory. To start it, enter the following:

/opt/lampp/lampp start

You should now see something like this on your screen:

Starting XAMPP 1.6.8a...
LAMPP: Starting Apache...
LAMPP: Starting MySQL...
LAMPP started.

Ready. Apache and MySQL are running.

Now you are ready to test the setup. Type the following URL into your web browser’s address bar:

http://localhost

You should now see ...

Get Learning PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.