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 port443
(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