cd /usr/local/nginx/sbin
./nginx -v
./nginx
[root@iZ25byfwma3Z usr01]# ps -ef | grep nginx
root 1598 1 0 Sep01 ? 00:00:01 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
root 2171 2157 0 14:16 pts/2 00:00:00 grep nginx
usr01 31875 1598 0 09:35 ? 00:00:19 nginx: worker process
./nginx -s stop
./nginx -s reload
cd /usr/local/nginx/conf/nginx.conf
包含三部分内容
a 全局块:从配置文件开始到 events 块之间的内容,主要会设置一些影响 nginx 服务器整体运行的配置指令
比如
worker_processes 1; # 处理并发数的配置
b events 块:影响 Nginx 服务器与用户的网络连接,这部分配置对 nginx 的性能影响较大,在实际中应该灵活配置。
比如
worker_connections 1024; # 支持的最大连接数为 1024
c http 块:配置最频繁的部分
包含两部分:
# 全局块worker_processes 1;
# events 块
events {
worker_connections 1024;
}
# http 块
http {
# http 全局块
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# server 块
server {
listen 9001;
server_name localhost;
location ~ /pharmacy/ {
proxy_pass http://localhost:8201;
}
location ~ /cmn/ {
proxy_pass http://localhost:8202;
}
location ~ /hospital/ {
proxy_pass http://localhost:8201;
}
location ~ /company/ {
proxy_pass http://localhost:8201;
}
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;
}
}
}
upstream ofe {
server 172.17.10.231 weight=2; # 正式环境
server 172.17.10.235 weight=3; # 正式环境
# server 172.17.10.231:9020; # 测试环境
# server 172.17.10.235:9020; # 测试环境
}
# server 块
server {
listen 80;
server_name mytest.cn;
client_max_body_size 1024M;
sendfile on;
keepalive_timeout 1800;
access_log logs/sfe.access.log;
error_log logs/sfe.error.log;
location / {
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_connect_timeout 400s;
proxy_send_timeout 400s;
proxy_read_timeout 400s;
proxy_buffering off;
proxy_pass http://ofe;
proxy_redirect off;
}
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/chengqiuming/article/details/122092096
内容来源于网络,如有侵权,请联系作者删除!