Share this page:
A LAMP server consists of Linux, Apache, MySQL database, and PHP (or Perl or Python). It's a very common combination of tools which can be used with many different web applictions, and is supported by most web hosting companies.
The Apache web server receives requests and decides how to handle them. Some requests may be handled by sending an HTML file back to the browser, others will be handled by running a PHP script.
The HTML output from scripts is sent back to the browser. Data used by a LAMP stack is stored in a database which can be accessed by PHP scripts.
First, make sure your server is up to date:
Now you need to install several packages:
This will install Apache, MySQL server, PHP and a PHP/MySQL interface library. I've included the MySQL client, but this is optional. When the MySQL server is installed, you will be prompted for a root password. For the purposes of this tutorial, I used 'mypassword' without the quotes.
Alternative PHP Cache (APC) is a module that caches PHP byte code when it executes. When the same code is executed again, it doesn't need to be parsed again which reduces disk access and CPU overheads. It can lead to a significant improvement in the performance of PHP applications.
Check that Apache is working by opening a browser on a PC or laptop, visit the IP address of your server. In my case this is http://192.168.1.50. You should see something like this:
Next, test that PHP is installed correctly. Open a file in nano in /var/www:
Note that in Apache 2.4, the web root is /var/www/html. Enter this text, and save the file:
Type control-o and press return to save the file, and type control-x to exit nano. Now visit the new page in your web browser by visiting http://server IP address/test.php. In my case this is http://192.168.1.50/test.php.
There are some MySQL server settings that can be changed to make it more secure. MySQL is supplied with a utility that guides users through the process of changing these settings. Enter the following command in a terminal:
If you entered a root password when you installed MySQL server, then you don't need to change it and you can answer 'n' for the first question. Enter 'y' for all the others.
You now have a fully functioning LAMP server. You can use it to develop PHP applications, or install an application like Wordpress.