Installing a LAMP (Linux, Apache, MySQL, PHP) stack on RHEL 8 can be done by following these steps:
- Install Apache web server:
sudo dnf install httpd
- Start the Apache service and enable it to start automatically at boot time:
sudo systemctl start httpd
sudo systemctl enable httpd
- Install MySQL server and client:
sudo dnf install mariadb-server mariadb
- Start the MySQL service and enable it to start automatically at boot time:
sudo systemctl start mariadb
sudo systemctl enable mariadb
- Secure your MySQL installation by running the following command:
sudo mysql_secure_installation
- Install PHP and the PHP module for Apache:
sudo dnf install php php-mysqlnd
- Enable the PHP module for Apache by editing the Apache configuration file:
sudo nano /etc/httpd/conf.d/php.conf
and add the following line:
LoadModule php7_module modules/libphp7.so
- Restart the Apache service to apply the changes:
sudo systemctl restart httpd
- Verify that PHP is working by creating a file called
info.php
in the Apache document root directory:
sudo nano /var/www/html/info.php
with the following contents:
phpinfo();
- Access the file in a web browser:
http://your_server_ip/info.php
The above steps will install a LAMP stack on your RHEL 8 system. You can now use this stack to host dynamic websites and web applications that use PHP and MySQL.