Nginx 是一个高性能的 HTTP 和反向代理服务器,同时也支持 IMAP/POP3/SMTP 等协议。它经常被用于网站服务器、反向代理服务器以及负载均衡器。

安装 Nginx

以下是在 Linux 系统上安装 Nginx 的步骤:

  1. 更新系统包列表:
    sudo apt-get update
    
  2. 安装 Nginx:
    sudo apt-get install nginx
    
  3. 启动 Nginx 服务:
    sudo systemctl start nginx
    
  4. 设置 Nginx 服务开机自启:
    sudo systemctl enable nginx
    

配置 Nginx

Nginx 的配置文件位于 /etc/nginx/nginx.conf。以下是一个简单的配置示例:

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

Nginx 高级功能

Nginx 支持许多高级功能,例如:

  • 负载均衡
  • HTTPS 支持
  • Gzip 压缩
  • 缓存

更多高级功能信息,请访问官方文档

图片示例

Nginx Logo