当前位置:首页 > nginx > 正文

nginx怎么安装配置(nginx配置详解超详细)

  • nginx
  • 2024-03-31 14:35:14
  • 3944
Nginx 安装
下载 Nginx 二进制包:

wget http://nginx.org/download/nginx-.tar.gz

解压二进制包:

tar -zxvf nginx-.tar.gz

编译和安装 Nginx:

cd nginx-
./configure
make
make install

Nginx 配置
在 /etc/nginx/nginx.conf 配置文件中设置主要配置:
监听端口:

listen 80;

根目录:

root /var/www/html;

索引文件:

index index.html index.htm;

错误页面:

error_page 404 /404.html;

日志记录:

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

其他要素:
虚拟主机配置
SSL 证书配置
缓存配置
限流配置