2024년 신상 호텔 리스트
최근에 오픈한 호텔을 찾는다면 살펴보세요
부산 추천 호텔: 라발스 호텔

Ubuntu - Nginx 설치하기

조회수: 771

서버 터미널에서 우선 sudo apt update 실행하자.

Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease                                  

Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                

Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]            

Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]            

Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2,192 kB]

Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [1,337 kB]

Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [1,575 kB]

Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,748 kB]

Fetched 7,103 kB in 5s (1,333 kB/s)                        

Reading package lists... Done

Building dependency tree       

Reading state information... Done

18 packages can be upgraded. Run 'apt list --upgradable' to see them.

 

그리고 sudo apt install nginx 실행하자.

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following additional packages will be installed:

  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip

  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5

  libwebp6 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 libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip

  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5

  libwebp6 libxpm4 nginx nginx-common nginx-core

0 upgraded, 18 newly installed, 0 to remove and 18 not upgraded.

Need to get 2,461 kB of archives.

After this operation, 8,210 kB of additional disk space will be used.

Do you want to continue? [Y/n]

 

Y 입력하자. 그럼 아래와 같이 설치가 된다.

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following additional packages will be installed:

  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip

  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5

  libwebp6 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 libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip

  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5

  libwebp6 libxpm4 nginx nginx-common nginx-core

0 upgraded, 18 newly installed, 0 to remove and 18 not upgraded.

Need to get 2,461 kB of archives.

After this operation, 8,210 kB of additional disk space will be used.

Do you want to continue? [Y/n] Y   

Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libjpeg-turbo8 amd64 1.5.2-0ubuntu5.18.04.4 [110 kB]

Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 fonts-dejavu-core all 2.37-1 [1,041 kB]

Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 fontconfig-config all 2.12.6-0ubuntu2 [55.8 kB]

Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 libfontconfig1 amd64 2.12.6-0ubuntu2 [137 kB]

Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 libjpeg8 amd64 8c-2ubuntu8 [2,194 B]

Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 libjbig0 amd64 2.1-3.1build1 [26.7 kB]

Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libtiff5 amd64 4.0.9-5ubuntu0.4 [153 kB]

Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libwebp6 amd64 0.6.1-2ubuntu0.18.04.1 [186 kB]

Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 libxpm4 amd64 1:3.5.12-1 [34.0 kB]

Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgd3 amd64 2.2.5-4ubuntu0.4 [119 kB]

Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 nginx-common all 1.14.0-0ubuntu1.9 [37.2 kB]

Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libnginx-mod-http-geoip amd64 1.14.0-0ubuntu1.9 [11.0 kB]

Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libnginx-mod-http-image-filter amd64 1.14.0-0ubuntu1.9 [14.3 kB]

Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libnginx-mod-http-xslt-filter amd64 1.14.0-0ubuntu1.9 [12.7 kB]

Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libnginx-mod-mail amd64 1.14.0-0ubuntu1.9 [41.6 kB]

Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libnginx-mod-stream amd64 1.14.0-0ubuntu1.9 [63.5 kB]

Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 nginx-core amd64 1.14.0-0ubuntu1.9 [413 kB]

Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 nginx all 1.14.0-0ubuntu1.9 [3,596 B]

Fetched 2,461 kB in 3s (778 kB/s)

Preconfiguring packages ...

Selecting previously unselected package libjpeg-turbo8:amd64.

(Reading database ... 102899 files and directories currently installed.)

Preparing to unpack .../00-libjpeg-turbo8_1.5.2-0ubuntu5.18.04.4_amd64.deb ...

Unpacking libjpeg-turbo8:amd64 (1.5.2-0ubuntu5.18.04.4) ...

Selecting previously unselected package fonts-dejavu-core.

Preparing to unpack .../01-fonts-dejavu-core_2.37-1_all.deb ...

Unpacking fonts-dejavu-core (2.37-1) ...

Selecting previously unselected package fontconfig-config.

Preparing to unpack .../02-fontconfig-config_2.12.6-0ubuntu2_all.deb ...

Unpacking fontconfig-config (2.12.6-0ubuntu2) ...

Selecting previously unselected package libfontconfig1:amd64.

Preparing to unpack .../03-libfontconfig1_2.12.6-0ubuntu2_amd64.deb ...

Unpacking libfontconfig1:amd64 (2.12.6-0ubuntu2) ...

Selecting previously unselected package libjpeg8:amd64.

Preparing to unpack .../04-libjpeg8_8c-2ubuntu8_amd64.deb ...

Unpacking libjpeg8:amd64 (8c-2ubuntu8) ...

Selecting previously unselected package libjbig0:amd64.

Preparing to unpack .../05-libjbig0_2.1-3.1build1_amd64.deb ...

Unpacking libjbig0:amd64 (2.1-3.1build1) ...

Selecting previously unselected package libtiff5:amd64.

Preparing to unpack .../06-libtiff5_4.0.9-5ubuntu0.4_amd64.deb ...

Unpacking libtiff5:amd64 (4.0.9-5ubuntu0.4) ...

Selecting previously unselected package libwebp6:amd64.

Preparing to unpack .../07-libwebp6_0.6.1-2ubuntu0.18.04.1_amd64.deb ...

Unpacking libwebp6:amd64 (0.6.1-2ubuntu0.18.04.1) ...

Selecting previously unselected package libxpm4:amd64.

Preparing to unpack .../08-libxpm4_1%3a3.5.12-1_amd64.deb ...

Unpacking libxpm4:amd64 (1:3.5.12-1) ...

