TheKoguryo's 기술 블로그

Version 2019.06.03

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

Apache HTTP Server 설치

  1. 생성한 Instance에 SSH 명령을 통해 접속

    ssh –i <private_key> <username>@<public-ip-address>

    <private_key>: Linux 인스턴스에 등록된 공개키에 매칭되는 개인키
    <username>: 인스턴스의 디폴트 사용자입니다. 예, opc
    <public-ip-address>: 인스턴스의 Public IP입니다. OCI 콘솔에서 확인할 수 있습니다.

  2. yum update

    sudo yum -y update
  3. Apache HTTP Server 설치

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

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

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

  5. 방화벽 변경정보 다시 반영

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

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

    sudo su
    echo 'Hello Apache' >/var/www/html/index.html

설치 예시

oracle@ubuntu:~$ ssh -i privateKey opc@129.213.56.XX
Last login: Fri Jan 11 11:38:48 2019 from 221.149.60.XX
[opc@examplelinuxinstance ~]$ sudo yum -y update
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package kernel-uek.x86_64 0:4.14.35-1844.0.7.el7uek will be installed
---> Package oci-utils.noarch 0:0.7.1-2.el7 will be updated
---> Package oci-utils.noarch 0:0.8.0-4.el7 will be an update
---> Package python2-pyOpenSSL.noarch 0:17.4.0-1.3.el7 will be updated
---> Package python2-pyOpenSSL.noarch 0:17.5.0-1.3.el7 will be an update
---> Package tzdata.noarch 0:2018g-1.el7 will be updated
---> Package tzdata.noarch 0:2018i-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================
 Package                      Arch              Version                             Repository                Size
===================================================================================================================
Installing:
 kernel-uek                   x86_64            4.14.35-1844.0.7.el7uek             ol7_UEKR5                 52 M
Updating:
 oci-utils                    noarch            0.8.0-4.el7                         ol7_developer            129 k
 python2-pyOpenSSL            noarch            17.5.0-1.3.el7                      ol7_developer             95 k
 tzdata                       noarch            2018i-1.el7                         ol7_latest               489 k

Transaction Summary
===================================================================================================================
Install  1 Package
Upgrade  3 Packages

Total download size: 53 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/4): oci-utils-0.8.0-4.el7.noarch.rpm                                                     | 129 kB  00:00:00
(2/4): python2-pyOpenSSL-17.5.0-1.3.el7.noarch.rpm                                          |  95 kB  00:00:00
(3/4): tzdata-2018i-1.el7.noarch.rpm                                                        | 489 kB  00:00:00
(4/4): kernel-uek-4.14.35-1844.0.7.el7uek.x86_64.rpm                                        |  52 MB  00:00:00
-------------------------------------------------------------------------------------------------------------------
Total                                                                              108 MB/s |  53 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-uek-4.14.35-1844.0.7.el7uek.x86_64                                                       1/7
  Updating   : python2-pyOpenSSL-17.5.0-1.3.el7.noarch                                                         2/7
  Updating   : oci-utils-0.8.0-4.el7.noarch                                                                    3/7
  Updating   : tzdata-2018i-1.el7.noarch                                                                       4/7
  Cleanup    : python2-pyOpenSSL-17.4.0-1.3.el7.noarch                                                         5/7
  Cleanup    : oci-utils-0.7.1-2.el7.noarch                                                                    6/7
  Cleanup    : tzdata-2018g-1.el7.noarch                                                                       7/7
bash
modsign
nss-softokn
i18n
network
ifcfg
btrfs
crypt
dm
dmraid
kernel-modules
lvm
mdraid
qemu
qemu-net
iscsi
nfs
resume
rootfs-block
terminfo
udev-rules
virtfs
biosdevname
systemd
usrmount
-uptrack
base
fs-lib
microcode_ctl-fw_dir_override
shutdown
bash
modsign
rescue
nss-softokn
i18n
network
ifcfg
btrfs
crypt
dm
dmraid
kernel-modules
lvm
mdraid
qemu
qemu-net
iscsi
nfs
resume
rootfs-block
terminfo
udev-rules
virtfs
biosdevname
systemd
usrmount
-uptrack
base
fs-lib
microcode_ctl-fw_dir_override
shutdown
  Verifying  : tzdata-2018i-1.el7.noarch                                                                       1/7
  Verifying  : oci-utils-0.8.0-4.el7.noarch                                                                    2/7
  Verifying  : python2-pyOpenSSL-17.5.0-1.3.el7.noarch                                                         3/7
  Verifying  : kernel-uek-4.14.35-1844.0.7.el7uek.x86_64                                                       4/7
  Verifying  : tzdata-2018g-1.el7.noarch                                                                       5/7
  Verifying  : python2-pyOpenSSL-17.4.0-1.3.el7.noarch                                                         6/7
  Verifying  : oci-utils-0.7.1-2.el7.noarch                                                                    7/7

