1080*80 ad

Installing Nginx on Fedora 30

How to Install Nginx on Fedora: A Complete Step-by-Step Guide

Looking to set up a high-performance, lightweight, and reliable web server? Nginx is one of the most popular choices in the world, renowned for its stability, rich feature set, and low resource consumption. Whether you’re hosting a personal blog, a complex application, or a high-traffic e-commerce site, Nginx provides a powerful foundation.

This guide will walk you through the entire process of installing and configuring Nginx on your Fedora system. While these instructions are designed for modern, supported versions of Fedora, the core commands are consistent across recent releases. It is crucial to always run a currently supported version of Fedora to receive critical security updates and patches.

Prerequisites

Before you begin, ensure you have the following:

  • A system running a supported version of Fedora.
  • Access to a user account with sudo or root privileges.
  • An active internet connection.

Step 1: Update Your System Packages

Before installing new software, it’s always a best practice to update your system’s package repository. This ensures you are installing the latest, most secure versions of all software and their dependencies.

Open your terminal and run the following command:

sudo dnf update -y

This command will download and apply any available updates. Wait for it to complete before proceeding.

Step 2: Install the Nginx Web Server

Nginx is available in the default Fedora repositories, making the installation process straightforward.

To install the Nginx package, use the DNF package manager by executing this command in your terminal:

sudo dnf install nginx -y

The system will resolve all necessary dependencies and install Nginx for you. The -y flag automatically confirms the installation prompt.

Step 3: Start and Enable the Nginx Service

After the installation is complete, the Nginx service will not start automatically. You need to manually start it and then enable it to launch on system boot.

First, start the Nginx service for the current session:

sudo systemctl start nginx

Next, enable Nginx to start automatically every time the system boots up:

sudo systemctl enable nginx

This command creates the necessary system links so you don’t have to manually start the server after a reboot.

To verify that the service is running correctly, you can check its status:

sudo systemctl status nginx

You should see an output indicating the service is active (running).

Step 4: Configure the Firewall to Allow Web Traffic

By default, Fedora’s firewall will block external connections to the web server. You must configure your system’s firewall to allow HTTP and HTTPS traffic so that visitors can access your site.

Fedora uses firewalld as its default firewall management tool. Use the following commands to permanently open ports 80 (HTTP) and 443 (HTTPS):

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

The --permanent flag ensures these rules persist after a reboot. For the new rules to take effect, you must reload the firewall:

sudo firewall-cmd --reload

You will see a success message confirming the rules have been applied.

Step 5: Verify Your Nginx Installation

With Nginx installed and the firewall configured, it’s time to verify that everything is working. You’ll need your server’s public or private IP address. You can find it by running one of these commands:

ip a

or

hostname -I

Once you have the IP address, open a web browser on your local machine or another device on the same network and navigate to http://your_server_ip.

If the installation was successful, you will be greeted by the default Nginx welcome page. This page confirms that your web server is installed, running, and accessible.

Next Steps and Essential Security Tips

You now have a fully functional Nginx web server. Here are some critical next steps to take:

  • Configure Server Blocks: In the Nginx world, “Server Blocks” are what Apache users know as “Virtual Hosts.” They allow you to host multiple websites on a single server. You can create configuration files for your domains in the /etc/nginx/conf.d/ directory. This is essential for hosting actual websites instead of just the default page.

  • Secure Your Site with SSL/TLS: In today’s web, serving content over HTTPS is non-negotiable. It encrypts traffic and builds user trust. We strongly recommend using Let’s Encrypt to get free SSL/TLS certificates. You can easily automate this process by installing the certbot tool.

  • Review Nginx Configuration: The main Nginx configuration file is located at /etc/nginx/nginx.conf. Take some time to familiarize yourself with its structure and options to better optimize performance and security for your specific needs.

By following these steps, you have successfully deployed a powerful and efficient Nginx web server on your Fedora system, creating a solid foundation for all your web hosting projects.

Source: https://kifarunix.com/install-nginx-web-server-on-fedora-30/

900*80 ad

      1080*80 ad