---
title: Nginx Web Server场景
description: "Nginx Web Server场景是以Nginx作为Web Server的场景。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengwebs/twp/kunpengwebs_19_0010.html
sourcePath: /source/zh/kunpengwebs/twp/kunpengwebs_19_0010.html
indexId: 60983b5d9f8fa32ad3fd46031fe405484e2401f5db0469dfec43dafe8e6fefc251
---
# Nginx Web Server场景

Nginx Web Server场景是以Nginx作为Web Server的场景。

Nginx作为Web Server，可以被配置部署为静态资源Web Server，在该配置下可以高效的进行静态资源的请求处理，从而实现动静的分离，其中非服务器动态运行生成的文件都属于静态资源，包括并不限于以下种类。

| 类型 | 种类 |
| --- | --- |
| 浏览器端渲染 | HTML、CSS、JS |
| 图片 | JPEG、GIF、PNG |
| 音视频 | FLV、MP4、MP3 |
| 文件 | TXT、任意下载文件 |


配置时，可以通过server块定义虚拟服务器，通过root伪指令指定将用于搜索文件的根目录，通过location定义匹配块。通过index指令定义索引文件名称（默认值为index.html），如下面示例所示：

```
server{
listen 80;
server_name localhost;
location/{
root /home/www/html;
index index.html index.htm;
}
location
~
.*\.(gif|jpg|jpeg|png)${
root /home/www/images/;
}
location
~
\.(mp3/mp4){
root /home/www/media;
}
}
```

示例中参数说明如表1所示。


**表1 Nginx作为Web Server的配置参数说明**

| 参数 | 说明 |
| --- | --- |
| listen 80; | 端口号 |
| server\_name localhost; | 本机 |
| root /home/www/html; | html访问路径 |
| index index.html index.htm; | html文件名称 |


Nginx作为Web Server，其由于在高并发场景下Web请求处理性能优异而被广泛使用。鲲鹏服务器支持Nginx Web Server的物理机和虚拟机方式部署，利用华为鲲鹏处理器的多核优势，可以进一步提升高并发场景下的处理性能，在HTTP/HTTPS的短连接和长连接场景下均有较大的性能优势。
