Setting Up a LAMP Stack on AlmaLinux
Ready to supercharge your AlmaLinux server for web hosting? Follow this easy guide to set up a LAMP stack—Linux, Apache, MySQL, PHP. No tech jargon, just simple steps. Make your server the star of the web! 🚀
![Setting Up a LAMP Stack on AlmaLinux](/content/images/size/w1200/format/webp/2023/12/Setting-Up-a-LAMP-Stack-on-AlmaLinux.png)
Setting Up a LAMP Stack on AlmaLinux
AlmaLinux is a robust and open-source Linux distribution designed as a replacement for CentOS. If you're planning to host web applications or websites, setting up a LAMP (Linux, Apache, MySQL, PHP) stack is a fundamental step. This guide will walk you through the process of establishing a LAMP stack on AlmaLinux.
Prerequisites:
- A fresh installation of AlmaLinux with root or sudo access.
Step 1: Update System Packages
Before installing any components, ensure your system is up to date:
sudo dnf update -y
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.31.50-AM.png)
Step 2: Install Apache Web Server
Install the Apache web server on your AlmaLinux system:
sudo dnf install httpd -y
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.34.23-AM.png)
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.34.26-AM.png)
Start and enable Apache to ensure it starts on boot:
sudo systemctl start httpd
sudo systemctl enable httpd
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.39.45-AM.png)
Check Apache service status to ensure it's working:
sudo systemctl status httpd
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.41.07-AM.png)
Step 3: Install MySQL Database Server
AlmaLinux uses MariaDB as a drop-in replacement for MySQL. Install MariaDB and secure the installation:
sudo dnf install mariadb-server -y
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.43.54-AM.png)
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.45.04-AM.png)
Start and enable MariaDB to ensure it starts on boot:
sudo systemctl start mariadb
sudo systemctl enable mariadb
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.50.29-AM.png)
Check MariaDB service status to ensure it's working:
sudo systemctl status mariadb
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.52.24-AM.png)
Now we need to secure our MariaDB server:
sudo mysql_secure_installation
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-3.56.13-AM.png)
Follow the prompts to set a root password and secure your MariaDB installation.
Step 4: Install PHP
Install PHP and some common modules:
sudo dnf install php php-mysqlnd -y
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-4.01.27-AM.png)
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-4.02.01-AM.png)
Restart Apache to apply the changes:
sudo systemctl restart httpd
![](https://krython.com/content/images/2023/12/Screenshot-2023-12-16-at-4.03.18-AM.png)
Step 5: Test PHP Processing
Create a simple PHP test file to verify that PHP is configured correctly:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Create a simple PHP test file to verify that PHP is configured correctly
Access the file through your web browser by navigating to http://your_server_ip/info.php
.
You should see the PHP information page.
Conclusion
Congratulations! You've successfully set up a LAMP stack on your AlmaLinux server. This lays the foundation for hosting dynamic web content. Feel free to explore more advanced configurations based on your specific requirements.