업무에서는 nginx를 사용하기 이미 설치가 되어 있는 상태였으나 신규로 아파치를 설치하고 사용해야하는 일이 생겼다.
또한 추후 인터넷을 사용할 수 없는 상황에서 설치할 수 있기 때문에 이번에 패키지를 yum install 이 아닌 download 후 install 하는 방식으로 하고자한다.
1. 패키지 다운로드 (인터넷 되는 환경에서)
httpd 패키지 다운로드
sudo yum install --downloadonly --downloaddir=./ httpd
[ec2-user apache]$ sudo yum install --downloadonly --downloaddir=./ httpd
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register.
Last metadata expiration check: 0:02:41 ago on Mon 21 Apr 2025 03:12:48 PM KST.
Dependencies resolved.
============================================================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================================================
Installing:
httpd x86_64 2.4.62-1.el9_5.2 rhel-9-appstream-rhui-rpms 51 k
Installing dependencies:
apr x86_64 1.7.0-12.el9_3 rhel-9-appstream-rhui-rpms 126 k
apr-util x86_64 1.6.1-23.el9 rhel-9-appstream-rhui-rpms 97 k
apr-util-bdb x86_64 1.6.1-23.el9 rhel-9-appstream-rhui-rpms 14 k
httpd-core x86_64 2.4.62-1.el9_5.2 rhel-9-appstream-rhui-rpms 1.5 M
httpd-filesystem noarch 2.4.62-1.el9_5.2 rhel-9-appstream-rhui-rpms 15 k
httpd-tools x86_64 2.4.62-1.el9_5.2 rhel-9-appstream-rhui-rpms 86 k
mailcap noarch 2.1.49-5.el9 rhel-9-baseos-rhui-rpms 35 k
redhat-logos-httpd noarch 90.4-2.el9 rhel-9-appstream-rhui-rpms 18 k
Installing weak dependencies:
apr-util-openssl x86_64 1.6.1-23.el9 rhel-9-appstream-rhui-rpms 17 k
mod_http2 x86_64 2.0.26-2.el9_4.1 rhel-9-appstream-rhui-rpms 167 k
mod_lua x86_64 2.4.62-1.el9_5.2 rhel-9-appstream-rhui-rpms 60 k
Transaction Summary
============================================================================================================================================================================================================
Install 12 Packages
Total download size: 2.2 M
Installed size: 6.1 M
YUM will only download packages for the transaction.
Is this ok [y/N]: y
Downloading Packages:
(1/12): apr-util-openssl-1.6.1-23.el9.x86_64.rpm 439 kB/s | 17 kB 00:00
(2/12): apr-util-bdb-1.6.1-23.el9.x86_64.rpm 353 kB/s | 14 kB 00:00
(3/12): apr-util-1.6.1-23.el9.x86_64.rpm 2.1 MB/s | 97 kB 00:00
(4/12): redhat-logos-httpd-90.4-2.el9.noarch.rpm 2.0 MB/s | 18 kB 00:00
(5/12): apr-1.7.0-12.el9_3.x86_64.rpm 11 MB/s | 126 kB 00:00
(6/12): mod_http2-2.0.26-2.el9_4.1.x86_64.rpm 15 MB/s | 167 kB 00:00
(7/12): httpd-2.4.62-1.el9_5.2.x86_64.rpm 4.5 MB/s | 51 kB 00:00
(8/12): httpd-filesystem-2.4.62-1.el9_5.2.noarch.rpm 2.7 MB/s | 15 kB 00:00
(9/12): httpd-tools-2.4.62-1.el9_5.2.x86_64.rpm 7.1 MB/s | 86 kB 00:00
(10/12): mod_lua-2.4.62-1.el9_5.2.x86_64.rpm 5.8 MB/s | 60 kB 00:00
(11/12): mailcap-2.1.49-5.el9.noarch.rpm 3.3 MB/s | 35 kB 00:00
(12/12): httpd-core-2.4.62-1.el9_5.2.x86_64.rpm 35 MB/s | 1.5 MB 00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 16 MB/s | 2.2 MB 00:00
Complete!
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
[ec2-user apache]$ ll
total 2280
drwxr-xr-x. 3 ec2-user ec2-user 21 Apr 21 14:06 '~'
-rw-r--r--. 1 root root 129032 Apr 21 15:15 apr-1.7.0-12.el9_3.x86_64.rpm
-rw-r--r--. 1 root root 99555 Apr 21 15:15 apr-util-1.6.1-23.el9.x86_64.rpm
-rw-r--r--. 1 root root 14447 Apr 21 15:15 apr-util-bdb-1.6.1-23.el9.x86_64.rpm
-rw-r--r--. 1 root root 16990 Apr 21 15:15 apr-util-openssl-1.6.1-23.el9.x86_64.rpm
-rw-r--r--. 1 root root 52310 Apr 21 15:15 httpd-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 root root 1602367 Apr 21 15:15 httpd-core-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 root root 15487 Apr 21 15:15 httpd-filesystem-2.4.62-1.el9_5.2.noarch.rpm
-rw-r--r--. 1 root root 88326 Apr 21 15:15 httpd-tools-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 root root 35492 Apr 21 15:15 mailcap-2.1.49-5.el9.noarch.rpm
-rw-r--r--. 1 root root 171015 Apr 21 15:15 mod_http2-2.0.26-2.el9_4.1.x86_64.rpm
-rw-r--r--. 1 root root 61903 Apr 21 15:15 mod_lua-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 561 Apr 21 13:55 reademe.md
-rw-r--r--. 1 root root 18560 Apr 21 15:15 redhat-logos-httpd-90.4-2.el9.noarch.rpm
2. 패키지 이동 (인터넷 안되는 폐쇠망으로)
연습이기 때문에 이동했다 치고
3. 패키지 설치
sudo yum localinstall *.rpm
[ec2-user apache]$ sudo yum localinstall *.rpm
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register.
Last metadata expiration check: 0:07:46 ago on Mon 21 Apr 2025 03:12:48 PM KST.
Dependencies resolved.
==============================================================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================================================
Installing:
apr x86_64 1.7.0-12.el9_3 @commandline 126 k
apr-util x86_64 1.6.1-23.el9 @commandline 97 k
apr-util-bdb x86_64 1.6.1-23.el9 @commandline 14 k
apr-util-openssl x86_64 1.6.1-23.el9 @commandline 17 k
httpd x86_64 2.4.62-1.el9_5.2 @commandline 51 k
httpd-core x86_64 2.4.62-1.el9_5.2 @commandline 1.5 M
httpd-filesystem noarch 2.4.62-1.el9_5.2 @commandline 15 k
httpd-tools x86_64 2.4.62-1.el9_5.2 @commandline 86 k
mailcap noarch 2.1.49-5.el9 @commandline 35 k
mod_http2 x86_64 2.0.26-2.el9_4.1 @commandline 167 k
mod_lua x86_64 2.4.62-1.el9_5.2 @commandline 60 k
redhat-logos-httpd noarch 90.4-2.el9 @commandline 18 k
Transaction Summary
==============================================================================================================================================================================================================
Install 12 Packages
Total size: 2.2 M
Installed size: 6.1 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : apr-1.7.0-12.el9_3.x86_64 1/12
Installing : apr-util-bdb-1.6.1-23.el9.x86_64 2/12
Installing : apr-util-openssl-1.6.1-23.el9.x86_64 3/12
Installing : apr-util-1.6.1-23.el9.x86_64 4/12
Installing : httpd-tools-2.4.62-1.el9_5.2.x86_64 5/12
Installing : redhat-logos-httpd-90.4-2.el9.noarch 6/12
Installing : mailcap-2.1.49-5.el9.noarch 7/12
Running scriptlet: httpd-filesystem-2.4.62-1.el9_5.2.noarch 8/12
Installing : httpd-filesystem-2.4.62-1.el9_5.2.noarch 8/12
Installing : httpd-core-2.4.62-1.el9_5.2.x86_64 9/12
Installing : mod_lua-2.4.62-1.el9_5.2.x86_64 10/12
Installing : mod_http2-2.0.26-2.el9_4.1.x86_64 11/12
Installing : httpd-2.4.62-1.el9_5.2.x86_64 12/12
Running scriptlet: httpd-2.4.62-1.el9_5.2.x86_64 12/12
Verifying : apr-1.7.0-12.el9_3.x86_64 1/12
Verifying : apr-util-1.6.1-23.el9.x86_64 2/12
Verifying : apr-util-bdb-1.6.1-23.el9.x86_64 3/12
Verifying : apr-util-openssl-1.6.1-23.el9.x86_64 4/12
Verifying : httpd-2.4.62-1.el9_5.2.x86_64 5/12
Verifying : httpd-core-2.4.62-1.el9_5.2.x86_64 6/12
Verifying : httpd-filesystem-2.4.62-1.el9_5.2.noarch 7/12
Verifying : httpd-tools-2.4.62-1.el9_5.2.x86_64 8/12
Verifying : mailcap-2.1.49-5.el9.noarch 9/12
Verifying : mod_http2-2.0.26-2.el9_4.1.x86_64 10/12
Verifying : mod_lua-2.4.62-1.el9_5.2.x86_64 11/12
Verifying : redhat-logos-httpd-90.4-2.el9.noarch 12/12
Installed products updated.
Installed:
apr-1.7.0-12.el9_3.x86_64 apr-util-1.6.1-23.el9.x86_64 apr-util-bdb-1.6.1-23.el9.x86_64 apr-util-openssl-1.6.1-23.el9.x86_64 httpd-2.4.62-1.el9_5.2.x86_64
httpd-core-2.4.62-1.el9_5.2.x86_64 httpd-filesystem-2.4.62-1.el9_5.2.noarch httpd-tools-2.4.62-1.el9_5.2.x86_64 mailcap-2.1.49-5.el9.noarch mod_http2-2.0.26-2.el9_4.1.x86_64
mod_lua-2.4.62-1.el9_5.2.x86_64 redhat-logos-httpd-90.4-2.el9.noarch
Complete!
4. 설치 확인, enable, start
# 다운로드 확인
sudo systemctl status httpd
# 재기동 시 자동 시작 서비스 등록
sudo systemctl enable httpd
# httpd 시작
sudo systemctl start httpd
[ec2-user apache]$ sudo systemctl status httpd
○ httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
Active: inactive (dead)
Docs: man:httpd.service(8)
[ec2-user apache]$ sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[ec2-user apache]$ sudo systemctl start httpd
[ec2-user apache]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
Active: active (running) since Mon 2025-04-21 15:22:41 KST; 1min 15s ago
Docs: man:httpd.service(8)
Main PID: 12504 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec"
Tasks: 177 (limit: 47887)
Memory: 22.4M
CPU: 117ms
CGroup: /system.slice/httpd.service
├─12504 /usr/sbin/httpd -DFOREGROUND
├─12505 /usr/sbin/httpd -DFOREGROUND
├─12506 /usr/sbin/httpd -DFOREGROUND
├─12507 /usr/sbin/httpd -DFOREGROUND
└─12508 /usr/sbin/httpd -DFOREGROUND
Apr 21 15:22:41 ip-172-31-55-140.ap-northeast-2.compute.internal systemd[1]: Starting The Apache HTTP Server...
Apr 21 15:22:41 ip-172-31-55-140.ap-northeast-2.compute.internal httpd[12504]: Server configured, listening on: port 80
Apr 21 15:22:41 ip-172-31-55-140.ap-northeast-2.compute.internal systemd[1]: Started The Apache HTTP Server.
[ec2-user apache]$
5. CURL로 확인해보기
curl localhost:80
6. 브라우저로 확인
6-1 배스천 서버의 설정
현재 서버는 private IP로만 구성 되어 있으며 접근은 베스쳔 서버부터 타고 들어가야한다.
ssh 접근도 bastion 서버부터 접근한다
local -> bastion(public IP) -> apache(private IP)
내 로컬에서 apache를 접근하기 위해서는 bastion에 설정이 필요하다.
local에서 mobaxterm을 사용하여 터널링을 진행
터널링 클릭
New ssh tunnel 클릭
내가 사용할 포트(9999), 베스천 아이피, 베스천 아이디, 아파치 서버의 IP , 아파치 서버 포트
설정 후 저장
베스천의 ppk지정하기 위해 열쇠 모양 클릭 후 ppk 등록
실행
localhost:9999 접속
설명과 같이 html 정적 파일은 "/var/www/html"에 두고
설정 파일은 "/etc/httpd/conf.d/welcome.conf"에 설정하면 된다.
'웹 정리 > TIL' 카테고리의 다른 글
Node-Red [1] 설치와 RestApi 테스트 (0) | 2025.01.10 |
---|---|
Vscode에서 환경별 다른 버전의 Node.js 사용하기 (0) | 2024.11.21 |
nginx의 proxy_read_timeout 설정(api timeout) (2) | 2024.11.08 |
Arthas JVM stack 툴(profiler) (2) | 2024.10.08 |
iframe과 nginx 그리고 https (0) | 2024.08.29 |