Nginx 是一个开源 Linux Web 服务器,可在利用低资源的同时加速内容。 以性能和稳定性着称的 Nginx 还有许多其他用途,例如负载均衡、反向代理、邮件代理和 HTTP 缓存。 凭借所有这些品质,它成为了绝对的竞争对手 Apache. 要安装 Nginx,请遵循我们简单的教程。
飞行前检查
- 以 root 身份登录并在由 Liquid Web 提供支持的 Ubuntu 16.04 LTS 服务器上工作! 如果使用不同的用户 admin 特权使用 sudo 在每个命令之前。
第 1 步:更新 Apt-Get
与往常一样,我们更新和升级了我们的包管理器。
apt-get update && apt-get upgrade
第 2 步:安装 Nginx
只需要一个简单的命令来安装 Nginx:
apt-get -y install nginx
第 3 步:验证 Nginx 安装
正确安装后,Nginx 的默认文件将在 /var/www/html 中显示为 index.nginx-debian.html 。 如果你看到 Apache 默认页面重命名 index.html 文件。 很像 Apache,默认情况下,Nginx 的端口是 80 端口,这意味着如果您已经为您的服务器的主机名设置了 A 记录,您可以访问该 IP 来验证 Nginx 的安装。 如果您手头没有服务器的 IP,请运行以下命令以获取服务器的 IP。
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's//.*$//'
取上一条命令给出的 IP,通过 HTTP 访问。 (https://dtnqes.com/images/9/1652490529.png"},{"@type":"Article","@id":"https://dtnqes.com/article/484066#article","url":"https://dtnqes.com/article/484066","headline":"在 Ubuntu 16.04 上安装 Nginx","datePublished":"2022-05-13T17:08:49+00:00","dateModified":"2022-05-13T17:08:56+00:00","wordCount":97,"keywords":["Apache","Debian","Install","Linux","NGINX","Ubuntu"],"articleSection":["article"],"isPartOf":{"@id":"https://dtnqes.com/article/484066#webpage"},"mainEntityOfPage":{"@id":"https://dtnqes.com/article/484066#webpage"},"image":{"@id":"https://dtnqes.com/article/484066#thumbnail"},"publisher":{"@id":"https://dtnqes.com/#organization"},"author":{"@id":"https://dtnqes.com/article/484066#author"}},{"@type":"Person","@id":"https://dtnqes.com/article/484066#author","url":"https://dtnqes.com/author/mzdya/","name":"mzdya","image":{"@id":"https://dtnqes.com/article/484066#author_image"}},{"@type":"ImageObject","@id":"https://dtnqes.com/article/484066#author_image","url":"https://secure.gravatar.com/avatar/aa1d5ea659c6e7cee3be89b7061bdff6?s=96&d=mm&r=g","width":96,"height":96,"caption":"mzdya"}]}