【初心者向け】Oracle Linux 8にApache HTTP Server 2.4をyumインストールする

IT技術

概要

Oracle LinuxにWebサーバ用ミドルウェア「Apache HTTP Server」をインストールする方法を記載する。

システム環境

  • OS:Oracle Linux Server 8.5
  • Apache HTTP Server 2.4

インストール

今回はyumコマンドを使ってインストールする。

「yum search httpd」コマンドを実行し、「httpd.x86_64 : Apache HTTP Server」が表示されることを確認する。

[root@testvm999 ~]# yum search httpd
Last metadata expiration check: 3:12:21 ago on Sat 21 Jan 2023 08:47:08 PM GMT.
====================================== Name Exactly Matched: httpd ======================================
httpd.x86_64 : Apache HTTP Server
===================================== Name & Summary Matched: httpd =====================================
keycloak-httpd-client-install.noarch : Tools to configure Apache HTTPD as Keycloak client
keycloak-httpd-client-install.src : Tools to configure Apache HTTPD as Keycloak client
oracle-logos-httpd.noarch : Oracle-related icons and pictures used by httpd
python3-keycloak-httpd-client-install.noarch : Tools to configure Apache HTTPD as Keycloak client
========================================== Name Matched: httpd ==========================================
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-filesystem.noarch : The basic directory layout for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
libmicrohttpd.i686 : Lightweight library for embedding a webserver in applications
libmicrohttpd.src : Lightweight library for embedding a webserver in applications
libmicrohttpd.x86_64 : Lightweight library for embedding a webserver in applications
======================================== Summary Matched: httpd =========================================
mod_auth_mellon.src : A SAML 2.0 authentication module for the Apache Httpd Server
mod_auth_mellon.x86_64 : A SAML 2.0 authentication module for the Apache Httpd Server
mod_dav_svn.x86_64 : Apache httpd module for Subversion server
[root@testvm999 ~]# 

「yum install httpd.x86_64」コマンドを実行しインストールする。

[root@testvm999 ~]# yum install httpd.x86_64
Last metadata expiration check: 3:14:27 ago on Sat 21 Jan 2023 08:47:08 PM GMT.
Dependencies resolved.
=========================================================================================================
 Package              Arch     Version                                         Repository           Size
=========================================================================================================
Installing:
 httpd                x86_64   2.4.37-51.0.1.module+el8.7.0+20778+02173b8e     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+20778+02173b8e     ol8_appstream        42 k
 httpd-tools          x86_64   2.4.37-51.0.1.module+el8.7.0+20778+02173b8e     ol8_appstream       109 k
 mod_http2            x86_64   1.15.7-5.module+el8.6.0+20548+01710940          ol8_appstream       154 k
 oracle-logos-httpd   noarch   84.5-1.0.1.el8                                  ol8_baseos_latest    29 k
Enabling module streams:
 httpd                         2.4                                                                      
Transaction Summary
=========================================================================================================
Install  7 Packages
Total download size: 2.0 M
Installed size: 5.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): oracle-logos-httpd-84.5-1.0.1.el8.noarch.rpm                      300 kB/s |  29 kB     00:00    
(2/7): apr-1.6.3-12.el8.x86_64.rpm                                       1.1 MB/s | 129 kB     00:00    
(3/7): apr-util-1.6.1-6.el8.x86_64.rpm                                   722 kB/s | 105 kB     00:00    
(4/7): httpd-tools-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64.rp 1.8 MB/s | 109 kB     00:00    
(5/7): httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.noar 453 kB/s |  42 kB     00:00    
(6/7): httpd-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64.rpm      6.3 MB/s | 1.4 MB     00:00    
(7/7): mod_http2-1.15.7-5.module+el8.6.0+20548+01710940.x86_64.rpm       643 kB/s | 154 kB     00:00    
---------------------------------------------------------------------------------------------------------
Total                                                                    4.3 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/7 
  Running scriptlet: apr-1.6.3-12.el8.x86_64                                                         1/7 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                                     2/7 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                                     2/7 
  Installing       : httpd-tools-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64                  3/7 
  Running scriptlet: httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.noarch             4/7 
  Installing       : httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.noarch             4/7 
  Installing       : oracle-logos-httpd-84.5-1.0.1.el8.noarch                                        5/7 
  Installing       : mod_http2-1.15.7-5.module+el8.6.0+20548+01710940.x86_64                         6/7 
  Installing       : httpd-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64                        7/7 
  Running scriptlet: httpd-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64                        7/7 
  Verifying        : oracle-logos-httpd-84.5-1.0.1.el8.noarch                                        1/7 
  Verifying        : apr-1.6.3-12.el8.x86_64                                                         2/7 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                                     3/7 
  Verifying        : httpd-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64                        4/7 
  Verifying        : httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.noarch             5/7 
  Verifying        : httpd-tools-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64                  6/7 
  Verifying        : mod_http2-1.15.7-5.module+el8.6.0+20548+01710940.x86_64                         7/7 
Installed:
  apr-1.6.3-12.el8.x86_64                                                                                
  apr-util-1.6.1-6.el8.x86_64                                                                            
  httpd-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64                                               
  httpd-filesystem-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.noarch                                    
  httpd-tools-2.4.37-51.0.1.module+el8.7.0+20778+02173b8e.x86_64                                         
  mod_http2-1.15.7-5.module+el8.6.0+20548+01710940.x86_64                                                
  oracle-logos-httpd-84.5-1.0.1.el8.noarch                                                               
Complete!
[root@testvm999 ~]# 

バージョンの確認

インストールしたApache HTTP Serverのバージョンを確認する。

