Popular high-performance web servers include Nginx. You will learn how to install and launch Nginx on your CentOS 7 server in this guide.
This tutorial’s instructions call for a non-root user with sudo capabilities.
You must first establish an SSH connection to your CentOS 7 system before you can use the yum command to add the EPEL repository:
You will be asked to confirm your desire to install the software. Enter y to continue after you.
After that, you’ll set up the actual nginx programme.
After setting up the EPEL repository on your server, run the yum command below to install Nginx:
Once more, select yes to the verification question, and Nginx’s installation will be completed.
Nginx won’t launch on its own after installation. Make use of the systemctl command to start Nginx:
Systemctl status can be used to determine the status of the service.
● nginx.service – The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2022-01-24 20:14:24 UTC; 5s ago
Process: 1898 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 1896 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1895 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 1900 (nginx)
├─1900 nginx: master process /usr/sbin/nginx
└─1901 nginx: worker process
Jan 24 20:14:24 centos-updates systemd: Starting The nginx HTTP and reverse proxy server…
Jan 24 20:14:24 centos-updates nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jan 24 20:14:24 centos-updates nginx: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jan 24 20:14:24 centos-updates systemd: Started The nginx HTTP and reverse proxy server.
The service should be active.
Run the following commands on your firewall to enable HTTP and HTTPS traffic:
Visit your server’s public IP address in your web browser straight away to make sure everything went according to plan:
You will view the CentOS 7 Nginx default web page, which is provided for testing and informational reasons. It should resemble the following:
Your web server has now been correctly installed if you can view this page.
Note: Look for the network interfaces on your computer by typing: To discover your server’s public IP address, locate:
1. lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
. . .
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
. . .
Based on the hardware your server has, you can notice a variety of interfaces here. The local loopback interface, or lo interface, is not what we desire. We want the eth0 interface in the aforementioned case.
Run the following command to disclose your server’s public IP address once you have the interface name. Replace with the interface name you discovered above:
You should enable Nginx to start when your system boots before moving on. Enter the following command to accomplish that:
Currently, Nginx is set up and operating.
The locations of the Nginx configuration files and the default server root directory are important to know if you wish to start using Nginx to serve your own web pages or applications.
/usr/share/nginx/html is the server’s default home directory. The files you put there will be provided by your web server. This location is supplied in the /etc/nginx/conf.d/default.conf configuration file for the default server block that comes with Nginx.
/etc/nginx/nginx.conf is the location of the main Nginx configuration file. Here, among other things, you can modify parameters like the user who manages the Nginx daemon processes and the quantity of worker processes that are launched when Nginx is active.
Once you have Nginx installed on your CentOS 7 server.