#2~nginx

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;
        }
......

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值