TheKoguryo's 기술 블로그

 Version 2024.11.15

5.1 Linux 인스턴스에 Apache HTTP Server 설치

  1. 생성한 Instance에 SSH 명령을 통해 접속합니다. 아래 명령은 Oracle Enterprise Linux 기준입니다.

    ssh –i <private_key> <username>@<public-ip-address>
    
  2. Apache HTTP Server 설치

    sudo yum -y install httpd
    
  3. OS 방화벽에서 Apache HTTP용 포트, 80 포트 개방

    sudo firewall-cmd --permanent --add-port=80/tcp
    

    방화벽 개방 포트
    Apache 서버 디폴트 포트이외 포트, 다른 응용프로그램 사용시 실제 개방이 필요한 포트에 맞게 위 명령을 수정하여 해당 포트를 방화벽에서 개방합니다.
  4. 방화벽 변경정보 다시 반영

    sudo firewall-cmd --reload
    
  5. Apache 시작

    sudo systemctl start httpd
    sudo systemctl enable httpd
    
  6. 테스트를 위해 서버의 Root Index Document 생성

    sudo su
    echo 'Hello Apache' >/var/www/html/index.html
    
  7. 포트가 OS에서 개방되었는지 확인합니다.

    sudo firewall-cmd --zone=public --list-ports
    

설치 예시

$ ssh -i privateKey opc@129.154.xx.xxx
FIPS mode initialized
The authenticity of host '129.154.54.163 (129.154.xx.xxx)' can't be established.
ECDSA key fingerprint is SHA256:svS10DcrVps4neg/t9lYoutfow+V5a6UHU2VrC3UJ2Y.
ECDSA key fingerprint is SHA1:2rtJUm8jt0QiYR7b+I3Ra6j4Yac.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '129.154.54.163' (ECDSA) to the list of known hosts.
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Thu May  4 07:03:42 2023 from 132.145.xx.xx

[opc@examplelinuxinstance ~]$ sudo yum -y install httpd
Last metadata expiration check: 2:30:13 ago on Thu 04 May 2023 06:45:55 AM GMT.
Dependencies resolved.
=========================================================================================================================================
 Package                      Architecture     Version                                                 Repository                   Size
=========================================================================================================================================
Installing:
 httpd                        x86_64           2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5           ol8_appstream               1.4 M
Installing dependencies:
 apr                          x86_64           1.6.3-12.el8                                            ol8_appstream               129 k
 apr-util                     x86_64           1.6.1-6.el8                                             ol8_appstream               105 k
 httpd-filesystem             noarch           2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5           ol8_appstream                43 k
 httpd-tools                  x86_64           2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5           ol8_appstream               110 k
 mod_http2                    x86_64           1.15.7-5.module+el8.7.0+21029+de29ba63.4                ol8_appstream               155 k
 oracle-logos-httpd           noarch           84.5-1.0.1.el8                                          ol8_baseos_latest            29 k
Installing weak dependencies:
 apr-util-bdb                 x86_64           1.6.1-6.el8                                             ol8_appstream                24 k
 apr-util-openssl             x86_64           1.6.1-6.el8                                             ol8_appstream                27 k
Enabling module streams:
 httpd                                         2.4                                                                                      

Transaction Summary
=========================================================================================================================================
Install  9 Packages

Total download size: 2.0 M
Installed size: 5.4 M
Downloading Packages:
(1/9): oracle-logos-httpd-84.5-1.0.1.el8.noarch.rpm                                                      1.0 MB/s |  29 kB     00:00    
(2/9): apr-util-1.6.1-6.el8.x86_64.rpm                                                                   3.2 MB/s | 105 kB     00:00    
(3/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm                                                               742 kB/s |  24 kB     00:00    
(4/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm                                                           774 kB/s |  27 kB     00:00    
(5/9): apr-1.6.3-12.el8.x86_64.rpm                                                                       1.4 MB/s | 129 kB     00:00    
(6/9): httpd-tools-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64.rpm                              3.5 MB/s | 110 kB     00:00    
(7/9): httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.noarch.rpm                         766 kB/s |  43 kB     00:00    
(8/9): mod_http2-1.15.7-5.module+el8.7.0+21029+de29ba63.4.x86_64.rpm                                     2.3 MB/s | 155 kB     00:00    
(9/9): httpd-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64.rpm                                    9.2 MB/s | 1.4 MB     00:00    
-----------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                    9.1 MB/s | 2.0 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                 1/1 
  Installing       : apr-1.6.3-12.el8.x86_64                                                                                         1/9 
  Running scriptlet: apr-1.6.3-12.el8.x86_64                                                                                         1/9 
  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                                                                                 2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                                                                             3/9 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                                                                     4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                                                                     4/9 
  Installing       : httpd-tools-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64                                                5/9 
  Running scriptlet: httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.noarch                                           6/9 
  Installing       : httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.noarch                                           6/9 
  Installing       : oracle-logos-httpd-84.5-1.0.1.el8.noarch                                                                        7/9 
  Installing       : mod_http2-1.15.7-5.module+el8.7.0+21029+de29ba63.4.x86_64                                                       8/9 
  Installing       : httpd-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64                                                      9/9 
  Running scriptlet: httpd-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64                                                      9/9 
  Verifying        : oracle-logos-httpd-84.5-1.0.1.el8.noarch                                                                        1/9 
  Verifying        : apr-1.6.3-12.el8.x86_64                                                                                         2/9 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                                                                     3/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                                                                                 4/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                                                                             5/9 
  Verifying        : httpd-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64                                                      6/9 
  Verifying        : httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.noarch                                           7/9 
  Verifying        : httpd-tools-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64                                                8/9 
  Verifying        : mod_http2-1.15.7-5.module+el8.7.0+21029+de29ba63.4.x86_64                                                       9/9 

Installed:
  apr-1.6.3-12.el8.x86_64                                          apr-util-1.6.1-6.el8.x86_64                                          
  apr-util-bdb-1.6.1-6.el8.x86_64                                  apr-util-openssl-1.6.1-6.el8.x86_64                                  
  httpd-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64       httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.noarch
  httpd-tools-2.4.37-51.0.1.module+el8.7.0+21029+de29ba63.5.x86_64 mod_http2-1.15.7-5.module+el8.7.0+21029+de29ba63.4.x86_64            
  oracle-logos-httpd-84.5-1.0.1.el8.noarch                        

Complete!
[opc@examplelinuxinstance ~]$ sudo firewall-cmd --permanent --add-port=80/tcp
success
[opc@examplelinuxinstance ~]$ sudo firewall-cmd --reload
success
[opc@examplelinuxinstance ~]$ sudo systemctl start httpd
[opc@examplelinuxinstance ~]$ sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[opc@examplelinuxinstance ~]$ sudo su
[root@examplelinuxinstance opc]# echo 'Hello Apache' >/var/www/html/index.html
[root@examplelinuxinstance opc]# 
[root@examplelinuxinstance opc]# 
[root@examplelinuxinstance opc]# exit
exit
[opc@examplelinuxinstance ~]$ curl http://127.0.0.1:80/index.html
Hello Apache
[opc@examplelinuxinstance ~]$ sudo firewall-cmd --zone=public --list-ports
80/tcp


이 글은 개인으로서, 개인의 시간을 할애하여 작성된 글입니다. 글의 내용에 오류가 있을 수 있으며, 글 속의 의견은 개인적인 의견입니다.

Last updated on 11 Jan 2019