
LAMP stands for Linux OS, with Apache web server, Data store in a MySQL database, and dynamic content is processed by PHP. It is a group of open-source software and and widely used for hosting websites. In this tutorial, we will show you how to install LAMP stack on CentOS 7.
Prerequisites
Before you begin to install LAMP stack, you must logged in with non-root user account with sudo privileges.
Install Apache
In CentOS and RHEL Apache service is known as httpd. Apache is available in default CentOS 7 repositories so installation is pretty easy. To install the package run the following command:
sudo yum install httpd
Once the installation is finished, you need to start and enable the Apache service by typing:
sudo systemctl start httpd
sudo systemctl enable httpd
You can confirm installation by checking the status of service by below command:
sudo systemctl status httpd
Install MariaDB
Now we are going to install MariaDB on your CentOS system. To install type following:
sudo yum install mariadb-server
- If you want to install MySQL instead of MariaDB, check this tutorial for installation guide.
When the MariaDB installation completed, you should start and enable the service with:
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Also, check the status of service by typing:
sudo systemctl status mariadb.service
Install PHP
By default, CentOS 7 ships with PHP version 5.4 so we are going to use Remi repository to install PHP 7.2.
Run the following command to install the Remi repository to your system:
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Now you have to install yum-utils package and enable remi repository on your CentOS system using below command:
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php72
Next, install the PHP and required extensions along with it by typing:
sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql
You should now restart the Apache service to take effect. Use below command to restart Apache service:
sudo systemctl restart httpd
Verify Installation
Create a info.php file at /var/www/html/info.php
and add below lines to it and save.
<?php
phpinfo();
?>
Now, open your favorite browser and open info.php file with your server public ip address as given below:
http://SERVER_IP_ADDRESS/info.php
If it will show show PHP information page then your installation is successful.
Conclusion
You have learned how to install LAMP stack on CentOS 7. If you have any questions or suggest don’t forget to leave a comment.
Leave a Reply