Selecting previously unselected package libgd3:amd64.

Preparing to unpack .../09-libgd3_2.2.5-4ubuntu0.4_amd64.deb ...

Unpacking libgd3:amd64 (2.2.5-4ubuntu0.4) ...

Selecting previously unselected package nginx-common.

Preparing to unpack .../10-nginx-common_1.14.0-0ubuntu1.9_all.deb ...

Unpacking nginx-common (1.14.0-0ubuntu1.9) ...

Selecting previously unselected package libnginx-mod-http-geoip.

Preparing to unpack .../11-libnginx-mod-http-geoip_1.14.0-0ubuntu1.9_amd64.deb ...

Unpacking libnginx-mod-http-geoip (1.14.0-0ubuntu1.9) ...

Selecting previously unselected package libnginx-mod-http-image-filter.

Preparing to unpack .../12-libnginx-mod-http-image-filter_1.14.0-0ubuntu1.9_amd64.deb ...

Unpacking libnginx-mod-http-image-filter (1.14.0-0ubuntu1.9) ...

Selecting previously unselected package libnginx-mod-http-xslt-filter.

Preparing to unpack .../13-libnginx-mod-http-xslt-filter_1.14.0-0ubuntu1.9_amd64.deb ...

Unpacking libnginx-mod-http-xslt-filter (1.14.0-0ubuntu1.9) ...

Selecting previously unselected package libnginx-mod-mail.

Preparing to unpack .../14-libnginx-mod-mail_1.14.0-0ubuntu1.9_amd64.deb ...

Unpacking libnginx-mod-mail (1.14.0-0ubuntu1.9) ...

Selecting previously unselected package libnginx-mod-stream.

Preparing to unpack .../15-libnginx-mod-stream_1.14.0-0ubuntu1.9_amd64.deb ...

Unpacking libnginx-mod-stream (1.14.0-0ubuntu1.9) ...

Selecting previously unselected package nginx-core.

Preparing to unpack .../16-nginx-core_1.14.0-0ubuntu1.9_amd64.deb ...

Unpacking nginx-core (1.14.0-0ubuntu1.9) ...

Selecting previously unselected package nginx.

Preparing to unpack .../17-nginx_1.14.0-0ubuntu1.9_all.deb ...

Unpacking nginx (1.14.0-0ubuntu1.9) ...

Setting up libjbig0:amd64 (2.1-3.1build1) ...

Setting up fonts-dejavu-core (2.37-1) ...

Setting up nginx-common (1.14.0-0ubuntu1.9) ...

Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.

Setting up libjpeg-turbo8:amd64 (1.5.2-0ubuntu5.18.04.4) ...

Setting up libnginx-mod-mail (1.14.0-0ubuntu1.9) ...

Setting up libxpm4:amd64 (1:3.5.12-1) ...

Setting up libnginx-mod-http-xslt-filter (1.14.0-0ubuntu1.9) ...

Setting up libnginx-mod-http-geoip (1.14.0-0ubuntu1.9) ...

Setting up libwebp6:amd64 (0.6.1-2ubuntu0.18.04.1) ...

Setting up libjpeg8:amd64 (8c-2ubuntu8) ...

Setting up fontconfig-config (2.12.6-0ubuntu2) ...

Setting up libnginx-mod-stream (1.14.0-0ubuntu1.9) ...

Setting up libtiff5:amd64 (4.0.9-5ubuntu0.4) ...

Setting up libfontconfig1:amd64 (2.12.6-0ubuntu2) ...

Setting up libgd3:amd64 (2.2.5-4ubuntu0.4) ...

Setting up libnginx-mod-http-image-filter (1.14.0-0ubuntu1.9) ...

Setting up nginx-core (1.14.0-0ubuntu1.9) ...

Setting up nginx (1.14.0-0ubuntu1.9) ...

Processing triggers for systemd (237-3ubuntu10.50) ...

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Processing triggers for ufw (0.36-0ubuntu0.18.04.1) ...

Rules updated for profile 'OpenSSH'

Skipped reloading firewall

Processing triggers for ureadahead (0.100.0-21) ...

Processing triggers for libc-bin (2.27-3ubuntu1.4) ...

 

이제 sudo ufw app list를 실행하자.

그럼 아래와 나온다.

Available applications:

  Nginx Full

  Nginx HTTP

  Nginx HTTPS

  OpenSSH

 

sudo ufw allow 'Nginx Full' 실행하면 이렇게 나올 것이다.

Rule added

Rule added (v6)

 

그리고 sudo ufw status 실행하면 이렇게 확인이 가능.

Status: active

To                         Action      From

--                         ------      ----

OpenSSH                    ALLOW       Anywhere                  

Nginx Full                 ALLOW       Anywhere                  

OpenSSH (v6)               ALLOW       Anywhere (v6)             

Nginx Full (v6)            ALLOW       Anywhere (v6)    

 

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 2021-08-31 07:59:22 UTC; 2h 1min ago

     Docs: man:nginx(8)

 Main PID: 2458 (nginx)

    Tasks: 2 (limit: 1104)

   CGroup: /system.slice/nginx.service

           ├─2458 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;

           └─2460 nginx: worker process

 

크롬에서 본인 서버 IP 주소로 접속하면 아래와 같이 Welcome to nginx!를 볼 수 있다.

http://45.76.125.137 

 

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

 

명령어

sudo systemctl disable nginx
sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx

 

systemctl: 처음에 아무 생각하지 않고 외우려면 쉽지 않다. ctl은 control이다. 자~! 외우기 쉽다.