본문 바로가기
Project/3-Tier Architecture

[3-Tier] Amazon Linux2에 Apache HTTP 설치 (WEB 서버 구성2)

by ganyga 2024. 2. 22.

Apache http 설치

[root@web-a ~]# yum install httpd
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                 | 3.6 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.58-1.amzn2 will be installed
--> Processing Dependency: httpd-filesystem = 2.4.58-1.amzn2 for package: httpd-2.4.58-1.amzn2.x86_64
--> Processing Dependency: httpd-tools = 2.4.58-1.amzn2 for package: httpd-2.4.58-1.amzn2.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.58-1.amzn2.x86_64
--> Processing Dependency: httpd-filesystem for package: httpd-2.4.58-1.amzn2.x86_64
--> Processing Dependency: mod_http2 for package: httpd-2.4.58-1.amzn2.x86_64
--> Processing Dependency: system-logos-httpd for package: httpd-2.4.58-1.amzn2.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.58-1.amzn2.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.58-1.amzn2.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.7.2-1.amzn2 will be installed
---> Package apr-util.x86_64 0:1.6.3-1.amzn2.0.1 will be installed
--> Processing Dependency: apr-util-bdb(x86-64) = 1.6.3-1.amzn2.0.1 for package: apr-util-1.6.3-1.amzn2.0.1.x86_64
---> Package generic-logos-httpd.noarch 0:18.0.0-4.amzn2 will be installed
---> Package httpd-filesystem.noarch 0:2.4.58-1.amzn2 will be installed
---> Package httpd-tools.x86_64 0:2.4.58-1.amzn2 will be installed
---> Package mailcap.noarch 0:2.1.41-2.amzn2 will be installed
---> Package mod_http2.x86_64 0:1.15.19-1.amzn2.0.1 will be installed
--> Running transaction check
---> Package apr-util-bdb.x86_64 0:1.6.3-1.amzn2.0.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================
 Package                                         Arch                               Version                                          Repository                              Size
==================================================================================================================================================================================
Installing:
 httpd                                           x86_64                             2.4.58-1.amzn2                                   amzn2-core                             1.4 M
Installing for dependencies:
 apr                                             x86_64                             1.7.2-1.amzn2                                    amzn2-core                             130 k
 apr-util                                        x86_64                             1.6.3-1.amzn2.0.1                                amzn2-core                             101 k
 apr-util-bdb                                    x86_64                             1.6.3-1.amzn2.0.1                                amzn2-core                              22 k
 generic-logos-httpd                             noarch                             18.0.0-4.amzn2                                   amzn2-core                              19 k
 httpd-filesystem                                noarch                             2.4.58-1.amzn2                                   amzn2-core                              25 k
 httpd-tools                                     x86_64                             2.4.58-1.amzn2                                   amzn2-core                              88 k
 mailcap                                         noarch                             2.1.41-2.amzn2                                   amzn2-core                              31 k
 mod_http2                                       x86_64                             1.15.19-1.amzn2.0.1                              amzn2-core                             149 k

Transaction Summary
==================================================================================================================================================================================
Install  1 Package (+8 Dependent packages)

