Table of Contents
- Step 1: Update Repositories
- Step 2: Install Apache Web Server
- Step 3: Start Apache Service
- Step 4: Enable Apache to Start on Boot
- Step 5: Update Firewall Settings (Optional)
- Step 6: Install MySQL (MariaDB)
- Step 7: Start MySQL Service
- Step 8: Enable MySQL to Start on Boot
- Step 9: Secure MySQL Installation
- Step 10: Install PHP
- Step 11: Restart Apache for PHP Integration
- Step 12: Test Your LAMP Stack
To install a LAMP (Linux, Apache, MySQL, PHP) stack on AlmaLinux, follow the steps below:
Step 1: Update Repositories
sudo dnf update
Step 2: Install Apache Web Server
sudo dnf install httpd
Step 3: Start Apache Service
sudo systemctl start httpd
Step 4: Enable Apache to Start on Boot
sudo systemctl enable httpd
Step 5: Update Firewall Settings (Optional)
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
Step 6: Install MySQL (MariaDB)
sudo dnf install mariadb-server mariadb
Step 7: Start MySQL Service
sudo systemctl start mariadb
Step 8: Enable MySQL to Start on Boot
sudo systemctl enable mariadb
Step 9: Secure MySQL Installation
sudo mysql_secure_installation
Step 10: Install PHP
sudo dnf install php php-mysqlnd
Step 11: Restart Apache for PHP Integration
sudo systemctl restart httpd
Step 12: Test Your LAMP Stack
Create a PHP info file to test your installation:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Visit “http://your_server_ip/info.php” in a web browser to see the PHP info page.
Now, you have successfully installed a LAMP stack on AlmaLinux. You can use this stack to host and run web applications.