Ubuntu 22.04 – 安装 Nginx

环境

Ubuntu 22.04 LTS
Nginx 1.18.0

Ubuntu 22.04 LTS
Nginx 1.18.0

設置

安装Nginx

$ sudo apt update
$ sudo apt install nginx

防火墙的设置 de

不要忘记防火墙的设置。请先检查ufw所认可的应用程序配置。

$ sudo ufw app list
Available applications:
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  OpenSSH

总之,允许Full。

$ sudo ufw allow 'Nginx Full'
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)

确认Web服务器

只要状态为活动(运行)就可以。

$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-11-29 11:08:00 UTC; 4min 12s ago
       Docs: man:nginx(8)
    Process: 3618 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 3620 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 3738 (nginx)
      Tasks: 2 (limit: 1033)
     Memory: 4.1M
        CPU: 30ms
     CGroup: /system.slice/nginx.service
             tq3738 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             mq3741 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >

从网络浏览器进行访问。

image.png

Nginx 版本

我們要確認一下。嗯,這不是最新的。關於如何使其成為最新的方法,可以在下一篇文章中找到。

$ nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
广告
将在 10 秒后关闭
bannerAds