安装

官网

Debian

mkdir -p ~/.gnupg && chmod 700 ~/.gnupg

Install the prerequisites:

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/debian $(lsb_release -cs) nginx" | tee /etc/apt/sources.list.d/nginx.list

安装

apt update
apt install nginx

安装好后删除list

rm -rf /etc/apt/sources.list.d/nginx.list

配置

启动:

service nginx start

守护:

systemctl enable nginx
systemctl start nginx
systemctl restart nginx
systemctl stop nginx
systemctl disable nginx

配置文件

程序配置文件:/etc/nginx/nginx.conf
默认配置文件:/etc/nginx/conf.d/default.conf
配置文件目录:/etc/nginx/conf.d/

如果要用反代:
/etc/nginx/nginx.conf文件的http字段加入:

map $http_upgrade $connection_upgrade {
default upgrade;
''      close;
}

缓存路径:
'/var/cache/nginx'

log缓存路径
'/var/log/nginx'

更详细配置参考简书

最后修改:2026 年 04 月 15 日 04 : 54 PM