一、nginx帮助参数

下面是关于/application/nginx/sbin/nginx 的参数帮助
[root@A conf]# /application/nginx/sbin/nginx -h
nginx version: nginx/1.6.
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives] Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /application/nginx-1.6./)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

重启要学脚本,检查api端口,如果没问题就重启,如果有问题恢复到原来的模式

二、利用include功能优化nginx的配置文件

由于nginx主配置文件工作的时候会有很多虚拟主机维护不方便,因此会做出下面的
、先创建一个目录 mkdir /application/nginx/conf//extra
、之后备份 cp nginx.conf nginx.conf.pyrene 、增加include
[root@oldboy conf]# cat nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
include extra/www.conf;
include extra/bbs.conf;
}
、配置server标签
[root@oldboy conf]# cp nginx.conf.pyrene extra/a
[root@oldboy conf]# cd extra/
[root@oldboy extra]# ls
a
[root@oldboy extra]# sed -n "10,17p" a>www.conf
[root@oldboy extra]# sed -n "18,25p" a>bbs.conf
、重启

三、nginx细腻主机别名配置

 、    虚拟主机别名介绍及配置
所谓虚拟主机别名,就是为虚拟主机设置出了主域名意外的一个域名
方法:直接在配置文件中域名哪里直接添加一个新的域名,然后域名和域名之间要用空格隔开
如:
、[root@oldboy extra]# vim www.conf server {
listen ;
server_name www.cnblogs.co pyrene; --》添加别名 别名之间空格就可以
location / {
root html/www;
index index.html index.htm;
}
}
、[root@oldboy extra]# vim bbs.conf server {
listen ;
server_name bbs.cnblogs.co cnblog.co; --》添加别名
location / {
root html/bbs;
index index.html index.htm;
}
} 、把域名写道/etc/hosts解析 [root@A conf]# vim /etc/hosts [root@oldboy extra]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.8 www.cnblogs.co bbs.cnblogs.co cnblog.co pyrene 、然后检查语法,重启关闭防火墙,curl 查看就可以
[root@oldboy extra]# curl -I pyrene
HTTP/1.1 OK
Server: nginx/1.8.
Date: Sat, Mar :: GMT
Content-Type: text/html
Content-Length:
Last-Modified: Fri, Mar :: GMT
Connection: keep-alive
ETag: "58b9bb78-18"
Accept-Ranges: bytes
别名除了可以方便搜索之外,监控服务器里面监控别名,可以很好的判断每一台机器是否正常

四、Nginx状态信息配置

 编译的时候制定了一个状态模块  —with-http_stub_status_module 显示nginx当先的状态
配置如下: 、选择虚拟主机的方式增加了一个server标签到/application/nginx/conf/extra/status.conf里面,起名status.etiantian.org
cat >>/application/nginx/conf/extra/status.conf<<EOF
##status
server{
listen ;
server_name status.cnblogs.co;
location / {
stub_status on;
access_log off;
}
}
EOF server_name status. status.cnblog.co; →这里添加的域名 标签 、需要包含,include
[root@A conf]# vim nginx.conf worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
#nginx vhosts config
include extra/www.conf;
include extra/bbs.conf;
include extra/blog.conf;
include extra/status.conf; →这里的包含
}
、在/etc/hosts里面解析
[root@A conf]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.8 www.cnblogs.co bbs.cnblogs.co cnblog.co pyrene. status.cnblog.co →这里就是解析
、在window中解析配置 并且重启nginx

5、查看

浏览器中出现

[root@A conf]# curl status.cnblog.co

Active connections: 1                         →查看连接数

server accepts handled requests

16 16 16

Reading: 0 Writing: 1 Waiting: 0

上面的详细讲解

Active connections:2872

#<==表示Nginx 正处理的活动连接数 2872个

