FedoraRHEL Based

How To Install LAMP Stack on Fedora 39

Install LAMP Stack on Fedora 39

In this tutorial, we will show you how to install LAMP Stack on Fedora 39. In the realm of web development, the LAMP Stack holds a pivotal role. An acronym for Linux, Apache, MariaDB, and PHP, the LAMP Stack is a powerful combination of open-source software that provides a robust framework for building dynamic websites and web applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the LAMP Stack on a Fedora 39.


Before diving into the installation process, let’s ensure that you have everything you need:

  • A server running one of the following operating systems: Fedora 39.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • You will need access to the terminal to execute commands. Fedora 39 provides the Terminal application for this purpose. It can be found in your Applications menu.
  • You’ll need an active internet connection to download Apache, MariaDB, PHP, and its dependencies.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install LAMP Stack on Fedora 39

Step 1. Start by updating your system’s package list. Open your terminal and type the following command:

sudo dnf clean all
sudo dnf update

These commands will fetch the latest updates for your system, providing a stable foundation for the upcoming installation.

Step 2. Installing Apache (HTTP Server)

To install Apache, use the following command:

sudo dnf install httpd

Once installed, start the Apache service and enable it to start on boot with these commands:

sudo systemctl start httpd
sudo systemctl enable httpd

To verify that Apache is installed and running, open a web browser and navigate to your server’s public IP address or domain name. You should see the Apache test page.

Step 3. Installing MariaDB.

To install MariaDB, use the following command:

sudo dnf install mariadb-server

Start the MariaDB service and enable it to start on boot with these commands:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the mysql_secure_installation script to improve MariaDB’s security:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, and remove the test database.

To verify that MariaDB is installed and running, use the following command:

sudo systemctl status mariadb

Step 4. Installing PHP.

To install PHP and some common modules, use the following command:

sudo dnf install php php-mysqlnd php-fpm

To configure PHP to work with Apache, you need to edit the Apache configuration file. Open the file with this command:

sudo nano /etc/httpd/conf.d/php.conf

Find the line that starts with DirectoryIndex and add index.php to the list of files. Save and close the file.

To verify that PHP is installed and configured correctly, create a PHP info file in the web root directory:

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

Open a web browser and navigate to http://your_server_ip/info.php. You should see a page displaying information about your PHP installation.

Step 5. Configure Firewall.

To install and enable the Firewalld service, use the following commands:

sudo dnf install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld

Add the HTTP and HTTPS services to the firewall with these commands:

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

Reload the firewall configuration to apply the changes:

sudo firewall-cmd --reload

Step 6. Set up HTTPS with Let’s Encrypt.

To install Certbot, the client software for Let’s Encrypt, use the following command:

sudo dnf install certbot python3-certbot-apache

Obtain an SSL certificate for your domain with this command:

sudo certbot --apache -d your_domain

Certbot should automatically configure Apache to use the SSL certificate. Verify this by navigating to https://your_domain in a web browser. You should see a lock icon in the address bar.

To set up automatic certificate renewal, add a cron job that runs the certbot renew command twice a day:

echo "0 */12 * * * root certbot renew --quiet" | sudo tee -a /etc/crontab

Step 7. Troubleshooting

A. Common Apache Issues

1. Permission Errors

If you encounter permission errors, check the ownership and permissions of your web root directory and its contents. They should be owned by the Apache user and group, and their permissions should allow Apache to read, write, and execute files as necessary.

2. Configuration Errors

If Apache fails to start or function correctly, check the syntax of your configuration files with the command sudo apachectl configtest. Fix any reported errors and restart Apache.

B. Common MariaDB Issues

1. Connection Errors

If you can’t connect to MariaDB, ensure the service is running with sudo systemctl status mariadb. If it’s not running, start it with sudo systemctl start mariadb.

2. Authentication Errors

If you can’t authenticate with MariaDB, ensure you’re using the correct username and password. If you’ve forgotten the root password, you can reset it by starting MariaDB with the --skip-grant-tables option, logging in as root, and running the appropriate SQL commands to change the password.

C. Common PHP Issues

1. Syntax Errors

If your PHP scripts aren’t working as expected, check for syntax errors. You can do this by running the script from the command line with the -l option, like so: php -l script.php.

2. Module-Related Errors

If you’re having trouble with a PHP module, ensure it’s installed and enabled. You can list all installed modules with php -m. If a module isn’t listed, you can install it with sudo dnf install php-module, replacing “module” with the name of the module.

D. Common Firewall and HTTPS Issues

1. Blocked Ports

If you can’t access your website, ensure your firewall isn’t blocking the necessary ports. You can list all open ports with sudo firewall-cmd --list-ports.

2. SSL Certificate Errors

If you’re having trouble with your SSL certificate, check its status with sudo certbot certificates. If there are any issues, you can attempt to renew the certificate with sudo certbot renew.

Congratulations! You have successfully installed LAMP. Thanks for using this tutorial for installing the LAMP Stack on your Fedora 39 system. For additional or useful information, we recommend you check the official LAMP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
Back to top button