Get the App
SLTechnology News&Howtos  ›  Servers  › 

CentOS7 yum installs the latest version of Nginx

Shulou Source: shulou.com Published: 2022-06-02 18:27:48 09月22日 Update

Download the nginx package (package) corresponding to the current system version

# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Establish the yum warehouse of nginx

# rpm-ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

Download and install nginx

# yum install nginx

Start the nginx service

Systemctl start nginx

Configuration

The default configuration file is under the / etc/nginx path, and you can use this configuration to run nginx; correctly. If you need customization, you can modify the nginx.conf and other files under it.

test

Enter the IP of the machine where the nginx environment is deployed in the browser address bar, and if everything is all right, you should see the following words.

User nginx

Worker_processes 1

Error_log / var/log/nginx/error.log warn

Pid / var/run/nginx.pid

Events {

Worker_connections 1024

}

Http {

Include / etc/nginx/mime.types

Default_type application/octet-stream

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

# set the list of load balancer servers

Upstream group1 {

# backend server access rules

# ip_hash

# weight parameter indicates the weight value. The higher the weight value, the greater the probability of being assigned.

# PC_Local

Server 192.168.187.133:80 weight=5

# PC_Server

Server 192.168.187.134:80 weight=5

}

Server {

Listen 81; # set external port

Server_name 192.168.187.133; # set the domain name to identify the request

Location / {

# define the default site root location of the server

# root html

# define the name of the index file on the home page

# index index.html index.htm index.php

Proxy_pass http://group1; # offload to group1 cluster

}

}

}

Tags: Service file server configuration version balance warehouse location content probability parameter name address domain name word machine weight root directory browser environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MySQL Shulou Tech Info Huawei MariaDB