Easy Guide to Installing LAMP on CentOS

Cloudmatika / March 24, 2026
Easy Guide to Installing LAMP on CentOS

LAMP is an acronym for Linux, Apache, MySQL, and Perl/PHP/Python. It is a popular open-source software stack used to run web applications and websites.

Components of the LAMP Stack

  • Linux – Operating System
  • Apache HTTP Server – Web Server
  • MariaDB or MySQL – Database Management System
  • PHP, Perl, or Python – Programming Language

How to Install LAMP on CentOS

1. Log in to Your CentOS VPS/Server

Log in to your CentOS VPS or server as the root user or another user with sufficient privileges to install and configure web server components.

You can use PuTTY on Windows or the Terminal application on Linux.

2. Update Yum Packages

Once you are logged in to the CentOS terminal, update your Yum packages to ensure a smooth installation process:

sudo yum update

3. Install Apache

Install Apache by running the following command:

sudo yum install httpd

After the installation is complete, start the Apache service:

sudo service httpd start

4. Verify Apache Installation

After Apache has been installed and started, open a web browser and enter your VPS IP address.

For example, if your VPS IP address is 192.168.1.2, enter:

http://192.168.1.2

If the installation was successful, the default Apache welcome page will appear in your browser.

5. Install MariaDB

MariaDB is a database platform developed by the original creators of MySQL. After MySQL was acquired by Oracle, many of its developers created MariaDB as an alternative database platform with several enhancements and improvements.

Since MariaDB is a fork of MySQL, all MySQL commands and syntax remain fully compatible with MariaDB.

To install MariaDB on CentOS, run:

sudo yum install -y mariadb-server mariadb-client

Note: The -y parameter automatically answers “Yes” to all installation prompts.

6. Start and Verify MariaDB

Start the MariaDB service:

sudo service mysql start

Check the MariaDB service status:

sudo service mysql status

7. Secure MariaDB Installation

To improve the security of your database server, run:

sudo mysql_secure_installation

Follow the prompts to set a root password and apply recommended security settings.

8. Install PHP

Install PHP along with the MySQL extension:

sudo yum install php php-mysql

9. Restart Apache

After the PHP installation is complete, restart Apache:

sudo service httpd restart

Installation Complete

Congratulations! You have successfully installed the LAMP stack on your CentOS VPS or server.

By default, your website files should be placed in the following directory:

/var/www/html

You can now begin uploading your website files and hosting web applications on your server.

Whatsapp Chat Chat with us here
Scroll to Top