Installed:
  kernel-uek.x86_64 0:4.14.35-1844.0.7.el7uek

Updated:
  oci-utils.noarch 0:0.8.0-4.el7     python2-pyOpenSSL.noarch 0:17.5.0-1.3.el7     tzdata.noarch 0:2018i-1.el7

Complete!
[opc@examplelinuxinstance ~]$
[opc@examplelinuxinstance ~]$ sudo yum -y install httpd
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-88.0.1.el7 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-88.0.1.el7 for package: httpd-2.4.6-88.0.1.el7.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-88.0.1.el7.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-88.0.1.el7.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-88.0.1.el7.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.0.1.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-88.0.1.el7 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================
 Package                    Arch                  Version                          Repository                 Size
===================================================================================================================
Installing:
 httpd                      x86_64                2.4.6-88.0.1.el7                 ol7_latest                1.2 M
Installing for dependencies:
 apr                        x86_64                1.4.8-3.el7_4.1                  ol7_latest                103 k
 apr-util                   x86_64                1.5.2-6.0.1.el7                  ol7_latest                 91 k
 httpd-tools                x86_64                2.4.6-88.0.1.el7                 ol7_latest                 90 k
 mailcap                    noarch                2.1.41-2.el7                     ol7_latest                 30 k

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

Total download size: 1.5 M
Installed size: 4.3 M
Downloading packages:
(1/5): apr-1.4.8-3.el7_4.1.x86_64.rpm                                                       | 103 kB  00:00:00
(2/5): apr-util-1.5.2-6.0.1.el7.x86_64.rpm                                                  |  91 kB  00:00:00
(3/5): httpd-tools-2.4.6-88.0.1.el7.x86_64.rpm                                              |  90 kB  00:00:00
(4/5): httpd-2.4.6-88.0.1.el7.x86_64.rpm                                                    | 1.2 MB  00:00:00
(5/5): mailcap-2.1.41-2.el7.noarch.rpm                                                      |  30 kB  00:00:00
-------------------------------------------------------------------------------------------------------------------
Total                                                                               12 MB/s | 1.5 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7_4.1.x86_64                                                                      1/5
  Installing : apr-util-1.5.2-6.0.1.el7.x86_64                                                                 2/5
  Installing : httpd-tools-2.4.6-88.0.1.el7.x86_64                                                             3/5
  Installing : mailcap-2.1.41-2.el7.noarch                                                                     4/5
  Installing : httpd-2.4.6-88.0.1.el7.x86_64                                                                   5/5
  Verifying  : httpd-2.4.6-88.0.1.el7.x86_64                                                                   1/5
  Verifying  : apr-util-1.5.2-6.0.1.el7.x86_64                                                                 2/5
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                     3/5
  Verifying  : httpd-tools-2.4.6-88.0.1.el7.x86_64                                                             4/5
  Verifying  : apr-1.4.8-3.el7_4.1.x86_64                                                                      5/5

Installed:
  httpd.x86_64 0:2.4.6-88.0.1.el7

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1      apr-util.x86_64 0:1.5.2-6.0.1.el7     httpd-tools.x86_64 0:2.4.6-88.0.1.el7
  mailcap.noarch 0:2.1.41-2.el7

Complete!
[opc@examplelinuxinstance ~]$
[opc@examplelinuxinstance ~]$ sudo firewall-cmd --permanent --add-port=80/tcp
success
[opc@examplelinuxinstance ~]$
[opc@examplelinuxinstance ~]$ sudo firewall-cmd --reload
success
[opc@examplelinuxinstance ~]$
[opc@examplelinuxinstance ~]$ sudo systemctl start httpd
[opc@examplelinuxinstance ~]$
[opc@examplelinuxinstance ~]$ sudo su
[root@examplelinuxinstance opc]# echo 'Hello Apache' >/var/www/html/index.html
[root@examplelinuxinstance opc]# exit
exit
[opc@examplelinuxinstance ~]$
[opc@examplelinuxinstance ~]$ curl http://127.0.0.1:80/index.html
Hello Apache
[opc@examplelinuxinstance ~]$


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