Perform LAMP installation on CentOS to enable Web Services in a Linux environment.
Linux machine running CentOS
Step 1: Install Apache
Install the Apache package by using the following command.
yum install -y httpd
Then, start the Apache services by using the following command.
systemctl start httpd.service
Afterwards, enable the Apache services to start on boot by using the following command.
systemctl enable httpd.service
Step 2: Installing MariaDB
Install the MariaDB package by using the following command.
yum install mariadb-server mariadb
Then, start the MariaDB services by using the following command
systemctl start mariadb
To eliminate dangerous defaults and lock down access to the database system, you need to run a simple security script via the following command.
Proceed by pressing Enter upon asking for a current root password.
To set up a root password, enter Y when prompted to set up a new root password.
The remaining prompts can be skipped by pressing Enter.
Enter the following command to enable MariaDB to start on boot.
systemctl enable mariadb.service
Step 3: Install PHP
Install PHP by entering the following command.
yum install php php-mysql
To enable Apache to work with PHP, restart the Apache service after PHP installation via the following command.
systemctl restart httpd.service
To install PHP modules for other services, you can install them manually via the command line.
For example, to install the PHP module php-fpm, use the following command.
yum install php-fpm
Next, test the processing of PHP on the Apache web server by creating a file and entering some PHP code, illustrated below.
sudo vi /var/www/html/info.php
Then, enter the following text to the file.
Afterwards, allow HTTP and HTTPS traffic through the firewall via the following commands.
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
Then, visit the PHP page by entering http:///info.php on your web browser.