The most important and required open source software to build a dynamic web development application called LAMP Stack which is just an acronym for the software which includes – Linux, Apache, MySQL and PHP and today we will see how to install LAMP on CentOS that your web application needs.
The LAMP Components includes,
- Operating system – Linux (e.g. CentOS)
- Web server – Apache
- Database – MySQL
- Programming language – PHP (Hypertext Preprocessor)
Please login to the server as a root user to Install the LAMP.
How to Install Apache, #
1) Make sure your software is up to date before you begin any installation.
2) Install Apache using below command.
yum install httpd
3) Start Apache using below command.
systemctl start httpd.service
4) Set Apache to start on server boot using the below command.
systemctl enable httpd.service
5) Verify that Apache is installed by going to,
http://your server’s IP address.
If Apache is installed, the Apache Test Page 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,
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.
2) Please type in the following code in the newly created PHP file.
3) Save and close the file using below command.
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.