46.2. Nginx 命令

root@netkiller ~ % nginx -h
nginx version: nginx/1.12.1
Usage: nginx [-?hvVtTq] [-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
  -T            : test configuration, dump it 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: /etc/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

46.2.1. -V show version and configure options then exit

[root@netkiller tmp]# nginx -v
nginx version: nginx/1.10.1

[root@netkiller tmp]# nginx -V
nginx version: nginx/1.10.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

46.2.2. -t : test configuration and exit

CentOS 6

$ sudo service nginx configtest
Testing nginx configuration: nginx.
			

通用方法

root@netkiller ~ % nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
			

46.2.3. test configuration, dump it and exit

root@netkiller ~ % nginx -T
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:

user  nginx;
worker_processes  auto;
worker_rlimit_nofile 65530;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  4096;
}

http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    server_tokens off;
    gzip  on;
    gzip_types text/plain text/css application/json application/x-javascript application/xml;

    include /etc/nginx/conf.d/*.conf;
}

# configuration file /etc/nginx/mime.types:

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/javascript                js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg svgz;
    image/webp                            webp;

    application/font-woff                 woff;
    application/java-archive              jar war ear;
    application/json                      json;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.apple.mpegurl         m3u8;
    application/vnd.ms-excel              xls;
    application/vnd.ms-fontobject         eot;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.google-earth.kml+xml  kml;
    application/vnd.google-earth.kmz      kmz;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/xhtml+xml                 xhtml;
    application/xspf+xml                  xspf;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
    application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/ogg                             ogg;
    audio/x-m4a                           m4a;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mp2t                            ts;
    video/mp4                             mp4;
    video/mpeg                            mpeg mpg;
    video/quicktime                       mov;
    video/webm                            webm;
    video/x-flv                           flv;
    video/x-m4v                           m4v;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}

# configuration file /etc/nginx/conf.d/default.conf:
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

时间: 2024-09-20 19:23:38

46.2. Nginx 命令的相关文章

46.3. nginx 配置文件

worker_processes = CPU 数量 user www; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; 46.3.1. http 配置 自定义缓冲区相关设置 client_body_buffer_size 1K; client_header_buffer_size 1k; client_max_body_size 1k; large_client_header

第 46 章 Nginx

46.1. Installing 46.1.1. Netkiller OSCM 一键安装 (CentOS 7) # curl -s https://raw.githubusercontent.com/oscm/shell/master/web/nginx/stable/nginx.sh | bash 46.1.2. Installing by apt-get under the debain/ubuntu $ sudo apt-get install nginx sudo /etc/init.d

SRVCTL 命令详细说明文档(原译)

SRVCTL 命令详细说明文档(译)  简介: SRVCTL是ORACLE9i RAC集群配置管理的工具.本文是对SRVCTL的所有命令进行详细说明的一篇参考文档. 读者对象:ORACLE9i RAC数据库集群管理员. 注: RAC:     Real Application Clusters SRVM:   Server Management ----------------------------------------------------------------------------

Nginx在Linux下的启动、停止和重加载

Nginx的启动 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 其中-c参数指定配置文件路径. Nginx的停止 Nginx支持以下几种信号控制: - TERM, INT 快速关闭 - QUIT 从容关闭 - HUP 平滑重启 - USR1 重新打开日志文件,在切割文件时用处大 - USR2 平滑升级 - WINCH 从容关闭工作进程 我们可以通 过信号停止Nginx主进程,首先,我们需要通过ps -ef|grep

Linux系统RPM命令参数使用详解

在Linux操作系统中,有一个系统软件包,它的功能类似于Windows里面的"添加/删除程序",但是功能又比"添加/删除程序"强很多,它就是Red Hat Package Manager(简称RPM).此工具包最先是由Red Hat公司推出的,后来被其他Linux开发商所借用.由于它为Linux使用者省去了很多时间,所以被广泛应用于在Linux下安装.删除软件.下面就给大家介绍一下它的具体使用方法. [root@ford /root] # rpm -qa | mor

Linux 中RPM命令参数使用详解

  此工具包最先是由Red Hat公司推出的,后来被其他Linux开发商所借用.由于它为Linux使用者省去了很多时间,所以被广泛应用于在Linux下安装.删除软件.下面就给大家介绍一下它的具体使用方法. 1.我们得到一个新软件,在安装之前,一般都要先查看一下这个软件包里有什么内容,假设这个文件是:Linux-1.4-6.i368.rpm,我们可以用这条命令查看: rpm -qpi Linux-1.4-6.i368.rpm 系统将会列出这个软件包的详细资料,包括含有多少个文件.各文件名称.文件大

汇总:Linux文件管理的50个命令

1.Linux cat命令 cat 命令用于连接文件并打印到标准输出设备上. 2.Linux chattr命令 Linux chattr命令用于改变文件属性. 3.Linux chgrp命令 Linux chgrp命令用于变更文件或目录的所属群组. 在UNIX系统家族里,文件或目录权限的掌控以拥有者及所属群组来管理.您可以使用chgrp指令去变更文件与目录的所属群组,设置方式采用群组名称或群组识别码皆可. 4.Linux chmod命令 Linux/Unix 的文件调用权限分为三级 : 文件拥有

Mac上搭建直播服务器Nginx+rtmp

简介 nginx是非常优秀的开源服务器,用它来做hls或者rtmp流媒体服务器是非常不错的选择,本人在网上整理了安装流程,分享给大家并且作备忘. 步骤安装 1.安装Homebrow Homebrew简称brew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件,可以说Homebrew就是mac下的apt-get.yum神器 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/

Linux+Nginx+Asp.net Core及守护进程部署

这篇文章我将以oss.offical.site站点为例,主要介绍下在linux机器下完整的部署流程,.net core在docker容器中的运行已经介绍,这里.net core运行环境我会介绍直接在linux运行的场景,内容主要包含以下几个部分: 基础工具和Linux环境准备 .Net Core环境安装及端口配置 Nginx的安装配置 Supervisor守护进程安装配置 一. 基础工具和Linux环境准备 工具介绍: Ubuntu:azure云端linux主机 Xshell:免费的linux客