第 2 章 Setting up and configuring NGINX
NGINX is a high performance and modular server that you can use, for example, as a:
- Web server
- Reverse proxy
- Load balancer
2.1. Installing and preparing NGINX 复制链接链接已复制到粘贴板!
Red Hat uses Application Streams to provide different versions of NGINX. You can do the following:
- Select a stream and install NGINX
- Open the required ports in the firewall
-
Enable and start the
nginxservice
Using the default configuration, NGINX runs as a web server on port 80 and provides content from the /usr/share/nginx/html/ directory.
Prerequisites
- The host is subscribed to the Red Hat Customer Portal.
-
The
firewalldservice is enabled and started.
Procedure
Install the
nginxpackage:# dnf install nginxOpen the ports on which NGINX should provide its service in the firewall. For example, to open the default ports for HTTP (port 80) and HTTPS (port 443) in
firewalld, enter:# firewall-cmd --permanent --add-port={80/tcp,443/tcp} # firewall-cmd --reloadEnable the
nginxservice to start automatically when the system boots:# systemctl enable nginxOptional: Start the
nginxservice:# systemctl start nginxIf you do not want to use the default configuration, skip this step, and configure NGINX accordingly before you start the service.
Verification
Use the
dnfutility to verify that thenginxpackage is installed:# dnf list installed nginx Installed Packages nginx.x86_64 1:1.14.1-9.module+el8.0.0+4108+af250afe @rhel-8-for-x86_64-appstream-rpmsEnsure that the ports on which NGINX should provide its service are opened in the firewalld:
# firewall-cmd --list-ports 80/tcp 443/tcpVerify that the
nginxservice is enabled:# systemctl is-enabled nginx enabled