AWS EC2の「Ubuntu Server」インスタンス上にApache Webサーバーをインストールする


AWS EC2の「Ubuntu Server」インスタンス上にApache Webサーバーをインストールしてみます。なお、サーバーをインストールするあたり、sudo権限を持つ通常のroot以外のユーザーの設定が必要となります。



Windows10(Google Chrome)

AWS インスタンス作成済み(Ubuntu 22.04 LTS (GNU/Linux 5.15.0-1011-aws x86 64))


Apache Webサーバーをインストールしてみますが、その前に「AWS マネジメントコンソール」にログインし、「EC2」サービスへ移動します。移動後、「EC2 Management Console」内の左メニューの「インスタンス」の「インスタンス」をクリックすると、作成した「インスタンス」が一覧で表示されます。

今回作成した「Ubuntu Server」インスタンスの「インスタンス状態」が「実行中」であることを確認します。確認後、SSHクライアント「PuTTY」を用いて、SSHで接続を行います。

Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-1011-aws x86 64)
* Documentation: https://help.ub 
* Management: 
* Support:
System information as of Fri Jul 8 00:49:50 UTC 2022
System load: 0.0 Usage of 7: 22.6% of 7.58GB Memory usage: 234 Swap usage: 0%
100 Users logged in: IPv4 address for etho: ***.**.**.**
* Ubuntu Pro delivers the most comprehensive open source security and,
compliance features.

Ubuntu Pro for AWS | Ubuntu
Ubuntu Pro for AWS, the Ubuntu image optimised for production and professional use on public cloud. Including broad secu...
42 updates can be applied immediately. 22 of these updates are standard security updates. To see these additional updates run: apt list --upgradable





$ sudo apt update

接続後、上記のコマンドを入力し、Enterキーを押します。パッケージ一覧を更新します。Enterキーを押すと更新が開始され、「Reading package lists… Done(パッケージリストを読んでいます…完了)」、「** packages can be upgraded. (パッケージはアップグレードできます。)」といったメッセージが出力されます。これが出力されれば更新が完了となります。

$ sudo apt install apache2


Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils bzip2 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.3-0 mailcap mime-support
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils bzip2 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.3-0 mailcap mime-support
0 upgraded, 13 newly installed, 0 to remove and 45 not upgraded.
Need to get 2138 kB of archives.
After this operation, 8501 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Enterキーを押すと、パッケージの確認などが行われ、「Do you want to continue? [Y/n](続けますか?)」と質問されますので、「Y」を入力し、Enterキーを押します。

