In this tutorial, we will show you how to install LAMP Stack on Fedora 35. For those of you who didn’t know, the LAMP stack is a known combination of Linux, Apache, MariaDB, and PHP. Here Linux is an operating system, Apache is the popular web server developed by Apache Foundation, MariaDB is a relational database management system used for storing data and PHP is the widely used programming language. With LAMP it is possible to develop and deploy web applications created in PHP.
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 Apache, MariaDB & PHP (LAMP Stack) on a Fedora 35.
Prerequisites
- A server running one of the following operating systems: Fedora 35.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-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 35
Step 1. Before proceeding, update your Fedora operating system to make sure all existing packages are up to date. Use this command to update the server packages:
sudo dnf upgrade sudo dnf update
Step 2. Installing Apache Server on Fedora 35.
By default, Apache is available on Fedora 35 base repository. Then we can install the Apache webserver with the following command below:
sudo dnf install httpd
After installation is complete we need to start the Apache server to start operating. We do that with the following command below:
sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl status httpd
Configure Apache Basic Settings:
Now we edit the configuration file /etc/httpd/conf/httpd.conf
and set:
nano etc/httpd/conf/httpd.conf
Add the following configuration:
ServerAdmin admin@your-domian.com ServerName your-domian.com ServerTokens Prod
Configure Firewall:
If you have firewalld running, allow HTTP and HTTPS services:
sudo firewall-cmd --add-service={http,https} --permanent sudo firewall-cmd --reload
Accessing Apache Web Test Page.
Once successfully installed, now verify that the webserver is running and accessible by accessing your server’s IP address:
http://your-IP-address
Output:
Step 3. Installing MariaDB on Fedora 35.
By default, MariaDB is available on Fedora 35 base repository. Then we can install MariaDB with the following command below:
sudo dnf install mariadb-server
Once the installation is complete, we need to start the MariaDB server to start operating. We do that with the following command below:
sudo systemctl start mariadb sudo systemctl enable mariadb sudo systemctl status mariadb
Secure MariaDB Installation:
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation
script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
mysql_secure_installation
Configure it like this:
- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y
To log into MariaDB, use the following command (note that it’s the same command you would use to log into a MariaDB database):
mysql -u root -p
Check the MariaDB version:
MariaDB [(none)]> SELECT VERSION(); +-----------------+ | VERSION() | +-----------------+ | 10.6.5-MariaDB | +-----------------+ 1 row in set (0.000 sec) MariaDB [(none)]>
Step 4. Installing PHP 8 on Fedora 35.
By default, PHP is not available on Fedora 35 base repository. Then we add the Remi repository to your system with the following command below:
sudo dnf install http://rpms.remirepo.net/fedora/remi-release-35.rpm
After that, reset the PHP module and enable PHP 8 from the Remi-8.0 module using the following command:
sudo dnf module reset php sudo dnf config-manager --set-enabled remi sudo dnf module enable php:remi-8.1
Finally, you can install PHP 8.0 with the following command below:
sudo dnf module install php:remi-8.1
Check the installed version of PHP on your Fedora Linux:
$ php -v
PHP 8.1.0RC6 (cli) (built: Nov 20 2021 10:15:52) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies
Installing PHP 8 Extensions:
Optionally, if you would like to install PHP extensions using the name format php-<extension>
. For example:
sudo dnf install php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
After that, restart your web server so that Apache knows that it will be serving PHP requests as well:
sudo systemctl restart httpd
To confirm that our web server is accessible and that PHP is working as expected, we can create a file called info.php
inside the /var/www/html
directory:
sudo nano /var/www/html/info.php
Add the following line:
<?php phpinfo (); ?>
We can now load this file in the browser by going to http://your-ip-address/info.php
or http://your-domian.com/info.php
.
Congratulations! You have successfully installed LAMP. Thanks for using this tutorial for installing LAMP (Apache, MariaDB, and PHP) Stack on your Fedora 35 system. For additional help or useful information, we recommend you check the official LAMP website.