如何在 Debian 11 上安装 Nginx

Nginx 是一个免费的开源网络服务器,提供 HTTP、反向代理、缓存和负载平衡功能。它是 Apache 的绝佳替代品,并且易于设置。

在 Debian 11 Bullseye 上安装 Nginx

步骤 1. 在我们安装任何软件之前,通过apt在终端中运行以下命令来确保您的系统是最新的很重要:

sudo apt update
sudo apt upgrade
sudo apt install curl gnupg2 ca-certificates lsb-release

步骤 2. 在 Debian 11 上安装 Nginx。

现在我们运行以下命令将 Nginx 安装到您的 Debian 系统:

sudo apt install nginx

输出:

root@idroot.us:~# sudo apt install nginxReadingpackage lists...DoneBuilding dependency tree...DoneReading state information...DoneThe following additional packages will be installed:
  geoip-database libgeoip1 libnginx-mod-http-geoip
  libnginx-mod-http-image-filter
  libnginx-mod-http-xslt-filter libnginx-mod-mail
  libnginx-mod-stream libnginx-mod-stream-geoip
  nginx-common nginx-core
  Suggested packages:
  geoip-bin fcgiwrap nginx-doc

安装完成后,启动 Nginx 并将其添加到系统启动时使用以下命令自动启动:

sudo systemctl start nginx
sudo systemctl enable nginx

验证安装:

nginx -v

步骤 3. 配置防火墙。

现在添加防火墙规则以允许连接以及 HTTP(端口 80)和 HTTPS(端口 443)流量:

sudoufw allow 'Nginx HTTP'

步骤 4. 访问 Nginx Web 服务器。

成功安装后,您应该能够通过 Web 浏览器查看测试 Nginx 网页:

http://your-server-ip-address

感谢您使用本教程在 Debian 11 Bullseye 上安装最新版本的 Nginx Web 服务器。如需其他帮助或有用信息,我们建议您查看Nginx 官方网站

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/155212.html<

(0)
运维的头像运维
上一篇2025-03-15 08:17
下一篇 2025-02-02 18:18

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注