Get:1 jammy/main amd64 libapr1 amd64 1.7.0-8build1 [107 kB]
Get:2 jammy/main amd64 libaprutil1 amd64 1.6.1-5ubuntu4 [92.4 kB]
Get:3 jammy/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-5ubuntu4 [11.3 kB]
Get:4 jammy/main amd64 libaprutil1-ldap amd64 1.6.1-5ubuntu4 [9162 B]
Get:5 jammy/main amd64 liblua5.3-0 amd64 5.3.6-1build1 [140 kB]
Get:6 jammy-updates/main amd64 apache2-bin amd64 2.4.52-1ubuntu4.1 [1347 kB]
Get:7 jammy-updates/main amd64 apache2-data all 2.4.52-1ubuntu4.1 [165 kB]
Get:8 jammy-updates/main amd64 apache2-utils amd64 2.4.52-1ubuntu4.1 [89.1 kB]
Get:9 jammy/main amd64 mailcap all 3.70+nmu1ubuntu1 [23.8 kB]
Get:10 jammy/main amd64 mime-support all 3.66 [3696 B]
Get:11 jammy-updates/main amd64 apache2 amd64 2.4.52-1ubuntu4.1 [97.8 kB]
Get:12 jammy/main amd64 bzip2 amd64 1.0.8-5build1 [34.8 kB]
Get:13 jammy/main amd64 ssl-cert all 1.1.2 [17.4 kB]
Fetched 2138 kB in 0s (16.9 MB/s)
Preconfiguring packages ...
Selecting previously unselected package libapr1:amd64.
(Reading database ... 63612 files and directories currently installed.)
Preparing to unpack .../00-libapr1_1.7.0-8build1_amd64.deb ...
Unpacking libapr1:amd64 (1.7.0-8build1) ...
Selecting previously unselected package libaprutil1:amd64.
Preparing to unpack .../01-libaprutil1_1.6.1-5ubuntu4_amd64.deb ...
Unpacking libaprutil1:amd64 (1.6.1-5ubuntu4) ...
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
Preparing to unpack .../02-libaprutil1-dbd-sqlite3_1.6.1-5ubuntu4_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.1-5ubuntu4) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../03-libaprutil1-ldap_1.6.1-5ubuntu4_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.6.1-5ubuntu4) ...
Selecting previously unselected package liblua5.3-0:amd64.
Preparing to unpack .../04-liblua5.3-0_5.3.6-1build1_amd64.deb ...
Unpacking liblua5.3-0:amd64 (5.3.6-1build1) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../05-apache2-bin_2.4.52-1ubuntu4.1_amd64.deb ...
Unpacking apache2-bin (2.4.52-1ubuntu4.1) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../06-apache2-data_2.4.52-1ubuntu4.1_all.deb ...
Unpacking apache2-data (2.4.52-1ubuntu4.1) ...
Selecting previously unselected package apache2-utils.
Preparing to unpack .../07-apache2-utils_2.4.52-1ubuntu4.1_amd64.deb ...
Unpacking apache2-utils (2.4.52-1ubuntu4.1) ...
Selecting previously unselected package mailcap.
Preparing to unpack .../08-mailcap_3.70+nmu1ubuntu1_all.deb ...
Unpacking mailcap (3.70+nmu1ubuntu1) ...
Selecting previously unselected package mime-support.
Preparing to unpack .../09-mime-support_3.66_all.deb ...
Unpacking mime-support (3.66) ...
Selecting previously unselected package apache2.
Preparing to unpack .../10-apache2_2.4.52-1ubuntu4.1_amd64.deb ...
Unpacking apache2 (2.4.52-1ubuntu4.1) ...
Selecting previously unselected package bzip2.
Preparing to unpack .../11-bzip2_1.0.8-5build1_amd64.deb ...
Unpacking bzip2 (1.0.8-5build1) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../12-ssl-cert_1.1.2_all.deb ...
Unpacking ssl-cert (1.1.2) ...
Setting up libapr1:amd64 (1.7.0-8build1) ...
Setting up bzip2 (1.0.8-5build1) ...
Setting up ssl-cert (1.1.2) ...
Setting up liblua5.3-0:amd64 (5.3.6-1build1) ...
Setting up apache2-data (2.4.52-1ubuntu4.1) ...
Setting up mailcap (3.70+nmu1ubuntu1) ...
Setting up libaprutil1:amd64 (1.6.1-5ubuntu4) ...
Setting up mime-support (3.66) ...
Setting up libaprutil1-ldap:amd64 (1.6.1-5ubuntu4) ...
Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.1-5ubuntu4) ...
Setting up apache2-utils (2.4.52-1ubuntu4.1) ...
Setting up apache2-bin (2.4.52-1ubuntu4.1) ...
Setting up apache2 (2.4.52-1ubuntu4.1) ...
Enabling module mpm_event.
Enabling module authz_core.
Enabling module authz_host.
Enabling module authn_core.
Enabling module auth_basic.
Enabling module access_compat.
Enabling module authn_file.
Enabling module authz_user.
Enabling module alias.
Enabling module dir.
Enabling module autoindex.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module filter.
Enabling module deflate.
Enabling module status.
Enabling module reqtimeout.
Enabling conf charset.
Enabling conf localized-error-pages.
Enabling conf other-vhosts-access-log.
Enabling conf security.
Enabling conf serve-cgi-bin.
Enabling site 000-default.
Created symlink /etc/systemd/system/ ? /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/ ? /lib/systemd/system/apache-htcacheclean.service.
Processing triggers for ufw (0.36.1-4build1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.



$ sudo systemctl status apache2


??pache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
     Active: active (running) since Fri 2022-07-15 23:45:58 UTC; 3min 58s ago
   Main PID: 2245 (apache2)
      Tasks: 55 (limit: 1146)
     Memory: 4.9M
        CPU: 40ms
     CGroup: /system.slice/apache2.service
             ??2245 /usr/sbin/apache2 -k start
             ??2247 /usr/sbin/apache2 -k start
             ??2248 /usr/sbin/apache2 -k start

Jul 15 23:45:58 ip-***-**-**-** systemd[1]: Starting The Apache HTTP Server...
Jul 15 23:45:58 ip-***-**-**-** systemd[1]: Started The Apache HTTP Server.

Enterキーを押すと、上記のメッセージが出力されます。出力内容を確認すると「Active: active (running)」と出力されており、Apache Webサーバーが実行されていることが確認できました。さらに実行されているということは、インストールも完了していることを意味していますので、これで実行とインストールの確認を終了します。