Total download size: 1.9 M
Installed size: 5.3 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): apr-1.7.2-1.amzn2.x86_64.rpm                                                                                                                        | 130 kB  00:00:00
(2/9): apr-util-1.6.3-1.amzn2.0.1.x86_64.rpm                                                                                                               | 101 kB  00:00:00
(3/9): apr-util-bdb-1.6.3-1.amzn2.0.1.x86_64.rpm                                                                                                           |  22 kB  00:00:00
(4/9): generic-logos-httpd-18.0.0-4.amzn2.noarch.rpm                                                                                                       |  19 kB  00:00:00
(5/9): httpd-2.4.58-1.amzn2.x86_64.rpm                                                                                                                     | 1.4 MB  00:00:00
(6/9): httpd-filesystem-2.4.58-1.amzn2.noarch.rpm                                                                                                          |  25 kB  00:00:00
(7/9): httpd-tools-2.4.58-1.amzn2.x86_64.rpm                                                                                                               |  88 kB  00:00:00
(8/9): mailcap-2.1.41-2.amzn2.noarch.rpm                                                                                                                   |  31 kB  00:00:00
(9/9): mod_http2-1.15.19-1.amzn2.0.1.x86_64.rpm                                                                                                            | 149 kB  00:00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                             7.5 MB/s | 1.9 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.7.2-1.amzn2.x86_64                                                                                                                                       1/9
  Installing : apr-util-1.6.3-1.amzn2.0.1.x86_64                                                                                                                              2/9
  Installing : apr-util-bdb-1.6.3-1.amzn2.0.1.x86_64                                                                                                                          3/9
  Installing : httpd-tools-2.4.58-1.amzn2.x86_64                                                                                                                              4/9
  Installing : generic-logos-httpd-18.0.0-4.amzn2.noarch                                                                                                                      5/9
  Installing : mailcap-2.1.41-2.amzn2.noarch                                                                                                                                  6/9
  Installing : httpd-filesystem-2.4.58-1.amzn2.noarch                                                                                                                         7/9
  Installing : mod_http2-1.15.19-1.amzn2.0.1.x86_64                                                                                                                           8/9
  Installing : httpd-2.4.58-1.amzn2.x86_64                                                                                                                                    9/9
  Verifying  : httpd-tools-2.4.58-1.amzn2.x86_64                                                                                                                              1/9
  Verifying  : httpd-filesystem-2.4.58-1.amzn2.noarch                                                                                                                         2/9
  Verifying  : apr-util-bdb-1.6.3-1.amzn2.0.1.x86_64                                                                                                                          3/9
  Verifying  : httpd-2.4.58-1.amzn2.x86_64                                                                                                                                    4/9
  Verifying  : apr-1.7.2-1.amzn2.x86_64                                                                                                                                       5/9
  Verifying  : apr-util-1.6.3-1.amzn2.0.1.x86_64                                                                                                                              6/9
  Verifying  : mailcap-2.1.41-2.amzn2.noarch                                                                                                                                  7/9
  Verifying  : generic-logos-httpd-18.0.0-4.amzn2.noarch                                                                                                                      8/9
  Verifying  : mod_http2-1.15.19-1.amzn2.0.1.x86_64                                                                                                                           9/9

Installed:
  httpd.x86_64 0:2.4.58-1.amzn2

Dependency Installed:
  apr.x86_64 0:1.7.2-1.amzn2                   apr-util.x86_64 0:1.6.3-1.amzn2.0.1     apr-util-bdb.x86_64 0:1.6.3-1.amzn2.0.1     generic-logos-httpd.noarch 0:18.0.0-4.amzn2
  httpd-filesystem.noarch 0:2.4.58-1.amzn2     httpd-tools.x86_64 0:2.4.58-1.amzn2     mailcap.noarch 0:2.1.41-2.amzn2             mod_http2.x86_64 0:1.15.19-1.amzn2.0.1

Complete!

 

version 확인

[root@web-a ~]# httpd -v
Server version: Apache/2.4.58 ()
Server built:   Oct 26 2023 20:09:34

 

httpd 시작, 상태 확인

status 명령어로 조회했을 때 httpd가 inactive인 상태임을 확인

[root@web-a ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd.service(8)

 

start로 데몬을 실행하고 서버 재부팅 시 자동으로 시작되도록 enable 명령어 입력

[root@web-a ~]# systemctl start httpd
[root@web-a ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

 

status 명령어로 active 상태임을 확인

[root@web-a ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2024-01-20 02:14:59 UTC; 7s ago
     Docs: man:httpd.service(8)
 Main PID: 3402 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─3402 /usr/sbin/httpd -DFOREGROUND
           ├─3404 /usr/sbin/httpd -DFOREGROUND
           ├─3405 /usr/sbin/httpd -DFOREGROUND
           ├─3406 /usr/sbin/httpd -DFOREGROUND
           ├─3407 /usr/sbin/httpd -DFOREGROUND
           └─3408 /usr/sbin/httpd -DFOREGROUND

Jan 20 02:14:59 web-a systemd[1]: Starting The Apache HTTP Server...
Jan 20 02:14:59 web-a httpd[3402]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::4d:a3ff:febc:340%eth0. Set th...this message
Jan 20 02:14:59 web-a systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full

 

curl localhost 명령어 입력해서 내부에서 확인하기

[root@web-a ~]# curl localhost
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title>Test Page for the Apache HTTP Server</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<style type="text/css">
			/*<![CDATA[*/
			body {
				background-color: #fff;
				color: #000;
				font-size: 0.9em;
				font-family: sans-serif,helvetica;
				margin: 0;
				padding: 0;

 

index.html 파일에 WEB A 내용 넣기

echo "WEB A" > /var/www/html/index.html

 

다시 curl localhost 명령어로 확인하기

[root@web-a html]# curl localhost
WEB A