LAMP Stack

LAMP Stack setup – Linux Apache MySQL PHP

LAMP is an acronym of a very popular web stack – Linux, Apache, MySQL, PHP. All of the four components of LAMP are open-sourced and are suitable to deploy dynamic websites and web applications. In today’s tutorial, I am going to show you how to set up a cloud server with the LAMP stack.

LAMP Stack: L – Linux

L in LAMP stands for Linux Operating System. With CloudSigma’s easy-to-use interface, you can deploy it within minutes.

Creating the machine

First, you have to create a machine. You can do that easily under CloudSigma’s Compute Section. For the purposes of this tutorial, you can use the following resources:

CPU: 8 GHz
RAM: 8 GB
SSD: 50 GB

You can mount the disk with Ubuntu 18.04 LTS image available in CloudSigma’s library. Ubuntu 18.04: Pre-installed 64bit with VirtIO drivers, superuser, Python 2.7.17, Pip 20.0.2 OpenSSL 1.1.1d, Cloud-init and latest updates until 2019-03-03.

After starting the machine, you can update all the existing repos and packages on the machine by running the following commands:

LAMP Stack: A – Apache

Apache (Apache HTTP Server) is an open-source web server software that can be used to serve the content on the web. More than 40% of the websites on the WWW – World Wide Web use it.

To install Apache HTTP Server, you can run the following command:

Once it’s installed, you can go to the IP address on your web browser and you will see an output similar to this:

apace web server homepage LAMP Stack

If you do not know the IP address, you can check it under CloudSigma account’s Compute Section.
Finding IP address

LAMP Stack: M – MySQL

You can go ahead and install MySQL now that Linux and Apache are installed

MySQL is an open-source Relational Database Management System (RDBMS) that helps users store, organize, and manage data. It is very popular and widely used in the IT industry. To read more about MySQL, follow CloudSigma’s post – How to setup MySQL on a server and MySQL basics.

To increase the security, run the below script and choose your preferences:

 

LAMP Stack: P – PHP

PHP is a popular open-source scripting language generally used for building dynamic web pages. You can install it using the command:

Once it’s installed, you can configure Apache to serve your PHP file by moving “index.php”  before “index.html” in this file – /etc/apache2/mods-enabled/dir.conf

The file would now look like this:

PHP has a vast library of modules that you can use in your application. Find the available libraries using the given command and it will get you a list:

PHP Modules page

Install the above modules using the apt-get command:

You can create a sample PHP file to test it out. Create a file – /var/www/html/test.php and add the following contents in it.

Then, restart the Apache server so the changes take effect.

Now, when you go to the URL – https://IPaddress/test.php , you will see the following content:
PHP Info page

Finally, you have successfully set up your LAMP Stack.

Happy Computing!