美文网首页
Nginx简单配置

Nginx简单配置

作者: 刘昊2018 | 来源:发表于2018-06-30 23:28 被阅读28次

Nginx是一个高性能的HTTP服务器反向代理服务器,通常在实现高并发场景中扮演重要的角色。尤其适合承载静态资源的访问。相关数据显示,Nginx最大能抗住5万并发。

本篇文章,从以下三个方面,记录Nginx的日常使用方法。

  • 静态资源能力
  • 虚拟主机
  • 反向代理,负载均衡

为了方便演示,我们直接在windows上进行操作。在windows上安装Nginx,可参阅相关文档。

起步

安装好之后,我们进入到nginx根目录,输入:

start nginx

之后,我们访问localhost:80,若出现nginx相关信息,则说明nginx正常启动。

配置文件

Nginx的配置文件为/conf/nginx.conf,刨去注释,我们先来简单认识一下:

worker_processes  1;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

静态资源

虚拟主机

反向代理 负载均衡

相关文章

网友评论

      本文标题:Nginx简单配置

      本文链接:https://www.haomeiwen.com/subject/ebvxuftx.html