
This guide is for Rocky Linux 8, but will be very similar for other versions or RHEL, please adjust the PHP and MariaDB versions as needed for your specific requirements.
Prerequisites:
Ensure the user has sudo privileges, which can be done by adding the user to the ‘wheel’ group, for example:
Add user 'user' to the 'wheel' group
su gpasswd -a user wheel
Step 1: Update the System
sudo dnf upgrade -yy
Step 2: Install PHP and Verify Repositories
sudo dnf install epel-release -yy
Find the latest Remi repository version and install it: sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -yy
sudo dnf repolist
sudo dnf update -yy
Step 3: Install Apache/HTTPD Web Server
sudo dnf install httpd -yy
Step 4: Enable and Start Apache and Configure Firewall
sudo systemctl enable --now httpd
sudo systemctl start httpd
Confirm httpd is running with:
sudo systemctl status httpd
Enable ports 80 (HTTP) and 443 (HTTPS) in the firewall for outgoing http and https respectively:
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --reload
Step 5: Setup PHP
sudo dnf module reset php -yy
sudo dnf module list php
Choose a PHP version from the list, e.g., php:remi-8.0 sudo dnf module install php:remi-8.0 -yy
sudo dnf search php-mysql*
Install the recommended PHP MySQL extension, e.g., php-mysqlnd.x86_64
sudo dnf install php-mysqlnd.x86_64 -yy
sudo php -v
sudo dnf update -yy
Step 6: Test PHP Configuration
Create a PHP info file
sudo nano /var/www/html/info.php
In the info.php
file, add the following content:
<?php phpinfo(); ?>
Save the file and access it in a web browser using localhost/info.php
on the Rocky Linux machine to check PHP information, alternatively you can access this page using the Rocky machines IP address in the browser of another machine with network access to it.
Step 7: Install MariaDB
sudo dnf module list mariadb
Choose a MariaDB version from the list, e.g., mariadb:10.5
sudo dnf install mariadb mariadb-server -yy
sudo systemctl enable --now mariadb
Check mariadb is up and running:
sudo systemctl status mariadb
Step 8: Initial Setup of MariaDB
mysql_secure_installation
Follow the prompts to:
- Set the root password
- Remove anonymous user accounts
- Disallow remote login for root
- Remove the test database
- Reload privilege tables
Step 9: Login to MariaDB
mysql -u root -p
This guide outlines the steps to set up a LAMP stack on Rocky Linux. Please adjust the PHP and MariaDB versions as needed for your specific requirements.
Leave a Reply