LAMP Stack consists of Apache web server, MariaDB / MySQL database, and PHP language, running on top of Linux operating system. It is the most widely used tech stack all around the world for websites, hosting, blogs, etc.. used by small to enterprise organizations.
LAMP is the acronym of
L – Linux Operating System
A – Apache Web Server
M – MariaDB / MySQL Server
P – PHP language
At this moment, we don’t have any article written about how to install CentOS 7. However, you can click this link to find it in Google.
Open a terminal and switch yourselves to the root user.
$ su -
The Apache package is available in the base repository of CentOS 7. The name of the Apache package is httpd, and you can install it using the yum command.
yum install -y httpd
Start the Apache service with systemctl command.
systemctl start httpd
By default, Apache web service doesn’t start automatically on system reboot. So, to make the Apache service to start automatically during every system reboot run the following command.
systemctl enable httpd
FirewallD blocks all request coming to the system except SSH connections. So, we need to allow HTTP requests in the firewall from external machines to access web pages.
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --reload
Test Apache Web Server
To make sure Apache web server installed correctly we will now test it to see if it is working correctly. Open up a web browser and then go to the following web address.
You should see the web page saying Testing 123. This page confirms that the Apache web server is working fine.
Apache web server’s default document root is
/var/www/html and the main configuration file is
/etc/httpd/conf/httpd.conf. Additional configurations can be seen in the
Install MariaDB / MySQL
The MariaDB has become the default database server replacing MySQL after the licensing issue.
Here, I will install the MariaDB.
yum install -y mariadb mariadb-server
Start the MariaDB service with the below command.
systemctl start mariadb
Enable MariaDB service to start during every boot.
systemctl enable mariadb
Secure MariaDB Installation
Secure your MariaDB installation with
By default, Apache web server supports only HTML pages. To have support for PHP, we would need to install the PHP package along with support for the MariaDB / MySQL database.
PHP 5.4 (End Of Support)
The PHP version (v5.4) available in OS repository is already the end of support. If you still wish you install v5.4, use the below command to install it.
yum install -y php php-mysqlnd
Remi, a third party repository that offers up to date version of PHP (v7.3). To enable the Remi repository, install the Remi repository auto-configuration package.
yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Now, install PHP v7.3 with the following the command
yum install -y --enablerepo=remi-php73 php php-mysqlnd
Restart the Apache web service after the installation of the PHP.
systemctl restart httpd
Test LAMP Stack
.php file on to the default directory of the Apache.
Copy/paste below lines into the
<html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html>
Visit the following web address on your web browser.
You should see the Hello World page.
You have successfully installed LAMP Stack on CentOS 7. Consider installing phpMyAdmin on CentOS 7 to manage MariaDB / MySQL database servers. Also, you can install Let’s Encrypt SSL certificate in Apache on CentOS 7 for secure communication.