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. 查看 Linux 发行版本的名称以及版本号

    查看LINUX发行版的名称及其版本号的命令: lsb_release -a cat /etc/redhat-release(针对redhat,Fedora)

  2. ubuntu Linux 操作系统安装与配置

    Ubuntu是一个以桌面应用为主的Linux操作系统.Ubuntu每六个月发布一个新版本(一般是4和10月份,命名为YY.MM),每一个普通版本都将被支持 18个月,长期支持版(Long Term S ...

  3. .NET DataTable转换为JSON格式的字符串

    在进行数据传递的时候,有时我们需要通过Ajax的方式或者其他的方式传递一个数据列表,可以将DataTable或者其他形式的数据列表转换为JSON的格式,通过Ajax实体的形式进行传递. 比如说: // ...

  4. JavaScript 数据实用程序库:Datalib

    Datalib 是一个 JavaScript 数据实用程序库. 快速使用Romanysoft LAB的技术实现 HTML 开发Mac OS App,并销售到苹果应用商店中.   <HTML开发M ...

  5. Wiki上的C++哲学

    Philosophy[edit] Throughout C++'s life, its development and evolution has been informally governed b ...

  6. python机器学习系列之环境搭建

    Windows系统下python2.7,numpy,matplotlib安装 1.  python2.7从https://www.python.org/downloads/release/python ...

  7. 使用 docker 搭建 nginx+php-fpm 环境 (两个独立镜像)

    :first-child{margin-top:0!important}.markdown-body>:last-child{margin-bottom:0!important}.markdow ...

  8. jvm(4)---垃圾回收(哪些对象可以被回收)

    1.java堆中几乎放着所有对象的实例,那么什么样子的对象才是可以被回收的呢? 1.1.引用计数法: 给对象添加一个引用计数器,当有地方引用的时候,计数器就+1,引用失效就-1:任何时候当计数器为0, ...

  9. ios开发系列之内存泄漏分析(上)

    ios自从引入ARC机制后,一般的内存管理就可以不用我们码农来负责了,但是一些操作如果不注意,还是会引起内存泄漏. 本文主要介绍一下内存泄漏的原理.常规的检测方法以及出现的常用场景和修改方法. 1.  ...

  10. jmeter安装与部署

    1.JDK组件安装 jmeter是一款java开发的测试软件,需要JDK运行环境支持,因此在安装jmeter前需要安装调试好jdk运行环境.jmeter3.2需要1.8以上版本jdk才可以正常运行.首 ...