DEV Community

Cover image for Install NGINX in Ubuntu 22.04 LTS Server
Asep Septiadi
Asep Septiadi

Posted on

Install NGINX in Ubuntu 22.04 LTS Server

servex@aspsptyd:~$ sudo apt -y install nginx
Enter fullscreen mode Exit fullscreen mode

Tunggu sampai proses installasi selesai

[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]
. . . . 
Enter fullscreen mode Exit fullscreen mode

Pastikan tidak ada masalah saat installasi, berikutnya menyesuaikan firewall seperti berikut

servex@aspsptyd:~$ sudo ufw app list
Available applications:
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  OpenSSH
servex@aspsptyd:~$
Enter fullscreen mode Exit fullscreen mode

As demonstrated by the output, there are three profiles available for Nginx:

  1. Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
  2. Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
  3. Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
servex@aspsptyd:~$ sudo ufw allow 'Nginx HTTP'
Rules updated
Rules updated (v6)
Enter fullscreen mode Exit fullscreen mode
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.
Enter fullscreen mode Exit fullscreen mode

Image description

Jika sudah, selanjutnya kita akses IP VM / server seperti gambar diatas, dan pastikan akses ke webserver nginx sudah muncul.

Top comments (0)