[root@testvm999 ~]# httpd -v
Server version: Apache/2.4.37 (Oracle Linux)
Server built:   Oct  3 2022 05:16:06
[root@testvm999 ~]#

Apache HTTP Serverサービス起動/停止/再起動

サービス起動

「systemctl start httpd」コマンドでApache HTTP Serverサービスを起動する。

[root@testvm999 ~]# 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)
[root@testvm999 ~]# 
[root@testvm999 ~]# systemctl start httpd
[root@testvm999 ~]# 
[root@testvm999 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-01-22 00:06:40 GMT; 5s ago
     Docs: man:httpd.service(8)
 Main PID: 2621133 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 3927)
   Memory: 18.7M
   CGroup: /system.slice/httpd.service
           ├─2621133 /usr/sbin/httpd -DFOREGROUND
           ├─2621134 /usr/sbin/httpd -DFOREGROUND
           ├─2621135 /usr/sbin/httpd -DFOREGROUND
           ├─2621136 /usr/sbin/httpd -DFOREGROUND
           └─2621137 /usr/sbin/httpd -DFOREGROUND
Jan 22 00:06:40 testvm999 systemd[1]: Starting The Apache HTTP Server...
Jan 22 00:06:40 testvm999 systemd[1]: Started The Apache HTTP Server.
Jan 22 00:06:40 testvm999 httpd[2621133]: Server configured, listening on: port 80
[root@testvm999 ~]# 

サービス停止

「systemctl stop httpd」コマンドでApache HTTP Serverサービスを停止する。

[root@testvm999 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-01-22 00:06:40 GMT; 3min 31s ago
     Docs: man:httpd.service(8)
 Main PID: 2621133 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 3927)
   Memory: 18.7M
   CGroup: /system.slice/httpd.service
           ├─2621133 /usr/sbin/httpd -DFOREGROUND
           ├─2621134 /usr/sbin/httpd -DFOREGROUND
           ├─2621135 /usr/sbin/httpd -DFOREGROUND
           ├─2621136 /usr/sbin/httpd -DFOREGROUND
           └─2621137 /usr/sbin/httpd -DFOREGROUND
Jan 22 00:06:40 testvm999 systemd[1]: Starting The Apache HTTP Server...
Jan 22 00:06:40 testvm999 systemd[1]: Started The Apache HTTP Server.
Jan 22 00:06:40 testvm999 httpd[2621133]: Server configured, listening on: port 80
[root@testvm999 ~]# 
[root@testvm999 ~]# systemctl stop httpd
[root@testvm999 ~]# 
[root@testvm999 ~]# 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)
Jan 22 00:06:40 testvm999 systemd[1]: Starting The Apache HTTP Server...
Jan 22 00:06:40 testvm999 systemd[1]: Started The Apache HTTP Server.
Jan 22 00:06:40 testvm999 httpd[2621133]: Server configured, listening on: port 80
Jan 22 00:10:18 testvm999 systemd[1]: Stopping The Apache HTTP Server...
Jan 22 00:10:19 testvm999 systemd[1]: httpd.service: Succeeded.
Jan 22 00:10:19 testvm999 systemd[1]: Stopped The Apache HTTP Server.
[root@testvm999 ~]# 

サービス再起動

「systemctl restart httpd」コマンドでApache HTTP Serverサービスを再起動する。

[root@testvm999 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-01-22 00:11:34 GMT; 3s ago
     Docs: man:httpd.service(8)
 Main PID: 2622419 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 3927)
   Memory: 18.9M
   CGroup: /system.slice/httpd.service
           ├─2622419 /usr/sbin/httpd -DFOREGROUND
           ├─2622420 /usr/sbin/httpd -DFOREGROUND
           ├─2622421 /usr/sbin/httpd -DFOREGROUND
           ├─2622422 /usr/sbin/httpd -DFOREGROUND
           └─2622423 /usr/sbin/httpd -DFOREGROUND
Jan 22 00:11:34 testvm999 systemd[1]: Starting The Apache HTTP Server...
Jan 22 00:11:34 testvm999 systemd[1]: Started The Apache HTTP Server.
Jan 22 00:11:34 testvm999 httpd[2622419]: Server configured, listening on: port 80
[root@testvm999 ~]# 
[root@testvm999 ~]# systemctl restart httpd
[root@testvm999 ~]# 
[root@testvm999 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-01-22 00:11:45 GMT; 2s ago
     Docs: man:httpd.service(8)
 Main PID: 2622642 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 3927)
   Memory: 18.2M
   CGroup: /system.slice/httpd.service
           ├─2622642 /usr/sbin/httpd -DFOREGROUND
           ├─2622643 /usr/sbin/httpd -DFOREGROUND
           ├─2622644 /usr/sbin/httpd -DFOREGROUND
           ├─2622645 /usr/sbin/httpd -DFOREGROUND
           └─2622646 /usr/sbin/httpd -DFOREGROUND
Jan 22 00:11:45 testvm999 systemd[1]: Starting The Apache HTTP Server...
Jan 22 00:11:45 testvm999 systemd[1]: Started The Apache HTTP Server.
Jan 22 00:11:45 testvm999 httpd[2622642]: Server configured, listening on: port 80
[root@testvm999 ~]# 

テストページ表示

ブラウザで「http://<インストールしたサーバのIPアドレス>」にアクセスし、以下のようなテストページが表示されることを確認する。

もしテストページが表示されない場合、通信制御によりHTTPアクセスがブロックされている可能性があるため、ファイアウォール機器やサーバのfirewalld設定を見直す。

タイトルとURLをコピーしました