Implementation steps for Nginx installation in yum mode under CentOS7

  • 2020-06-15 11:01:48
  • OfStack

Steps to install Nginx in yum mode under CentOS7

Nginx is a powerful, high-performance Web and reverse proxy server with a number of excellent features. Low overhead, high concurrency, support for caching, support for forward and backward proxies, support for load balancing, support for regularization, support for rewrite, etc. So the fans are numerous. This article briefly describes the installation and deployment of yum based on CentOS 7 for your reference.

If it is a compiled installation, please refer to: Linux 6 for installation

For common configuration of Nginx, see: Overview of Nginx and daily administration

1. Configure nginx yum source

 The demo environment 
[root@centos7-router ~]# more /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

[root@centos7-router ~]# vim /etc/yum.repos.d/nginx.repo

name=nginx repo

 Will be in the above configuration file OS Replace with rhel or centos . OSRELEASE Replace with 6 or 7 Which is the current Linux for 6 or 7 version 

 Look at the machine ip
[root@centos7-router ~]# ip addr|grep inet|grep global
inet brd scope global eno16777728
inet brd scope global dynamic eno33554960

2. Install nginx

[root@centos7-router ~]# yum install nginx -y
[root@centos7-router ~]# yum install nginx-module-perl.x86_64 -y 

 View the relevant documentation of the process 
[root@centos7-router ~]# rpm -ql nginx

3. Verify nginx

 Start the nginx
root@centos7-router ~]# systemctl start nginx
[root@centos7-router ~]# systemctl enable nginx ### Configure self-start 
[root@centos7-router ~]# ss -nltp|grep nginx
LISTEN 0 128 *:80 *:* users:(("nginx",pid=65418,fd=6),("nginx",pid=65415,fd=6))

 To view nginx The version of the 
[root@centos7-router ~]# nginx -v
nginx version: nginx/1.12.2

 View or modify the configuration file 
[root@centos7-router ~]# more /etc/nginx/nginx.conf

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/;

events {
worker_connections 1024;

http {
include /etc/nginx/mime.types;  ### Author : Leshami
default_type application/octet-stream; ### Blog :

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;

[root@centos7-router ~]# firewall-cmd --add-service=http --permanent
[root@centos7-router ~]# firewall-cmd --reload

 Verify from other machines nginx
[root@centos7-web ~]# curl
<!DOCTYPE html>
<title>Welcome to nginx!</title>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="" rel="external nofollow" ></a>.<br/>
Commercial support is available at
<a href="" rel="external nofollow" ></a>.</p>

<p><em>Thank you for using nginx.</em></p>

If you have any questions, please leave a message or go to this site community exchange discussion, thank you for reading, hope to help you, thank you for your support to this site!

Related articles: