Steps to Install Linux, Apache, MySQL, PHP (LAMP) On CentOS 7

The most vital and needed open supply software package to make a dynamic web development application known as LAMP Stack that is simply an word form for the software package which has – Linux operating system, Apache, MySQL and PHP and nowadays we’ll see how to install LAMP on CentOS that your web application needs.

How to Install Apache,

1) Before you begin any installation, make sure your software is up to date.

 yum update

2) Install Apache using below command.

 yum install httpd

3) using below command start Apache .

 systemctl start httpd.service

4) using following command, Set Apache to start on server boot .

 systemctl enable httpd.service

5) Now verify that Apache is installed by visiting to,
http://your server’s IP address.

If Apache gets installed, the Apache Test Page will displays.

How to Install MySQL

1) First you need to Install MariaDB, the community-developed fork of MySQL.

 yum install mariadb-server mariadb

2) Now start the service.

 systemctl start mariadb

3) Set MySQL to start on server boot.

 systemctl enable mariadb.service

4) Execute the below command to finish setting up the installation,

 mysql_secure_installation

5) Type “Y” to set the root password. Because now you have been asked to set the root password.
6) Enter and confirm the new password.
7) Press “Y” to respond system prompts and security configuration.

How to Install PHP

1) Run below command to Install PHP:

 yum install php php-mysql

Enter “Y” to install.

2) Now restart Apache:

 systemctl restart httpd.service

Your web application may need PHP modules, you can install them now,

1) First view all available PHP modules using below command,

 yum search php-

2) The list displays the available PHP modules. To view the description of a specific package, use the following command.

 yum info "the name of the package you want to use"

3) Install the required package.

 yum install "the name of the package you want to use"

To test PHP processing on Apache,

1) Create a new PHP file under the /var/www/html directory.

 vim /var/www/html/info.php

2) Please type in the following code in the newly created PHP file.

 

<?php

phpinfo();

?>

3) Save and close the file using below command.

 :wq!

4) Type this URL in your browser, to check if it is working or not – http://your server’s IP address/info.php

The screen will display a page with the Version of the PHP, extensions, build date, and other information. Now you know how to build a LAMP stack on CentOS.