您好,欢迎来到爱站旅游。
搜索
您的当前位置:首页7.Nginx安装部署文档

7.Nginx安装部署文档

来源:爱站旅游
Nginx安装配置文档

本次部署安装Nginx 1.14.0版本windows 64位。利用Nginx来做服务集群反向代理实现负载均衡。

一、环境准备

1. Nginx软件包(nginx-1.14.0.zip) 二、安装配置

三、 修改配置文件

nginx配置文件在 nginx-1.14.0\\conf\\nginx.conf

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice; #error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024; }

http {

include 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 logs/access.log main;

sendfile on; #tcp_nopush on;

#keepalive_timeout 0; keepalive_timeout 65;

#gzip on;

#这里的域名要和下面proxy_pass的一样 upstream smartwindfarm.com { #server 192.168.1.73:8080 weight=1 max_fails=2 fail_timeout=2s; server 192.168.1.73:8080 weight=1 ; server 192.168.1.73:8088 weight=2 ; } server { listen 80; server_name 192.168.1.73; location / { proxy_pass http://smartwindfarm.com; proxy_redirect default; proxy_connect_timeout 2; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }

# another virtual host using mix of IP-, name-, and port-based configuration #

#server {

# listen 8000;

# listen somename:8080;

# server_name somename alias another.alias;

# location / {

# root html;

# index index.html index.htm; # } #}

# HTTPS server #

#server {

# listen 443 ssl; # server_name localhost;

# ssl_certificate cert.pem; # ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on;

# location / {

# root html;

# index index.html index.htm; # } #}

}

三. 启动

注意不要直接双击nginx.exe,这样会导致修改配置后重启、停止nginx无效,需要手动关闭任务管理器内的所有nginx进程

在nginx.exe目录,打开命令行工具,用命令 启动/关闭/重启nginx

start nginx : 启动nginx

nginx -s reload :修改配置后重新加载生效 nginx -s reopen :重新打开日志文件

nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

关闭nginx:

nginx -s stop :快速停止nginx

nginx -s quit :完整有序的停止nginx

如果遇到报错:

bash: nginx: command not found

有可能是你再linux命令行环境下运行了windows命令, 如果你之前是允许 nginx -s reload报错, 试下 ./nginx -s reload 或者 用windows系统自带命令行工具运行

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- azee.cn 版权所有 赣ICP备2024042794号-5

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务