How to Install LAMP Server on Fedora 31

LAMP stands for Linux, Apache, MySQL, and PHP. A great combination to build a powerful web server based on Linux distribution. This tutorial will show you how to install LAMP on Fedora 31. In other words, we are going to build a powerful web server with a MySQL database back end. I have written many tutorials about how to build a powerful web server using Linux.

There are things to do to complete this task. But I will try to explain them one by one. This tutorial is applicable to both Fedora 31 Server or Workstation edition.

Steps to Install LAMP Server on Fedora 31

Step 1. Update System

Well, it is good to update Fedora before continuing to the next steps. Let’s update Fedora 31 with this command

sudo dnf update

Step 2. Set the SELinux

By default, Fedora 31 SELinux is set to enabled. Now we need to disable it. Use the following command to permanently disable it

sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

Now make sure the SELinux is disabled

cat /etc/selinux/config | grep SELINUX=

Output:

SELINUX= can take one of these three values:
SELINUX=disabled

Step 3. Install Apache Web Server

Now we need to start the service and enable it on startup

sudo systemctl start httpd
sudo systemctl enable httpd

Now let’s configure the basic settings. Edit the file /etc/httpd/conf/httpd.conf and set the following:

ServerAdmin admin@example.com 
ServerName  example.com 
ServerTokens Prod 

Now configure the firewall so the http and https traffic is allowed.

sudo firewall-cmd --add-service={http,https} --permanent 
sudo firewall-cmd --reload 

Test the webserver

Open the web browser and type “localhost” on the address bar. You should see something like this.

You should be able to webserver from another computer in your network by typing the server IP address.

Step 4. Install MariaDB Database

Now we are going to install MariaDB Database on Fedora 31. MariaDB is a fork of MySQL database.

sudo dnf install mariadb-server

Next, Start and enable the database server

sudo systemctl start mariadb
sudo systemctl enable mariadb

Now, let’s secure the MariaDB

sudo mysql_secure_installation

Follow the installation step shown on-screen. You will need to create a new password for MariaDB root user etc.

Allow MySQL Service over the firewall

sudo firewall-cmd --add-service=mysql --permanent 
sudo firewall-cmd --reload 

Now, we are finished installing the MariaDB Server on Fedora 31.

Step 5. Install PHP and Extensions

Last, we need to install PHP and some additional extensions.

sudo dnf -y install php php-cli php-php-gettext php-mbstring php-mcrypt php-mysqlnd php-pear php-curl php-gd php-xml php-bcmath php-zip

Next, let’s check which PHP version we got.

[dhani@localhost ~]$ php -v
 PHP 7.3.12 (cli) (built: Nov 19 2019 10:24:51) ( NTS )
 Copyright (c) 1997-2018 The PHP Group
 Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
     with Zend OPcache v7.3.12, Copyright (c) 1999-2018, by Zend Technologies

As you can see, I am now running PHP version 7.3.12. This could be different from yours.

Step 6. Check LAMP Installation

Ok so basically, now we have everything installed. Let’s test the overall installation. Create new info.php under /var/www/html/ directory and then paste these lines

 <?php 
// Show all information, defaults to INFO_ALL phpinfo(); 
?> 

Now restart the server

sudo systemctl restart httpd

And then open web browser and type the following address: localhost/info.php

You should see something like this

1 Trackback / Pingback

  1. Build a Powerful Wordpress Site on Fedora 31 | Manjaro dot site

Leave a Reply

Your email address will not be published.


*