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实战操作(常用命令及配置)的更多相关文章

  1. window下nginx的常用命令

    window nginx 启动 常用命令 2016-05-04 11:11 214人阅读 评论(0) 收藏 举报 分类: nginx(5) 版权声明:本文为博主原创文章,未经博主允许不得转载. 启动 ...

  2. Vim常用命令及配置方案

    Vim常用命令及配置方案   几句话 很久之前就接触到vim,初学那阵觉得vim很酷炫,但确实对新手不是很友好.我也就简单看了下基本操作就上手了,但又不是长期在vim下工作,这就导致了每一次重新使用v ...

  3. WebSphere MQ常用命令及配置

    WebSphere MQ常用命令及配置 (2012-06-23 23:09:16) 标签: mq命令 杂谈 分类: MQ [导读]WebSphere MQ常用命令及配置 一,队列管理命令 1,创建队列 ...

  4. nginx常用命令和配置

    1.常用命令 查看版本号: ./nginx -v   启动nginx:在/usr/local/nginx/sbin 目录下执行  ./nginx   关闭nginx:在/usr/local/nginx ...

  5. linux下安装nginx以及常用命令指南

    安装nginx之前,要先在服务器上安装nginx运行所需要的依赖包 目录选择:一般选择 "/usr/local/" 1.安装PCRE库 离线安装包:https://pan.baid ...

  6. ubuntu和centos 编译安装nginx及常用命令

    转自http://www.cnblogs.com/piscesLoveCc/p/5794926.html 一. ubuntu安装 1. 安装依赖库 安装gcc g++的依赖库 ubuntu平台可以使用 ...

  7. Linux上安装Nginx及常用命令

    一.Linux安装软件常用方法 1.rpm(或pkg)安装,类似于Windows安装程序,是预编译好的程序. 1)使用的是通用参数编译,配置参数不是最佳 2)可控制性不强,比如对程序特定组件的定制性安 ...

  8. nginx的常用命令

    一.nginx的解压安装 #tar xzvf nginx-1.6.0.tar.gz #cd nginx-1.6.0 #./configure    --prefix=/home/weixin/loca ...

  9. linux安装jdk tomcat nginx 以及常用命令

    linux: 操作系统,应用服务器上 常用命令: cd 切换命令 cd / cd ~ cd ../../ cd xx ll 展示所有的文件 ll -h 友好的展示 mkdir 创建目录 mkdir 目 ...

随机推荐

  1. 【Gerrit】持续集成工具Jenkins的安装配置与使用过程中遇到的问题整理

    1.下载war包 https://jenkins.io/download/ 2.安装 java -jar jenkins.war Error: Feb 21, 2019 2:17:25 AM wins ...

  2. 伪类&伪元素

    刚开始学习伪类和伪元素的时候,觉得好混乱呀,分不清有什么区别,用的时候也没注意对比.现在总结一下他们的区别吧. w3c中对它们的定义分别为: css伪类用于向某些选择器添加特殊的效果. css伪元素用 ...

  3. CentOS 7 配置163源

    具体的操作步骤: 1.打开终端,输入su指令切换到root用户:su 2.切换到系统yum源的目录下,即:cd /etc/yum.repos.d 3.备份系统默认yum源(也可直接删除):mv Cen ...

  4. shell转义符

    转义是一种引用单个字符的方法. 一个前面放上转义符 (\)的字符就是告诉shell这个字符按照字面的意思进行解释, 换句话说, 就是这个字符失去了它的特殊含义. 在某些特定的命令和工具中, 比如ech ...

  5. [机器学习]Generalized Linear Model

    最近一直在回顾linear regression model和logistic regression model,但对其中的一些问题都很疑惑不解,知道我看到广义线性模型即Generalized Lin ...

  6. VS使用的快捷方式

    VS常用快捷键 1.回到上一个光标位置/前进到下一个光标位置 1)回到上一个光标位置:使用组合键“Ctrl + -”: 2)前进到下一个光标位置:“Ctrl + Shift + - ”. 2.复制/剪 ...

  7. pycharm窗口选项卡管理

    1.主题 我们已经注意到Pycharm的主编辑框是基于窗口选项卡机制显示的,Pycharm选项卡多种多样,这里我们将详细介绍这种选项卡机制.  2.激活的选项卡 每当我们打开一个Python文件时op ...

  8. 再说Java集合,subList之于ArrayList

    上一章说了很多ArrayList相关的内容,但还有一块儿内容没说到,那就是subList方法.先看一段代码 public static void testSubList() { List<Str ...

  9. SpringBoot从入门到精通二(SpringBoot整合myBatis的两种方式)

    前言 通过上一章的学习,我们已经对SpringBoot有简单的入门,接下来我们深入学习一下SpringBoot,我们知道任何一个网站的数据大多数都是动态的,也就是说数据是从数据库提取出来的,而非静态数 ...

  10. 小程序请求接口统一封装到一个js文件中

    在我们做小程序时,数据请求数据请求是避免不了的,然而我们用官方自带的请求方式,会给我们带来很多重复的工作,所以我就借鉴大神们的博客,写了一个简单的请求方式. 1.首先我们在utils中新建一个api. ...