环境准备:
1.关闭firewalld
2.关闭selinux
一.安装nginx
yum -y install epel-release
yum -y install nginx
二.配置nginx主配置文件
cd /etc/nginx
mv nginx.conf nginx.conf.bak
vi /etc/nginx/nginx.conf
user nginx;
worker_processes 6;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
worker_rlimit_nofile 10240;
include /usr/share/nginx/modules/*.conf;
events {
use epoll;
worker_connections 5000;
}
http {
log_format main '$remote_addr -
r
e
m
o
t
e
u
s
e
r
[
remote_user [
remoteuser[time_local] “KaTeX parse error: Double superscript at position 34: … '̲status
b
o
d
y
b
y
t
e
s
s
e
n
t
"
body_bytes_sent "
bodybytessent"http_referer” ’
‘“
h
t
t
p
u
s
e
r
a
g
e
n
t
"
"
http_user_agent" "
httpuseragent""http_x_forwarded_for”’;
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
三.配置nginx虚拟主机
vi /etc/nginx/conf.d/edoc2.conf
upstream edoc2 {
ip_hash;
server 1.1.1.1:80 weight=1 max_fails=1 fail_timeout=20;
server 1.1.1.2:80 weight=1 max_fails=1 fail_timeout=20;
server 1.1.1.3:80 weight=1 max_fails=1 fail_timeout=20;
}
server {
listen 80;
server_name doc2.wf.com ; ##填写域名
location / {
proxy_pass http://edoc2;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
client_max_body_size 0;
proxy_http_version 1.1;
proxy_request_buffering off;
#proxy_buffering off;
}
}
四. 修改服务器打开的最大文件句柄数
echo ‘* - nofile 65535’ >> /etc/security/limits.conf
五.启动nginx
systemctl start nginx
systemctl enable nginx