nginx实战操作(常用命令及配置)
1. nginx介绍

2. nginx常用命令
验证配置是否正确: nginx -t
查看Nginx的详细的版本号:nginx -V
查看Nginx的简洁版本号:nginx -v
启动Nginx:start nginx
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit
配置文件修改重装载命令:nginx -s reload
3. nginx配置
3.1 配置代码
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#1 start
upstream linuxidc {
server localhost:7071;
server localhost:7072;
server localhost:7073;
}
server {
listen 7070;
server_name localhost;
location / {
# root C:/ngtest2;
# index index.html index.htm;
proxy_pass http://linuxidc;
}
}
# 1 end
#2 start
server {
listen 7071;
server_name localhost;
location / {
root C:/ngtest1;
# index index.html index.htm;
#proxy_pass https://tms;
#proxy_pass https://www.baidu.com/;
}
}
server {
listen 7072;
server_name localhost;
location / {
root C:/ngtest2;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
server {
listen 7073;
server_name localhost;
location / {
root C:/ngtest3;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
# 2 end
#3 start
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root C:\ngtest;
#index index.html index.htm;
#proxy_pass https://www.baidu.com/;
# }
location /baidu {
#root html;
#index index.html index.htm;
proxy_pass https://www.baidu.com/;
}
location /csdn {
#root html;
#index index.html index.htm;
proxy_pass https://www.csdn.net/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 3 end
}
}
3.2 代码说明及效果图
3.2.1 不同端口代理不同应用
#2 start
server {
listen 7071;
server_name localhost;
location / {
root C:/ngtest1;
# index index.html index.htm;
#proxy_pass https://tms;
#proxy_pass https://www.baidu.com/;
}
}
server {
listen 7072;
server_name localhost;
location / {
root C:/ngtest2;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
server {
listen 7073;
server_name localhost;
location / {
root C:/ngtest3;
# index index.html index.htm;
#proxy_pass https://tms;
}
}
# 2 end
3.2.2 效果图



3.2.3 同一端口号代理不同应用
#3 start
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root C:\ngtest;
#index index.html index.htm;
#proxy_pass https://www.baidu.com/;
# }
location /baidu {
#root html;
#index index.html index.htm;
proxy_pass https://www.baidu.com/;
}
location /csdn {
#root html;
#index index.html index.htm;
proxy_pass https://www.csdn.net/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 3 end
3.2.4 效果图


3.2.5 负载均衡
默认采用的轮询方式
#1 start
upstream linuxidc {
server localhost:7071;
server localhost:7072;
server localhost:7073;
}
server {
listen 7070;
server_name localhost;
location / {
# root C:/ngtest2;
# index index.html index.htm;
proxy_pass http://linuxidc;
}
}
# 1 end
3.2.6 效果图



nginx实战操作(常用命令及配置)的更多相关文章
- window下nginx的常用命令
window nginx 启动 常用命令 2016-05-04 11:11 214人阅读 评论(0) 收藏 举报 分类: nginx(5) 版权声明:本文为博主原创文章,未经博主允许不得转载. 启动 ...
- Vim常用命令及配置方案
Vim常用命令及配置方案 几句话 很久之前就接触到vim,初学那阵觉得vim很酷炫,但确实对新手不是很友好.我也就简单看了下基本操作就上手了,但又不是长期在vim下工作,这就导致了每一次重新使用v ...
- WebSphere MQ常用命令及配置
WebSphere MQ常用命令及配置 (2012-06-23 23:09:16) 标签: mq命令 杂谈 分类: MQ [导读]WebSphere MQ常用命令及配置 一,队列管理命令 1,创建队列 ...
- nginx常用命令和配置
1.常用命令 查看版本号: ./nginx -v 启动nginx:在/usr/local/nginx/sbin 目录下执行 ./nginx 关闭nginx:在/usr/local/nginx ...
- linux下安装nginx以及常用命令指南
安装nginx之前,要先在服务器上安装nginx运行所需要的依赖包 目录选择:一般选择 "/usr/local/" 1.安装PCRE库 离线安装包:https://pan.baid ...
- ubuntu和centos 编译安装nginx及常用命令
转自http://www.cnblogs.com/piscesLoveCc/p/5794926.html 一. ubuntu安装 1. 安装依赖库 安装gcc g++的依赖库 ubuntu平台可以使用 ...
- Linux上安装Nginx及常用命令
一.Linux安装软件常用方法 1.rpm(或pkg)安装,类似于Windows安装程序,是预编译好的程序. 1)使用的是通用参数编译,配置参数不是最佳 2)可控制性不强,比如对程序特定组件的定制性安 ...
- nginx的常用命令
一.nginx的解压安装 #tar xzvf nginx-1.6.0.tar.gz #cd nginx-1.6.0 #./configure --prefix=/home/weixin/loca ...
- linux安装jdk tomcat nginx 以及常用命令
linux: 操作系统,应用服务器上 常用命令: cd 切换命令 cd / cd ~ cd ../../ cd xx ll 展示所有的文件 ll -h 友好的展示 mkdir 创建目录 mkdir 目 ...
随机推荐
- Mono.Cecil - 0.6
原文:Mono.Cecil - 0.6 项目地址:Mono.Cecil 项目描述:In simple English, with Cecil, you can load existing manage ...
- C#连接oracle 数据库查询时输入中文查询不出来,用plsql就可以
查询语句为:select * from Per where khmc like '%李%',其实是字符集的问题. 解决方案:在连接字符串加一个“Unicode=True;”
- 微信小程序实战之百思不得姐精简版
原文:微信小程序实战之百思不得姐精简版 微信小程序基本组件和API已撸完,总归要回到正题的,花了大半天时间做了个精简版的百思不得姐,包括段子,图片,音频,视频,四个模块.这篇就带着大家简述下这个小的A ...
- oracle 12c连接pdb
12c中,如何连接pluggable database: 使用默认的service连接pdb,创建pdb之后,在监听中自动添加以pdb为名的service: 用户在cluster中创建service, ...
- ps 专题
ps p 22763 -L -o pcpu,pid,tid,time,tname,cmd,pmem,rss --sort rss 按rss排序 ps p 26653 -L -o pcpu,tid ...
- Web 高效开发必备的 PHP 框架
摘要: 每周为您推送最有价值的开源技术内参! 码云项目推荐 1.项目名称:多功能 THinkPHP 开源框架 项目简介:使用 THinkPHP 开发项目的过程中把一些常用的功能或者第三方 sdk 整合 ...
- HTML 关于colgroup的研究
<colgroup width="20%"></colgroup> <colgroup width="10%"></c ...
- SYN591-A型 计数器
SYN591-A型 计数器 秒表计数器累计计数器电机测速表使用说明视频链接: http://www.syn029.com/h-pd-248-0_310_44_-1.html 请将此链接复制到浏览 ...
- 反向代理在APP通过无线路由接入3G/4G时的特殊作用
由于某些需求,要临时搭建局域网络,给小范围内大量移动客户端提供特定的网络服务,这样的服务通常包含常见的HTTP服务.数据文件下载服务.RESTFul接口服务等.市面常见的非企业级WIFI路由器能够承受 ...
- 在centos7上安装Docker CE
Docker CE的基本安装 https://docs.docker.com/engine/installation/linux/docker-ce/centos/ 一.系统要求 1.安装Docker ...