Linux Server

[Linux]Ubuntu 20.04 웹 서버 구축(1)-아파치 설치

톰아저씨의 오두막 2021. 7. 1. 12:32

[Linux]Ubuntu 20.04 웹 서버 구축(1)-아파치 설치

[UBUNTU] UBUNTU 20.04 Web Server Construction(1) - Apache Installation

 

Ubuntu 20.04 and Apache

 

웹 서버 개요

 

아파치 서버 설치에 앞서 웹 서버에 대하여 간단하게 설명드립니다. 「위키백과」을 참조해 보면 웹 서버(Web Server)는 HTTP를 통해서 웹 브라우저와 같은 클라이언트에서 요청하는 HTML 문서나 오브젝트(이미지, 동영상 등)를 전송해 주는 서비스입니다.

 

웹 서버의 주요 기능은 웹 페이지를 클라이언트(웹 브라우저)로 전달하는 것입니다. 주로 CSS, Javascript 를 포함한 HTML 문서가 클라이언트로 전달됩니다. 주된 작업은 콘텐츠를 제공하는 것이지만 반대로 클라이언트로 부터 콘텐츠를 전달 받는 것도 웹 서버의 기능에 속합니다. 파일 업로드를 포함해서 클라이언트에서 제출한 웹 폼을 수신하기 위해서 사용합니다.

 

아파치 서버는 아파치 소프트웨어 재단에서 관리하는 HTTP 웹 서버입니다. 리눅스, 윈도우 같은 다른 운용체제에서도 운용이 가능하며 오픈소스로 공개되어 무료로 사용 가능합니다.

 

Host Advice」에 따르면 2021년 글로벌 웹 서버에 대한 제품별 점유율은 Apache(40.86%), Nginx(27.86%), IIS(11.01%), LiteSpeed(2.40%), Apache Traffic Server(0.53%) 순 입니다. 또한 국내 웹서버 점유율은 Apache(47.20%), Nginx(37.2%), IIS(9.61%), Apache Tomcat(1.07), Resin(0.03%) 순으로 Apache 서버가 글로벌, 국내 시장을 통틀어서 가장 많이 사용하는 웹 서버 임을 알 수 있습니다.   

 

리눅스 운영체제, 아파치 웹 서버, MySQL 데이터베이스, PHP 로 웹서버를 구성하여 운영하는 것을 머릿글을 따서 LAMP(Linux, Apache, MySQL, PHP) 라고 부릅니다. 모두 오픈소스이며 번들로 제공됩니다.

 

지금 부터 LAMP 중 Ubuntu 20.04에 아파치 웹 서버 저장소를 이용하여  아파치 서버를 설치하는 방법을 설명드리겠습니다.

 

패키지 설치 전 사전 필수 작업

Ubuntu 에서 리눅스 패키지를 배포하거나 설치하기 전에는 필수적으로 시스템 내에 설치된 패키지들을 업그레이드하여 최신 버전으로 유지해 주는 것이 좋습니다. 패키지 설치 전 필수 작업은 다음 글을 참고바랍니다.

 

 

[Ubuntu]Ubuntu 20.04 패키지 설치 전 사전 필수 작업

[Ubuntu]Ubuntu 20.04 패키지 설치 전 사전 필수 작업 [Ubuntu] Prerequisite tasks before installing Ubuntu 20.04 package Ubuntu 에서 리눅스 패키지를 배포하거나 설치하기 전에는 필수적으로..

tomcabin.tistory.com

 

아파치 서버(apache2) 설치

 

