一、环境介绍
系统rhel7.1
node-6 ——192.168.3.13/24
二、查看tenginx的版本
[root@node-6 ~]
Tengine version: Tengine/2.3.3
nginx version: nginx/1.18.0
三、查看默认的配置文件内容
[root@node-6 ~]
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
四、tenginx的启停相关操作
1.tenginx的启动
[root@node-6 ~]
[root@node-6 ~]
root 28931 1 0 12:21 ? 00:00:00 nginx: master process nginx
nginx 28932 28931 0 12:21 ? 00:00:00 nginx: worker process
root 28980 27498 0 12:21 pts/1 00:00:00 grep --color=auto nginx
2.tenginx的停止
nginx -s stop
3.tenginx的重载配置文件
nginx -s reload
4.tenginx的配置文件检查
nginx -t
nginx默认配置文件路径:/data/server/nginx/conf/nginx.conf
五、tenginx的默认相关文件路径
/usr/local/nginx/conf/
/usr/local/nginx/conf/nginx.conf
/usr/local/nginx/logs
/usr/local/nginx/html
/usr/local/nginx/sbin/nginx
六、tenginx的负载均衡配置
[root@node-6 conf]
user nginx nginx;
error_log /data/server/nginx/logs/error.log;
worker_processes 2;
worker_cpu_affinity auto;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
client_header_buffer_size 32k;
server_tokens off;
server_info off;
autoindex on;
access_log /data/server/nginx/logs/access.log;
upstream mall-admin-web {
server 192.168.3.11 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.3.12 weight=1 max_fails=2 fail_timeout=30s;
}
server {
listen 80;
server_name 1ocalhost;
charset utf-8;
location / {
root /data/server/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8080;
server_name 1ocalhost;
charset utf-8;
location / {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://mall-admin-web;
expires 3d;
}
}
}
七、测试网站