This tutorial will help you to install and configure LAMP (Linux, Apache, MySQL and PHP) on CentOS 8 and RHEL 8 Linux systems. Useful link:

Setup Let’s Encrypt SSL with Apache on CentOS 8 How to Setup SFTP only user on CentOS 8

Prerequisites

Newly installed CentOS 8 machine. Complete initial server setup Shell access with sudo privileges

Step 1 – Install Apache

The Apache web server packages are available under the default AppStream repository on CentOS 8. You just need to update the DNF cache and install packages using the following commands. The mod_ssl package provides the functionality to use an SSL certificate for secure HTTP. After installation, enable the httpd service and start. Now check the Apache service status: Output:

Step 2 – Install MySQL Server

The latest MySQL 8 packages are available under the AppStrem repository under CentOS 8. Use the following command to install MySQL server including required packages on your system. After completing the installation, enable the MySQL service to auto-start on the system start. Also start service manually for the first time. Then check the service current status using the following command: The MySQL installation has been completed. Now you can connect the MySQL server without any password but we recommend securing the MySQL installation. The MySQL packages provide mysql_secure_installation command to apply the security. Just run the below command on terminal: and follow the on-screen instructions. Below are the details which require user input.

Press y|Y for Yes, any other key for No: y Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 New password: [ENTER STRONG PASSWORD HERE] Re-enter new password: RE ENTER PASSWORD HERE Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Step 3 – Install PHP

The Remi repository contains the latest PHP packages for the CentOS 8 Linux system. So first of all, you need to add the REMI repository to your system. Just execute the following command to add the repository. Then enable the required DNF module for PHP installation. Here we are enabling the module for installing PHP 7.4. You can change this to PHP 7.3 or PHP 7.2 as per your requirements. Once the repository is enabled on your system. Install PHP packages along with required PHP modules. You many also need to install other required php modules as per your application requirements. The below command will install few frequently used php modules:

Step 4 – Create Apache VirtualHost

All the packages required for LAMP environment is installed. Now, create the Apache virtual host. By default the Apache uses php-fpm for processing PHP files on CentOS 8 system. Create and edit virtual host configuration file in the favorite text editor: Add the following content in the configuration file. Make sure to change required parameters.

Save the virtual host configuration file and reload Apache to apply changes. Useful link:

Setup Let’s Encrypt SSL with Apache on CentOS 8

Step 5 – Allow Ports in Firewalld

The CentOS 8 Linux server is ready to serve the application over LAMP environment. If your system has firewalld installed ans active, you need to allow Apache ports. This will allow network users to access web application from remote systems. The following commands will open the required ports for you. Useful link:

What is FirewallD and how to implement on Linux

Step 6 – Test Setup

All done. To test the environment, create a PHP script with phpinfo() function. Place this file to your server document root. Use the below command to do this. Then access info.php using server IP address (for default VirtualHost) for your configured domain in Apache VirtualHost.

Conclusion

You have successfully configured LAMP environment on your CentOS 8 or RHEL 8 Linux system. Next you can install phpMyAdmin on your system.

How to Install Apache  MySQL   PHP  LAMP  on CentOS 8   TecAdmin - 12