Windows下Nginx基本操作概述
在Windows环境下运行Nginx,管理员需熟悉一系列基础运维指令,涵盖服务的启动、终止、配置重载等核心环节。以下将对这些关键操作进行简要说明。
1、启动服务:
C:\server\nginx-1.0.2>start nginx
或者执行
C:\server\nginx-1.0.2>nginx.exe
注意:推荐采用第一种方式。第二种方式会导致当前CMD窗口持续占用并处于执行状态,从而阻塞其他命令的输入。
2、停止服务:
C:\server\nginx-1.0.2>nginx.exe -s stop
或者执行
C:\server\nginx-1.0.2>nginx.exe -s quit
注:stop参数用于快速终止Nginx进程,此过程可能不会保存相关状态信息;quit参数则用于完整且有序地关闭Nginx,确保相关信息得到妥善保存。
3、重新载入Nginx配置:
C:\server\nginx-1.0.2>nginx.exe -s reload
当修改了Nginx的配置信息后,若需使新配置生效,应使用此命令进行重载。
4、重新打开日志文件:
C:\server\nginx-1.0.2>nginx.exe -s reopen
5、查看Nginx版本信息:
C:\server\nginx-1.0.2>nginx -v
nginx: nginx version: nginx/1.0.2
或者执行
C:\server\nginx-1.0.2>nginx -V
nginx: nginx version: nginx/1.0.2
nginx: TLS SNI support enabled
nginx: configure arguments: --builddir=objs.msvc8 --crossbuild=win32 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-7.9 --with-zlib=objs.msvc8/lib/zlib-1.2.3 --with-select_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-mail --with-ipv6 --with-openssl=objs.msvc8/lib/openssl-0.9.8r --with-openssl-opt=enable-tlsext --with-http_ssl_module --with-mail_ssl_module
注:小写v仅显示基本的版本信息;大写V不仅显示版本号,还会输出详细的编译配置参数信息。
6、测试或载入指定配置文件:
用于测试配置文件语法是否正确
C:\server\nginx-1.0.2>nginx.exe -t -c conf/default.conf
nginx: the configuration file C:\server\nginx-1.0.2/conf/default.conf syntax isok
nginx: configuration file C:\server\nginx-1.0.2/conf/default.conf test is successful
用于载入指定的配置文件
C:\server\nginx-1.0.2>start nginx.exe -c conf/default.conf
上述介绍的命令均为Nginx最基础的操作指令,易于记忆。通过多次实践尝试,即可熟练掌握。