Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS7 yum installs the latest version of Nginx

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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

}

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report