FedoraRHEL Based

How To Install LEMP on Fedora 37

Install LEMP on Fedora 37

In this tutorial, we will show you how to install LEMP on Fedora 37. Hey there, web developers and tech enthusiasts! Are you ready to power up your web applications with the lightning-fast LEMP software stack? Look no further, because we’ve got you covered with this guide on how to install LEMP on Fedora 37.

LEMP is the ultimate powerhouse software stack that provides a reliable, secure, and lightning-fast environment for web development and deployment. It’s the go-to choice for developers looking to take their web applications to the next level, and we’re here to help you get started.

In this post, we’re going to walk you through every step of the installation and configuration process. From installing the necessary software packages to configuring Nginx as your web server, securing MySQL, and configuring PHP for your web applications – we’ve got it all covered.

By the end of this tutorial, you’ll have a fully functional LEMP stack on your Fedora 37 system that’s ready to take on whatever web development challenges come your way.

Prerequisites

  • A server running one of the following operating systems: Fedora 37.
  • 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).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for LEMP.
  • 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 LEMP on Fedora 37

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 Nginx.

By default, the Nginx package comes in the default Fedora 37 repository. Now run the following command below to install Nginx to your Fedora system:

sudo dnf install nginx

After the installation is complete, start the Nginx service and enable it to start automatically on boot by running the following commands:

sudo systemctl start nginx
sudo systemctl enable nginx

We need to enable the firewall in order to filter traffic into our server. Now we add HTTP and HTTPS ports in the firewall using the following command:

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

To verify the installation of Nginx, you can access the default welcome page by opening a web browser and navigating to http://localhost or http://your-IP-address. You will get the following screen:

Install Nginx on Fedora 37

For additional resources on installing Nginx, read the post below:

Step 3. Installing MariaDB.

By default, MariaDB is available in the default repositories of Fedora 37, so you can install it using the dnf package manager. To install MariaDB, run the following command below:

sudo dnf install mariadb-server mariadb-client

After the installation is complete, start and enable MariaDB to run at boot time with the following command:

sudo systemctl start mariadb
sudo systemctl enable mariadb

It is recommended to secure the MariaDB installation to prevent unauthorized access to the database. Run the following command to run the security script:

sudo mysql_secure_installation

You will be prompted to answer some questions about the security settings of MariaDB. Follow the prompts and answer the questions:

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y

You can verify the installation of MariaDB on Fedora 37 by connecting to the MariaDB server using the following command:

sudo mysql -u root -p

Enter the root password that you set during the secure installation process. If the connection is successful, you will be presented with the MariaDB shell prompt, which looks like this:

MariaDB [(none)]>

For additional resources on installing MariaDB, read the post below:

Step 4. Installing PHP.

To install PHP on Fedora, you need to set up the REMI repository. Now import the Remi PHP repository using the following command below:

sudo dnf install http://rpms.remirepo.net/fedora/remi-release-37.rpm

Now, verify the installation:

dnf repolist | grep remi

Output:

[root@idroot.us ~]$ dnf repolist | grep remi
remi Remi's RPM repository - Fedora 37 - x86_64
remi-modular Remi's Modular repository - Fedora 37 - x86_64

By default, the PHP package comes in the default repository of Fedora 37. Now run the following command below to install the PHP 8.1 packages to your Fedora system:

sudo dnf module enable php:remi-8.1
sudo dnf install php php-common php-cli

In addition, if you would like to install the most commonly used extensions for PHP 8.1, use the following command:

sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache

After installing PHP, use the below command to check its version:

php -v

Output:

PHP 8.1.13 (cli) (built: Nov 28 2022 11:36:13) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.13, Copyright (c), by Zend Technologies

For additional resources on installing PHP, read the post below:

Step 5. Test Your LEMP Stack.

Once you have completed the installation and configuration of Nginx, MySQL, and PHP, you can test your LEMP stack by creating a PHP file with some simple code. Here are the steps to do this:

Create a new file named “info.php” in the Nginx document root directory:

nano /var/www/html/info.php

Add the following code to the file:

<?php
phpinfo();
?>

Save the file and exit the editor and open your web browser, navigate to http://your-IP-address/info.php. You should see a page with information about your PHP installation.

Congratulations! You have successfully installed LEMP. Thanks for using this tutorial for installing the LEMP on your Fedora 37 system. For additional help or useful information, we recommend you check the official LEMP 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