In this tutorial i will show you how to install Nginx on Fedora 35.
Nginx is a fast and lightweight web, http load balancer, reverse proxy and http cache server. Its scalability and efficiency makes Nginx both suitable for small and high traffic servers. It can also function as a proxy server for email IMAP,POP3 and SMTP.
Nginx has proved to be ideal web server for many web task because it can handle a high volume of connections. Nginx is frequently placed between clients and a second server to serve as an SSL/TLS terminator or web accelerator. Dynamic sites build with languages like PHP, node.js deploy Nginx as content cache and reverse proxy to reduce load on application servers and make the most effective use of the underlying hardware.
To install Nginx on Fedora 35, we need to have the following:
- Fedora 35 server having users with sudo priviledges
- Internet connection
- Familiarity with command line interface
Install Nginx via DNF
We use dnf command to run installation for the latest version of Fedora including the recent release of Fedora 35. So what we need to do is to first update the system with the following command.
$ sudo dnf update -y
When the update is complete, then we can install Nginx with the following command:
sudo dnf install nginx
Press y when prompted to allow the installation to continue. During installation all the dependency packages are installed so you don’t have to worry about them.
Now After instalaltion is complete we need to start the Nginx server to start operational. We do that with the following command;
$ systemctl start nginx.service
Another important aspect of Nginx is to enable it to start on reboot so that you can not be doing it manually every time you reboot the system. Use the enable command to accomplish this;
$ systemctl enable nginx.service
This command will create system link pointing to the nginx service.
Check your firewall if it is enable, so that you will be able to pass HTTP traffic in the server. We need to enable the firewall in order to filter traffic into our server. RPM uses firewalld to set up firewall. To set up firewalld use the following command
$ sudo dnf install firewalld -y
When the installation is complete, now we can start our firewalld with the following command;
$ systemctl start firewalld
You can now check the status of firewalld with the following command;
$ systemctl status firewalld
# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-11-09 09:24:20 UTC; 1min 18s ago Docs: man:firewalld(1) Main PID: 20276 (firewalld) Tasks: 2 (limit: 2336) Memory: 24.2M CPU: 546ms CGroup: /system.slice/firewalld.service └─20276 /usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid Nov 09 09:24:19 fedora systemd: Starting firewalld - dynamic firewall daemon... Nov 09 09:24:20 fedora systemd: Started firewalld - dynamic firewall daemon.
Firewalld is now running, we need to allow Nginx to to pass the firewall rules. We need to permanently allow HTTP to pass which is running on port 80 by default.
We need to add http with the following command;
$ sudo firewall-cmd --permanent --add-service=http
You will get a success message which shows it had added the http onto allowed rules. You will need to reload the firewall for the changes to take effect.
$ firewall-cmd --reload
If you get a success message you are good to go.
You can now verify if the changes was indeed accepted.
sudo firewall-cmd --permanent --list-all
Sample output will be as follows
# firewall-cmd --permanent --list-all public target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client http mdns ssh ports: protocols: forward: no masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
We can now go ahead and check on our browser if our installation was successful. Enter your server IP address on the browser. If you dont know the IP address you can check with the following command;
$ curl -4 icanhazip.com
This command will give you the IP address of your server. Type that IP address on your browser.
You have learn how to install Nginx on Fedora 35 server. You can go ahead and configure it to server your website correctly.