Learn how to install LAMP Stack on RHEL 8 with our comprehensive guide. Follow step-by-step instructions to set up and configure your LAMP Stack efficiently on your RHEL 8 system. #centlinux #linux #apache #mysql #php
LAMP stack is a popular combination of open-source software widely used for building and deploying web applications. LAMP is an acronym that stands for the following four essential components:
Here, we have selected Red Hat Enterprise Linux (RHEL) 8, Apache HTTP Server 2.4, MySQL 8.0 and PHP 7.2 as the LAMP Stack components.
Recommended Online Training: Learn Bash Shell in Linux for Beginners
A RHEL 8 minimal installed virtual machine is being used in this article. The specifications are:
A Local YUM repository is configured, so we can install required packages without having an active Red Hat subscription.
Connect with rhel-8-lamp.example.com using ssh as root user.
Since, we have already configured local yum repository, therefore, we can easily install Apache HTTP Server using dnf command.
# dnf install -y httpd
Enable and start httpd.service.
# systemctl enable httpd.service Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service â /usr/lib/systemd/system/httpd.service. # systemctl start httpd.service
Allow HTTP service in Linux firewall.
# firewall-cmd --permanent --add-service=http success # firewall-cmd --reload success
Open URL http://rhel-8-lamp.example.com using a web browser.
Apache HTTP Server has been installed and running on our Linux server.
For database back-end installation, we can choose between MySQL and MariaDB.
Since we have already used MariaDB in our previous article Install LEMP Stack on RHEL8 Server, therefore, we are installing MySQL this time.
MySQL 8.0 is available in local AppStream repository, therefore, let’s install it using dnf command.
# dnf install -y mysql-server
Start and enable MySQL service.
# systemctl enable mysqld.service Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service â /usr/lib/systemd/system/mysqld.service. # systemctl start mysqld.service
Configure and secure MySQL database instance as follows.
# mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 Please set the password for root here. New password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done!
Verify MySQL database installation using following command.
# mysql -e "SHOW DATABASES;" -p Enter password: +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+
MySQL Database 8.0 has been installed on our Linux server.
In local AppStream repository, PHP 7.2 is available, therefore, we can install it simply by executing a dnf command.
# dnf install -y php php-mysqlnd php-mbstring php-pdo php-gd
During installation, PHP created necessary configuration file in Apache configuration directory. Therefore, we have to restart httpd.service to integrate PHP with Apache HTTP Server.
# systemctl restart httpd.service
Create a PHP file to verify PHP installation and its integration with Apache HTTP Service.
# echo "<?php phpinfo() ?>" > /var/www/html/info.php
Open URL http://rhel-8-lemp.example.com/info.php in a web browser.
We have successfully install LAMP Stack on RHEL 8.
If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.
If you found this guide on installing the LAMP Stack on RHEL 8 helpful and need further assistance with server setup or other technical support, consider hiring a professional. Visit my Fiverr profile for expert services in server configuration, database management, and more. Let’s make your project a success!
Puppy Linux is a fast, lightweight OS designed for speed and simplicity, perfect for old…
Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…
Discover how to change Apache port in Linux easily. Follow our simple guide to modify…
Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…
Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…
Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…
This website uses cookies.