How To Install LAMP (Linux, Apache, MySQL, PHP) on Fedora
Welcome back to the Greenhost.cloud blog! Today we will guide you through the process of installing the LAMP stack (Linux, Apache, MySQL, PHP) on Fedora. Whether you’re looking to set up a development environment, host a website, or explore the wonders of web programming, this step-by-step tutorial will equip you with the essential tools to get started.
What is LAMP?
Before diving into the installation process, let’s briefly discuss what each component of LAMP entails:
- Linux: The operating system, which serves as the foundation for the stack.
- Apache: The web server software responsible for serving your web pages.
- MySQL: The relational database management system that allows you to store and manage your data.
- PHP: The scripting language used to create dynamic content that interacts with the database.
Prerequisites
Before we begin, ensure that you have:
- A working installation of Fedora (We recommend the latest version).
- Sudo privileges to install packages and make system changes.
- Basic familiarity with command-line operations.
Step 1: Update Your System
Open your terminal and start by updating your package repository to ensure all your software is up to date:
sudo dnf update
Step 2: Install Apache
- To install the Apache web server, run the following command:
sudo dnf install httpd
- Once the installation is complete, enable and start the Apache service:
sudo systemctl start httpd
sudo systemctl enable httpd
- To verify that Apache is running, open a web browser and navigate to
http://localhost/
. You should see the Apache test page.
Step 3: Install MySQL
- Next, we’ll install MariaDB, a community-developed fork of MySQL. This is commonly used as a drop-in substitute for MySQL. Run the following command:
sudo dnf install mariadb-server
- Start and enable the MariaDB service:
sudo systemctl start mariadb
sudo systemctl enable mariadb
- Secure the installation by running:
sudo mysql_secure_installation
Follow the prompts to set the root password and secure your installation as desired.
Step 4: Install PHP
- To install PHP and the necessary extensions for Apache and MySQL, use the following command:
sudo dnf install php php-mysqlnd php-fpm php-xml
- Restart Apache to apply the changes:
sudo systemctl restart httpd
Step 5: Test PHP Processing
- To check that PHP is installed correctly, create a new file called
info.php
in the web server’s root directory:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
- Preview this file in your web browser by navigating to
http://localhost/info.php
. If installed correctly, you should see the PHP information page displaying various details about your PHP installation.
Step 6: Additional Configurations (Optional)
- Firewall Configuration: If you have a firewall running (firewalld), ensure that it allows HTTP and HTTPS traffic:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
- Virtual Hosts: If you’re planning to manage multiple websites, consider setting up Apache virtual hosts. You can find documentation on how to do that in Apache’s official documentation.
Conclusion
Congratulations! You’ve successfully installed the LAMP stack on your Fedora system. You now have a robust environment for developing and hosting dynamic web applications. At Greenhost.cloud, we recommend that you continue exploring and experimenting with your setup—check out PHP frameworks, CMS options, and dive deeper into web development.
If you encountered any issues during the installation process or have questions, feel free to reach out in the comments below. Happy coding!
For more tips and tricks related to web hosting and development, don’t forget to follow our blog at Greenhost.cloud!