Overview

A LAMP stack contains several components: Linux, Apache, MySQL, and PHP. The Linux portion of the stack is taken care of when your new server is launched.

Tutorial

First, update the package index to the newest versions:

sudo apt-get update

Then, to install the base Apache, MySQL, and PHP packages, run:

sudo apt-get install lamp-server^

(Please be sure to include the ^ character at the end of the command)

A listing of the related packages that will be installed or updated will
appear on the screen. At the prompt, enter ‘Y’ to confirm proceeding with
the installation.

For the MySQL installation, a prompt will appear asking for the root
password to be set. That should not be left blank, please enter a secure
password here and record what that is set to.

The installation of all the packages may take several minutes to finish.
The final output should look something like this:

At this point, Apache should be installed and running with PHP configured
in module form, and MySQL will be installed and running. For a basic test
of Apache and PHP, you can create a test file under the default document
root of “/var/www/html/”. You may want to chown the directory to your
normal user so that you will have access to write to it. You can then
create a file named “test.php”, with the following inside:

<?php
phpinfo();
?>

You should now be able to load the file by calling the IP address of the
server in a browser with /test.php after that, such as:

http://SERVER_IP/test.php

(Replacing SERVER_IP with the public IP of the server)

If that loads the PHP info page, both Apache and PHP are functioning
correctly. That page is handy for future reference as it lists the
location of the php.ini files in use, as well as the current variable
settings.

Apache itself will create a default page with information on the paths and
configuration for it in the main document root. Calling the server IP
itself will load that:

http://SERVER_IP/

(Replacing SERVER_IP with the public IP of the server)

As a quick check for MySQL, the following command can be run:

mysqladmin -uroot -p variables

When prompted for a password, enter the password selected for the root
MySQL password. If MySQL was installed, and is up and running, that will
display the current configuration settings for it.

Further Documentation

To further configure the software to your specific projects, the
documentation for each package can be consulted.

http://httpd.apache.org/docs/2.4/

The Apache Getting Started Guide is at:

http://httpd.apache.org/docs/2.4/getting-started.html

PHP documentation can be found at:

http://php.net/manual/en/

The PHP Getting Started Guide is at:

http://php.net/manual/en/getting-started.php

MySQL documentation is at:

http://dev.mysql.com/doc/