ⓐ 아파치 서버를 설치하기 전에 우선 아파치 서버의 패키지 정보를 확인해 봅니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
root@uncletom-vm:~# apt info apache2
Package: apache2
Version: 2.4.41-4ubuntu3.3
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 542 kB
Provides: httpd, httpd-cgi
Pre-Depends: dpkg (>= 1.17.14)
Depends: apache2-bin (= 2.4.41-4ubuntu3.3), apache2-data (= 2.4.41-4ubuntu3.3), apache2-utils 
(= 2.4.41-4ubuntu3.3), lsb-base, mime-support, perl:any, procps
Recommends: ssl-cert
Suggests: apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, www-browser, ufw
Conflicts: apache2.2-bin, apache2.2-common
Breaks: libapache2-mod-proxy-uwsgi (<< 2.4.33)
Replaces: apache2.2-bin, apache2.2-common, libapache2-mod-proxy-uwsgi (<< 2.4.33)
Homepage: https://httpd.apache.org/
Task: lamp-server
Download-Size: 95.5 kB
APT-Sources: http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Description: Apache HTTP Server
 The Apache HTTP Server Project`s goal is to build a secure, efficient and
 extensible HTTP server as standards-compliant open source software. The
 result has long been the number one web server on the Internet.
 .
 Installing this package results in a full installation, including the
 configuration files, init scripts and support scripts.
 
N: There is 1 additional record. Please use the '-a' switch to see it
root@uncletom-vm:~

 

ⓑ 아파치가 현재 운영 시스템에 설치가 되어 있는지 확인합니다. 설치가 되어있지 않으면 아무 것도 표시되지 않고 이미 설치가 되어 있다면 설치된 정보가 표시됩니다. 

 

1
2
3
root@uncletom-vm:~# apt list --installed apache2
나열 중... 완료
root@uncletom-vm:~

 

ⓒ 우분투 시스템에 아파치를 설치합니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
root@uncletom-vm:~# sudo apt install apache2
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음의 추가 패키지가 설치될 것입니다 :
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap
제안하는 패키지:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom
다음 새 패키지를 설치할 것입니다:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap
0개 업그레이드, 8개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
1,712 k바이트 아카이브를 받아야 합니다.
이 작업 후 7,497 k바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] Y
받기:1 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libapr1 amd64 1.6.5-1ubuntu1 [91.4 kB]
......
받기:8 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 apache2 amd64 2.4.41.....
내려받기 1,712 k바이트, 소요시간 3초 (521 k바이트/초)
Selecting previously unselected package libapr1:amd64.
(데이터베이스 읽는중 ...현재 191122개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../0-libapr1_1.6.5-1ubuntu1_amd64.deb ...
Unpacking libapr1:amd64 (1.6.5-1ubuntu1) ...
Selecting previously unselected package libaprutil1:amd64.
......
Enabling conf security.
Enabling conf serve-cgi-bin.
Enabling site 000-default.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /l
ib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.
service → /lib/systemd/system/apache-htcacheclean.service.
Processing triggers for ufw (0.36-6) ...
Processing triggers for systemd (245.4-4ubuntu3.7) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@uncletom-vm:~

 

ⓓ 'apache2' 설치가 완료되었습니다.

 

아파치 서비스 관리를 위한 명령어 소개

 

'apache2' 서비스 관리를 위하여 필요한 몇 가지 명령을 소개합니다.

 

ⓐ 아파치 서비스가 현재 구동 유무 확인

 

1
2
3
root@uncletom-vm:~# sudo systemctl is-active apache2
active
root@uncletom-vm:~#    

 

ⓑ 아파치 서비스가 우분투 시스템 부팅 시 자동으로 구동이 될 수 있도록 설정되어 있는지 확인

 

1
2
3
root@uncletom-vm:~# sudo systemctl is-enabled apache2.service
enabled
root@uncletom-vm:~#       

 

ⓒ 아파치 서비스가 우분투 시스템 부팅 시 자동 구동으로 활성화되도록 설정

 

1
2
3
root@uncletom-vm:~# sudo systemctl enable apache2.service
Unknown operation enabled.
root@uncletom-vm:~#    

 

ⓓ 아파치 서버 상태 확인

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@uncletom-vm:~# sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
     Active: active (running) since Tue 2021-06-22 11:23:28 KST; 50min ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 23950 (apache2)
      Tasks: 55 (limit: 4617)
     Memory: 6.1M
     CGroup: /system.slice/apache2.service
             ├─23950 /usr/sbin/apache2 -k start
             ├─23951 /usr/sbin/apache2 -k start
             └─23952 /usr/sbin/apache2 -k start
 
 6월 22 11:23:28 uncletom-vm systemd[1]: Starting The Apache HTTP Server...
 6월 22 11:23:28 uncletom-vm apachectl[23949]: AH00558: apache2: Could not reli>
 6월 22 11:23:28 uncletom-vm systemd[1]: Started The Apache HTTP Server.
lines 1-15/15 (END)  

 

ⓔ 아파치 서버 중지

 

1
2
root@uncletom-vm:~# sudo systemctl stop apache2.service
root@uncletom-vm:~#

 

ⓕ 아파치 서버 시작

 

1
2
root@uncletom-vm:~# sudo systemctl start apache2.service
root@uncletom-vm:~#   

 

ⓖ 아파치 서버 재시작

 

1
2
root@uncletom-vm:~# sudo systemctl restart apache2.service
root@uncletom-vm:~#  

 

ⓗ 아파치 서버 설정 다시 로딩하기

 

1
2
root@uncletom-vm:~# sudo systemctl reload apache2.service
root@uncletom-vm:~#  

 

ⓘ 아파치 서버 버전 확인하기

 

1
2
3
4
root@uncletom-vm:~# apache2 -v
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2021-06-17T18:27:53
root@uncletom-vm:~#  

 

이상 Ubuntu 20.04 에 아파치 서버를 설치하는 방법을 설명드렸습니다.
감사합니다.