Fedora Lamp Stack


Title: How to Set Up a LAMP Stack on Fedora Linux


Introduction

A LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) is a popular setup for web development. This guide will walk you through the steps to install and configure a LAMP stack on your Fedora Linux system.


Step 1: Update Your System

Open a terminal and update your system packages to ensure you have the latest software versions.

sudo dnf update -y
sudo dnf upgrade -y

Step 2: Install Apache

Apache is the web server component of the LAMP stack. Install and start Apache with the following commands:

sudo dnf install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd

Verify Apache is running by visiting http://localhost in your web browser. You should see the Apache test page.


Step 3: Install MariaDB (MySQL)

MariaDB is a popular database server. Install and start MariaDB with:

sudo dnf install -y mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the security script to secure your MariaDB installation:

sudo mysql_secure_installation

Follow the prompts to set the root password and secure your installation.


Step 4: Install PHP

PHP is the server-side scripting language used to develop dynamic web content. Install PHP and necessary modules with:

sudo dnf install -y php php-mysqlnd php-fpm
sudo systemctl start php-fpm
sudo systemctl enable php-fpm

Restart Apache to load the PHP module:

sudo systemctl restart httpd

Step 5: Configure Firewall

If you have a firewall enabled, allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Step 6: Test PHP

Create a PHP info file to test your PHP configuration. Create the file in the web root directory:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Visit http://localhost/info.php in your web browser. You should see a PHP info page showing your PHP configuration.


Step 7: Secure Your LAMP Stack

1. Configure Apache:

Edit the Apache configuration file to improve security:

sudo nano /etc/httpd/conf/httpd.conf

Add or modify the following settings:

ServerTokens Prod
ServerSignature Off
TraceEnable Off

2. Configure PHP:

Edit the PHP configuration file to enhance security:

sudo nano /etc/php.ini

Modify the following settings:

expose_php = Off

3. Restart Services:

Restart Apache and PHP-FPM to apply the changes:

sudo systemctl restart httpd
sudo systemctl restart php-fpm

Conclusion

Congratulations! You have successfully set up a LAMP stack on your Fedora Linux system. You can now start developing your web applications using Apache, MariaDB, and PHP. If you have any questions or run into issues, feel free to leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *