How to install LAMP stack on CentOS 7
Table of Contents
Install LAMP stack on CentOS
LAMP stack stands for the set of packages such as Linux, Apache, MySQL, and PHP. LAMP stack is widely used for hosting Websites and Apps. In this tutorial, you are going to learn How to install LAMP stack on CentOS.
Before you start to install LAMP stack on CentOS 7. You must have the non-root user account on your server with sudo privileges.
1. Install Apache
In CentOS and RHEL Apache service is known as httpd. As Apache repository is available if CentOS core repositories, installation is pretty easy.
To install Apache on CentOS enter following command
sudo yum install httpd
Once You install Apache start and enable service by typing following in terminal.
sudo systemctl start httpd
sudo systemctl enable httpd
Confirm the status of Apache service by running following command
sudo systemctl status httpd
Enter CTRL+c to exit.
2. Install MariaDB
Now you are going to install MariaDB on your server. To install type following:
sudo yum install mariadb-server
After installing MariaDB you should start and enable MariaDB service by running the following command.
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Check the status of MariaDB service by typing
sudo systemctl status mariadb.service
The Installer generates the temporary password for MariaDb and saves it inside a file to check the password inside file enter following command
grep "A temporary password" /var/log/mysqld.log | tail -n1 [Some text hidden] A temporary password is generated for [email protected]: Eif;=GPCD88#
To secure MariaDB run following command.
Once you execute above command you will be asked to enter current password (Press ENTER for none) then you will be asked following questions, enter y for following questions:
- Set root password? : y
- Remove anonymous users? : y
- Disallow root login remotely? : y
- Remove test database and access to it? : y
- Reload privilege tables now? : y
Enter CTRL+c to exit
3. Install PHP
CentOS does not ship with PHP 7.2 in its core repositories. Here we are going to use the Remi repository to install PHP 7.2.
Enter the following command to add Remi repository on CentOS
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Now you should enable remi-php72 repository, to do so type:
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php72
Install PHP and some of its required extensions by typing
sudo yum install php php-common php-gd php-curl php-mysql
Now restart Apache by using the following command
sudo systemctl restart httpd
Now you should create info.php file to test php to do so type following.
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Now visit http://YOUR_DOMAIN_NAME_OR_IP_ADDRESS/info.php or http://localhost/info.php in your browser.
You have successfully learned to install LAMP stack on CentOS 7. If you have any queries regarding this please don’t forget to comment below.
How to install phpMyAdmin on CentOS 7
How to Install Ruby on Debian 9
How to Install Laravel PHP Framework With Nginx on CentOS 7
How to Install MySQL on Debian 9
How to Install PyCharm on Debian 9
How to Install VirtualBox on Ubuntu 18.04
How to install Composer on CentOS 7
How to install Audacity on Ubuntu 18.04
How to Recursively Search all Files for a String in Linux
How to Install FFmpeg on Fedora 29
How to Install Kodi on Debian 9
How to Install Django Web Framework on Debian 10