LAMP Stack featured image

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on CentOS 7

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 this tutorial,  we will walk you through setting 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
SSD: 50 GB

You can mount the disk with CentOS 7.8 Server – 64bit Pre-Installed English with SSH, Python, Pip, Cloud-init, OpenSSL, and VirtIO support. 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 the Apache HTTP Server, you can run the following command:

Once the webserver is installed, you can use the following command to start it:

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

apache server LAMP Stack

If you don’t see the above screen, it’s possible that your firewall is blocking the HTTP traffic. You can use the following commands and try again:

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

You can also enable Apache to start on boot with the following command:


LAMP Stack: M – MySQL (MariaDB)

You can go ahead and install MySQL now that Linux and Apache are installed. With this tutorial, you can also install MariaDB, a MySQL replacement. MariaDB is a community-developed version of the MySQL project. You will store your website data in it:

Once the installation is complete, you can start MariaDB with the following command:

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

Again, you can choose to enable MariaDB to start on boot with the following command:

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:

After this, you need to restart the Apache webserver for it to work seamlessly with PHP:

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 provide you with a list:

php library LAMP Stack

Install the above modules using the yum 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 to it:

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

Screenshot 2020 12 02 At 23.29.19 300x226

Finally, you have successfully set up your LAMP Stack!

Happy Computing!