debian安装nginx_如何在Debian 10上安装Nginx

本指南介绍了如何在Debian 10服务器上安装和配置Nginx,包括安装步骤、防火墙调整、检查Web服务器、管理Nginx进程和设置服务器块。Nginx因其资源效率和灵活性而广泛用于高流量网站。在安装后,需要调整防火墙以允许HTTP流量,并通过访问默认页面验证安装。此外,还展示了如何创建自定义服务器块以托管多个域。
摘要由CSDN通过智能技术生成

debian安装nginx

介绍 (Introduction)

Nginx is one of the most popular web servers in the world and responsible for hosting some of the largest and highest-traffic sites on the internet. It is more resource-friendly than Apache in most cases and can be used as a web server or reverse proxy.

Nginx是世界上最受欢迎的Web服务器之一,负责托管Internet上一些最大和流量最高的站点。 在大多数情况下,它比Apache更对资源友好,并且可以用作Web服务器或反向代理。

In this guide, we’ll discuss how to install Nginx on your Debian 10 server.

在本指南中,我们将讨论如何在Debian 10服务器上安装Nginx。

先决条件 (Prerequisites)

Before you begin this guide, you should have a regular, non-root user with sudo privileges configured on your server and an active firewall. You can learn how to set these up by following our initial server setup guide for Debian 10.

在开始本指南之前,您应该已经在服务器和活动防火墙上配置了具有sudo特权的常规非root用户。 您可以通过遵循我们针对Debian 10的初始服务器设置指南来学习如何进行设置。

When you have an account available, log in as your non-root user to begin.

如果您有可用的帐户,请以非root用户身份登录以开始。

步骤1 –安装Nginx (Step 1 – Installing Nginx)

Because Nginx is available in Debian’s default repositories, it is possible to install it from these repositories using the apt packaging system.

由于Nginx在Debian的默认存储库中可用,因此可以使用apt打包系统从这些存储库中安装Nginx。

Since this is our first interaction with the apt packaging system in this session, let’s first update our local package index so that we have access to the most recent package listings:

由于这是我们在本次会议中与apt打包系统的第一次交互,因此我们首先更新我们的本地包索引,以便可以访问最新的包清单:

  • sudo apt update

    sudo apt更新

We can now install nginx:

现在我们可以安装nginx

  • sudo apt install nginx

    sudo apt安装nginx

When prompted to confirm the installation, hit Enter to proceed. After that, apt will install Nginx and any required dependencies to your server.

当提示您确认安装时,请Enter继续。 之后, apt将为您的服务器安装Nginx和所有必需的依赖项。

步骤2 –调整防火墙 (Step 2 – Adjusting the Firewall)

Before testing Nginx, the firewall software needs to be adjusted to allow access to the service.

在测试Nginx之前,需要调整防火墙软件以允许访问该服务。

List the application configurations that ufw knows how to work with by typing:

键入以下内容,列出ufw知道如何使用的应用程序配置:

  • sudo ufw app list

    sudo ufw应用程序列表

You should get a listing of the application profiles:

您应该获得应用程序配置文件的列表:


   
   
   
Output
Available applications: ... Nginx Full Nginx HTTP Nginx HTTPS ...

As you can see, there are three profiles available for Nginx:

如您所见,Nginx提供了三个配置文件:

  • Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)

    Nginx Full :此配置文件同时打开端口80 (正常,未加密的网络流量)和端口443 (TLS / SSL加密的流量)

  • Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)

    Nginx HTTP :此配置文件仅打开端口80 (正常,未加密的网络流量)

  • Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)

    Nginx HTTPS :此配置文件仅打开端口443 (TLS / SSL加密流量)

It is recommended that you enable the most restrictive profile that will still allow the traffic you’ve configured. Since we haven’t configured SSL for our server yet in this guide, we will only need to allow traffic for

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值