nginx基础--1

概述
Nginx是一款轻量级的HTTP服务器,采用事件驱动的异步非阻塞处理方式框架,这让其具有极好的IO性能,具有处理高并发的能力。时常用于服务端的反向代理和负载均衡。划重点:处理高并发,反向代理,负载均衡。

安装(windows)
download
可以自行选择适合自己电脑的版本(开发版本/稳定版本/历史版本)–推荐稳定版(stable)
傻瓜式安装就行了,完事点一下nginx.exe,浏览器打开127.0.0.1,或者localhost
效果图


显示这个界面,表示安装成功
目录结构

å¨è¿éæå¥å¾çæè¿°
这里conf文件夹是最重要的,里边存放的是nginx的配置文件
html文件夹是静态站点文件,里边可以放一些静态页面
logs文件夹里边存放的是日志文件,还有nginx的pid
temp文件夹下是一些临时文件
docs和contrib可自行查看 ,很少用
conf/nginx.conf

#user  nobody; #运行用户
worker_processes  1; #Nginx进程数
#错误日志存放目录
#error_log  logs/error.log; 
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#指定nginx进程运行文件存放地址
#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;   #nginx访问日志目录

    sendfile        on;  #开启高效传输模式
    #tcp_nopush     on;   #减少网络报文段的数量

    #keepalive_timeout  0;
    keepalive_timeout  65; #超时时间

    #gzip  on; # 开启gzip压缩

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html; # root表示访问的目录
            index  index.html index.htm; # index表示默认首页
        }

        #error_page  404              /404.html; # 404页面处理

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;  # 状态码50x的处理页面
        location = /50x.html {
            root   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;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}


nginx命令
启动 win下,点击nginx.exe ,linux 下可以直接输入nginx
以下为linux下操作,win下任务管理器皆可搞定
重新加载 nginx -s reload (当你更改了配置文件 需要重新加载)
关闭 killall nginx 或者 nginx -s stop 或者 nginx -s quit 凶残程度逐渐降低
查看运行信息 ps -ef | grep nginx
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值