在 Ubuntu 22.04 LTS 服务器中安装 NGINX

<span style="color:var(--syntax-text-color)"><span style="color:var(--syntax-text-color)"><code>servex@aspsptyd:~$ sudo apt -y install nginx
</code></span></span>

东古三派散文安装

<span style="color:var(--syntax-text-color)"><span style="color:var(--syntax-text-color)"><code>[sudo] password for servex: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  fontconfig-config fonts-dejavu-core libdeflate0 libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip2
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip2
  libtiff5 libwebp7 libxpm4 nginx-common nginx-core
Suggested packages:
  libgd-tools fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
  fontconfig-config fonts-dejavu-core libdeflate0 libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip2
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip2
  libtiff5 libwebp7 libxpm4 nginx nginx-common nginx-core
0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
Need to get 2689 kB of archives.
After this operation, 8335 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 fonts-dejavu-core all 2.37-2build1 [1041 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 fontconfig-config all 2.13.1-4.2ubuntu5 [29.1 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 libdeflate0 amd64 1.10-2 [70.9 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libfontconfig1 amd64 2.13.1-4.2ubuntu5 [131 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 libjpeg-turbo8 amd64 2.1.2-0ubuntu1 [134 kB]
. . . . 
</code></span></span>

安装防火墙后,请先安装防火墙

<span style="color:var(--syntax-text-color)"><span style="color:var(--syntax-text-color)"><code>servex@aspsptyd:~$ sudo ufw app list
Available applications:
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  OpenSSH
servex@aspsptyd:~$
</code></span></span>

如输出所示,Nginx 可以使用三种配置文件:

  1. Nginx Full:此配置文件打开端口 80(正常、未加密的 Web 流量)和端口 443(TLS/SSL 加密流量)
  2. Nginx HTTP:此配置文件仅打开端口 80(正常、未加密的 Web 流量)
  3. Nginx HTTPS:此配置文件仅打开端口 443(TLS/SSL 加密流量)
<span style="color:var(--syntax-text-color)"><span style="color:var(--syntax-text-color)"><code>servex@aspsptyd:~$ sudo ufw allow 'Nginx HTTP'
Rules updated
Rules updated (v6)
</code></span></span>
<span style="color:var(--syntax-text-color)"><span style="color:var(--syntax-text-color)"><code>servex@aspsptyd:~$ sudo ufw status
Status: inactive
servex@aspsptyd:~$ 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 2023-06-20 16:23:35 UTC; 5min ago
       Docs: man:nginx(8)
    Process: 1381 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1382 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1475 (nginx)
      Tasks: 2 (limit: 2220)
     Memory: 6.3M
        CPU: 51ms
     CGroup: /system.slice/nginx.service
             ├─1475 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─1478 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Jun 20 16:23:35 aspsptyd systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 20 16:23:35 aspsptyd systemd[1]: Started A high performance web server and a reverse proxy server.
</code></span></span>

Jika sudah,selanjutnya kita akses IP VM /服务器独立的gambar diatas,dan patikan akses ke webserver nginx sudah muncul。

猜你喜欢

转载自blog.csdn.net/jascl/article/details/131325497