How To Install LAMP Stack on Fedora 40
In this tutorial, we will show you how to install LAMP Stack on Fedora 40. LAMP stack is a powerful combination of open-source software used for developing and deploying dynamic web applications. It consists of Linux as the operating system, Apache as the web server, MariaDB or MySQL as the database management system, and PHP as the server-side scripting language. Installing a LAMP stack on Fedora 40 provides a robust foundation for hosting 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 Fedora 40.
Prerequisites
Before we dive into the installation process, ensure that you have the following prerequisites in place:
- A server running one of the following operating systems: Fedora 40.
- 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 provides the Terminal application for this purpose. It can be found in your Applications menu.
- A stable internet connection to download the necessary packages.
- 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 40
Step 1. Update the System.
To ensure a smooth installation process, it’s crucial to start with an up-to-date system. Open a terminal and run the following commands to update your Fedora 40 installation:
sudo dnf clean all sudo dnf update
These commands will clean the package cache and fetch the latest updates for your system.
Step 2. Installing Apache.
The first component of the LAMP stack we’ll install is Apache, the world’s most popular web server. Apache is responsible for serving web content to clients (such as web browsers) over the internet or a local network.
To install Apache on your Fedora 40 Server, open your terminal and use the dnf
package manager:
sudo dnf install httpd
After the installation is complete, start and enable the Apache service to ensure it runs automatically on system boot:
sudo systemctl start httpd sudo systemctl enable httpd
To verify that Apache is running correctly, open your web browser and visit http://localhost
. You should see the default Apache welcome page.
Step 3. Installing MariaDB (MySQL).
The next component of the LAMP stack is the database management system. In this guide, we’ll be using MariaDB, a community-developed fork of the MySQL database server. MariaDB is known for its compatibility with MySQL while offering improved performance and additional features.
To install MariaDB on your Fedora 40 Server, use the dnf
package manager:
sudo dnf install mariadb-server
After the installation is complete, start and enable the MariaDB service to ensure it runs automatically on system boot:
sudo systemctl start mariadb sudo systemctl enable mariadb
To secure your MariaDB installation, run the mysql_secure_installation
script:
sudo mysql_secure_installation
This script will prompt you to set a root password, remove anonymous users, restrict root user access from remote hosts, and remove the test database.
To verify the installation, access the MySQL prompt by running:
sudo mysql -u root -p
Enter the root password you set during the mysql_secure_installation
process. Once inside the MySQL prompt, create a test database and table:
CREATE DATABASE test_db; USE test_db; CREATE TABLE test_table (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50)); INSERT INTO test_table (name) VALUES ('meilana'), ('maria'), ('ulfa'); SELECT * FROM test_table;
This will create a test database named test_db
, a table named test_table
, insert some sample data, and display the contents of the table.
Step 4. Installing PHP.
The final component of the LAMP stack is PHP, a server-side scripting language used for web development. PHP allows you to create dynamic, database-driven websites and web applications.
To install PHP and common extensions on your Fedora 40 Server, use the dnf
package manager:
sudo dnf install php php-mysqlnd php-gd php-xml
To verify the PHP installation, create a phpinfo.php file in the Apache document root directory (/var/www/html/
) with the following content:
<?php phpinfo();
Open your web browser and visit http://localhost/phpinfo.php
. You should see a detailed information page about your PHP configuration, including the version and loaded extensions.
Congratulations! You have successfully installed LAMP. Thanks for using this tutorial for installing the LAMP Stack on Fedora 40. system. For additional help or useful information, we recommend you check the Fedora website.