nginx可以做什么
nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。简单来说,就是一个web服务器,可以提供http服务,一般用来充当代理、反向代理工具来使用。官方网站https://nginx.org/
Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。
nginx启动
- 配置环境变量
在window下,新建环境变量NGINX_HOME,在PATH环境变量后追加%NGINX_HOME%。
在cmd窗口下,nginx -v命令查看nginx版本,说明安装和配置都没有问题。
- nginx -s signal进程命令
signal可包含:stop
— 强制关闭、quit
— 优雅退出、reload
— 重启、reopen
— 重新打开日志四个值。这里实际没有看到nginx启动命令,实际只需转到nginx的安装目录下,直接nginx启动:nginx -p 安装目录 -c 配置文件,例如nginx -p ./test -c ./conf/nginx.conf;
- 查询nginx启动任务
tasklist /fi "imagename eq nginx.exe"
-
kill nginx进程
nginx配置
在安装目录下conf存在两个配置相关的默认文件:nginx.conf、nginx.conf.default。里面包含很多配置项,其中大部分使用” # “进行了注释(nginx只能单行注释,并没有块注释符),本文暂时先贴出默认配置项,后续文章将逐一进行说明,如下所示:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
......