LAMP Stack Setup on Fedora 39 From Terminal

This guide will teach you the LAMP Stack Installation Setup on Fedora Linux 39 From Terminal. As you must know, LAMP stands for Linux, Apache, MySQL or MariaDB, and PHP is used for web development. Every component is an essential part of the stack needed for your dynamic websites. You can follow the rest of the article to start your LAMP stack installation on Fedora Linux 39 from the command line interface.

LAMP Stack Installation Setup Guide on Fedora 39 From Terminal

Before you start your LAMP stack installation on Fedora 39, you must have access to your server as a non-root user with sudo privileges. Then, you need to set up a basic firewall. For this purpose, you can check this guide on Manage Firewalld in Fedora 39 From Terminal.

Also, you need to disable your SELinux. To do this, you can check this guide on Configure SELinux in Fedora Linux Command Line.

Now follow the steps below to complete this guide.

Step 1 – Install Apache Web Server on Fedora 39 From Terminal

The first part of the LAMP Stack setup is to install Apache as your Web server. To do this, run the system update and install Apache by using the following commands:

# sudo dnf update -y
# sudo dnf install httpd -y

Note: If you have transaction test error issues during the DNF update process, you can check this guide to fix it: Fix dnf update Error: Transaction test error.

When our installation is completed, you must start and enable your web server on Fedora 39.

Start and Enable Apache on Fedora39

At this point, you can use the following commands to start and enable your Apache web server:

# sudo systemctl start httpd
# sudo systemctl enable httpd

Verify your Apache service is active and running on Fedora 39:

sudo systemctl status httpd

Example Output:

Apache web server status fedora 39

Configure Firewalld Rules for Apache on Fedora 39

At this point, you must allow Apache traffic through your Firewalld rules. To do this, you need to allow port 80 or http service by using the command below:

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

Reload the firewall to apply the new rules:

sudo firewall-cmd --reload

Then, you can verify your Apache web server is working correctly, you can type your server’s IP address in your web browser to see your Apache default page.


Note: If you don’t know your server’s IP address, you can check this guide on 4 Linux Commands to Get a Public IP Address.

Step 2 – LAMP Stack Setup | Install MariaDB on Fedora 39

The second part of the LAMP stack setup on Fedora 39 is to install MariaDB or MySQL as your database engine. In this guide, we use MariaDB. To install it, you can run the command below:

sudo dnf install mariadb-server mariadb -y

When your installation is completed, you need to start and enable your MariaDB service.

Start and Enable MariaDB on Fedora 39

To start and enable your MariaDB server, you can run the following commands:

# sudo systemctl start mariadb
# sudo systemctl enable mariadb

Verify your MariaDB server is active and running with the command below:

sudo systemctl status mariadb

Example Output:

MariaDB server status Fedora 39 Terminal

Run MariaDB or MySQL Secure Installation script on Fedora 39

At this point, to make your MariaDB server more secure, you must run the secure installation script. To do this, use the command below:

sudo mysql_secure_installation

Answer the questions as shown below and set a strong password for your MariaDB server:

Enter current password for root (enter for none): 
Set root password? [Y/n] Y 
New password: 
Re-enter new password: 
Remove anonymous users? [Y/n] Y 
Disallow root login remotely? [Y/n] Y 
Remove test database and access to it? [Y/n] 
Reload privilege tables now? [Y/n] Y

Now you can log in to your MariaDB server with your password by using the command below:

sudo mysql -u root -p

Example Output:

Access MariaDB shell Fedora 39

To exit from your MariaDB shell, you can run:

MariaDB [(none)]> EXIT;

Step 3 – PHP Setup on Fedora 39 from Terminal

The last part of the LAMP Stack installation is the PHP setup. The default PHP version in Fedora 39 is PHP 8.2. You can simply use the command below to install PHP and the most common extensions:

sudo dnf install php php-curl php-bcmath php-gd php-soap php-zip php-curl php-mbstring php-mysqlnd php-gd php-xml php-intl php-zip

Note: To get the latest PHP 8.3, you can visit this guide on Installing PHP 8.3 on Fedora Linux 39.

When your installation is completed, verify it by checking the PHP version:

php -v

Example Output:

PHP version Fedora Linux 39

Test PHP with Apache web server on Fedora 39

At this point, you can verify that your web server is accessible and the PHP is working as expected. To do this, create and open a smile PHP file with your favorite text editor like vi editor or nano editor:

sudo vi /var/www/html/info.php

Add the following content to the file:




When you’re done, save and close the file.

Then, restart Apache to apply the changes:

sudo systemctl restart httpd

Now in your web browser type your server’s IP address followed by /info.php:


You will see your PHP information in detail. After you have read your PHP info, for more security it’s better to remove it with the command below:

sudo rm /var/www/html/info.php


At this point, you have learned to Install LAMP Stack (Apache, MariaDB, and PHP) on Fedora Linux 39 for your web development from the Terminal command line. Hope you enjoy using it. Also, you may like to read the following articles:

Install LAMP Stack on Debian 12 Bookworm

Install LAMP Stack on AlmaLinux 9

WordPress Installation Guide on Fedora Linux 39

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!