nginx别名配置,状态配置,include优化的更多相关文章

  1. Nginx 高级配置-状态页配置

    Nginx 高级配置-状态页配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 建议将nginx的监控状态的值通过zabbix或者Open-Falcon之类的监控工具来监控状态,并 ...

  2. nginx反向代理的配置优化

    作者:守住每一天 blog:liuyu.blog.51cto.combbs:bbs.linuxtone.orgmsn:liuyubj520#hotmail.comemail:liuyu105#gmai ...

  3. [效果不错] nginx 高并发参数配置及linux内核参数优化,完整的内核优化设置。PHP-FPM高负载解决办法。

    背景:对vps小资源的实践中对,https://justwinit.cn/post/7536/ 的再优化,再实践,再优化,特别是Nginx,PHP,内核: 零)Nginx: error_log /da ...

  4. 通过浏览器查看nginx服务器状态配置方法

    通过浏览器查看nginx服务器状态配置方法 投稿:junjie 字体:[增加 减小] 类型:转载 这篇文章主要介绍了通过浏览器查看nginx服务器状态配置方法,本文讲解开启nginx-status的配 ...

  5. Nginx之常用基本配置

    上一篇博客我们大概介绍了一下nginx,nginx的架构,nginx编译安装和nginx命令的用法,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/1236680 ...

  6. Nginx入门--从核心配置与动静分离开始

    写在前面 优化我们项目,服务器部署,不仅仅可以是分布式,Nginx一样可以通过动静分离,负载均衡来减轻我们服务器的压力.Nginx的知识链,学习周期相对比较长,博主也是刚刚入门,这篇就先从实现基础的动 ...

  7. nginx、php-fpm默认配置与性能–TCP socket还是unix domain socket【转】

    原文地址:https://www.cnxct.com/default-configuration-and-performance-of-nginx-phpfpm-and-tcp-socket-or-u ...

  8. nginx安装升级及配置详解

    1.简介 2.安装配置 3.配置文件介绍 4.启动.停止.平滑重启.升级 一.Nginx简介 Nginx(engine x)是俄罗斯人Igor Sysoev编写的一款高性能的http和反向代理服务器. ...

  9. nginx 之 https 证书配置

    HTTPS原理和作用 为什么需要HTTPS 原因:HTTP不安全 传输数据被中间人盗用.信息泄露 数据内容劫持.篡改 HTTPS协议的实现 对传输内容进行加密以及身份验证 对称加密:加密秘钥和解密秘钥 ...

随机推荐

  1. Asp.Mvc将生成的视图保存为字符串

    public static class ViewExtensions { /// <summary> /// 在控制器内获取指定视图生成后的HTML /// </summary> ...

  2. mysql用merge合并表

    merge合并表的要求 1.合并的表使用的必须是MyISAM引擎 2.表的结构必须一致,包括索引.字段类型.引擎和字符集 实例: create table if not exists user1( i ...

  3. Atitit.swift 的新特性 以及与java的对比 改进方向attilax 总结

    Atitit.swift 的新特性 以及与java的对比 改进方向attilax 总结 1. defer关键字1 2. try!形式存在的“不失败”机制3 3. Guard 4 4. swift的新语 ...

  4. lua 中处理cocos2dx 的button 事件

    lua 中处理cocos2dx 的button 事件 2014-05-08 09:44:32|  分类: lua |举报 |字号 订阅   1.引入这个类:require "GuiConst ...

  5. iOS SDWebImage Error Domain=NSURLErrorDomain Code=-1202 “此服务器的证书无效

    sdwebImage 加载网络图片的时候,如果使用的https证书未经过认证,或者证书有问题,会出现Error Domain=NSURLErrorDomain Code=-1202 "此服务 ...

  6. Spring Boot内嵌Tomcat session超时问题

    最近让Spring Boot内嵌Tomcat的session超时问题给坑了一把. 在应用中需要设置session超时时间,然后就习惯的在application.properties配置文件中设置如下, ...

  7. printf()与 scanf()

    一直以来就没有认真看过控制台输入输出的格式,现今找了一些材料,分享如下: 1. 格式化规定符     Turbo C2.0提供的格式化规定符如下: ━━━━━━━━━━━━━━━━━━━━━━━━━━ ...

  8. 44.Android MD5Util

    44.Android MD5Util public class MD5Util { public static String getMD5String(String key) { char hexDi ...

  9. Java多线程之~~~~synchronized 方法

    在多线程开发中,总会遇到多个在不同线程中的方法操作同一个数据,这样在不同线程中操作这个数据不同的顺序 或者时机会导致各种不同的现象发生,以至于不能实现你预期的效果,不能实现一致性,这时候就能够使用 s ...

  10. 地形混合shader

    1.四个贴图混合 Shader "Custom/BlendTex_surface" { Properties { _RTexture("Red Channel Textu ...