デフォルトでは以下のようにApacheは入っていないようです。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ httpd -V
-bash: httpd: command not found
dnfコマンドでApacheのバージョン等の情報を取得します。
2.4.37のようです。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ dnf info httpd
Last metadata expiration check: 5:53:12 ago on Sun 13 Feb 2022 06:10:10 PM JST.
Available Packages
Name : httpd
Version : 2.4.37
Release : 43.module_el8.5.0+2609+b30d9eec.1.alma
Architecture : x86_64
Size : 1.4 M
Source : httpd-2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma.src.rpm
Repository : appstream
Summary : Apache HTTP Server
URL : https://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
それではApacheをインストールします。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ sudo dnf install httpd
[sudo] password for hogehoge:
Last metadata expiration check: 1:27:10 ago on Sun 13 Feb 2022 10:37:04 PM JST.
Dependencies resolved.
================================================================================
Package Arch Version Repo Size
================================================================================
Installing:
httpd x86_64 2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma
appstream 1.4 M
Installing dependencies:
almalinux-logos-httpd
noarch 84.5-1.el8 appstream 29 k
apr x86_64 1.6.3-12.el8 appstream 128 k
apr-util x86_64 1.6.1-6.el8 appstream 105 k
httpd-filesystem noarch 2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma
appstream 39 k
httpd-tools x86_64 2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma
appstream 106 k
mod_http2 x86_64 1.15.7-3.module_el8.5.0+2609+b30d9eec appstream 153 k
Installing weak dependencies:
apr-util-bdb x86_64 1.6.1-6.el8 appstream 24 k
apr-util-openssl x86_64 1.6.1-6.el8 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
Is this ok [y/N]: y
Downloading Packages:
(1/9): almalinux-logos-httpd-84.5-1.el8.noarch. 402 kB/s | 29 kB 00:00
(2/9): apr-util-1.6.1-6.el8.x86_64.rpm 1.4 MB/s | 105 kB 00:00
(3/9): apr-1.6.3-12.el8.x86_64.rpm 1.2 MB/s | 128 kB 00:00
(4/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm 918 kB/s | 27 kB 00:00
(5/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm 595 kB/s | 24 kB 00:00
(6/9): httpd-filesystem-2.4.37-43.module_el8.5. 1.8 MB/s | 39 kB 00:00
(7/9): httpd-tools-2.4.37-43.module_el8.5.0+260 1.7 MB/s | 106 kB 00:00
(8/9): mod_http2-1.15.7-3.module_el8.5.0+2609+b 2.6 MB/s | 153 kB 00:00
(9/9): httpd-2.4.37-43.module_el8.5.0+2609+b30d 8.6 MB/s | 1.4 MB 00:00
--------------------------------------------------------------------------------
Total 1.6 MB/s | 2.0 MB 00:01
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-43.module_el8.5.0+2609+b30d9eec.1 5/9
Running scriptlet: httpd-filesystem-2.4.37-43.module_el8.5.0+2609+b30d9 6/9
Installing : httpd-filesystem-2.4.37-43.module_el8.5.0+2609+b30d9 6/9
Installing : almalinux-logos-httpd-84.5-1.el8.noarch 7/9
Installing : mod_http2-1.15.7-3.module_el8.5.0+2609+b30d9eec.x86_ 8/9
Installing : httpd-2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma. 9/9
Running scriptlet: httpd-2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma. 9/9
Verifying : almalinux-logos-httpd-84.5-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-43.module_el8.5.0+2609+b30d9eec.1.alma. 6/9
Verifying : httpd-filesystem-2.4.37-43.module_el8.5.0+2609+b30d9 7/9
Verifying : httpd-tools-2.4.37-43.module_el8.5.0+2609+b30d9eec.1 8/9
Verifying : mod_http2-1.15.7-3.module_el8.5.0+2609+b30d9eec.x86_ 9/9
Installed:
almalinux-logos-httpd-84.5-1.el8.noarch
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-43.module_el8.5.0+2609+b30d9eec.1.alma.x86_64
httpd-filesystem-2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma.noarch
httpd-tools-2.4.37-43.module_el8.5.0+2609+b30d9eec.1.alma.x86_64
mod_http2-1.15.7-3.module_el8.5.0+2609+b30d9eec.x86_64
Complete!
インストールしたので、バージョンを確認します。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ httpd -V
Server version: Apache/2.4.37 (AlmaLinux)
Server built: Jan 25 2022 20:48:49
Server's Module Magic Number: 20120211:83
Server loaded: APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
サービスの状態を確認します。
まだサービスはスタートしていない状態。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor pres>
Active: inactive (dead)
Docs: man:httpd.service(8)
以下のコマンドでApacheサービスをスタートします。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ sudo systemctl start httpd
[sudo] password for hogehoge:
確認すると、以下のようにactive状態になりました。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor pres>
Active: active (running) since Mon 2022-02-14 00:11:58 JST; 4s ago
Docs: man:httpd.service(8)
Main PID: 28621 (httpd)
Status: "Started, listening on: port 80"
Tasks: 213 (limit: 4957)
Memory: 39.3M
CGroup: /system.slice/httpd.service
tq28621 /usr/sbin/httpd -DFOREGROUND
tq28622 /usr/sbin/httpd -DFOREGROUND
tq28623 /usr/sbin/httpd -DFOREGROUND
tq28624 /usr/sbin/httpd -DFOREGROUND
mq28625 /usr/sbin/httpd -DFOREGROUND
Feb 14 00:11:58 xxx-xxx-xxx-xxx systemd[1]: Starting The Apache HTTP Server...
Feb 14 00:11:58 xxx-xxx-xxx-xxx httpd[28621]: AH00558: httpd: Could not reliably d>
Feb 14 00:11:58 xxx-xxx-xxx-xxx systemd[1]: Started The Apache HTTP Server.
Feb 14 00:11:58 xxx-xxx-xxx-xxx httpd[28621]: Server configured, listening on: por>
常にApacheサービスを起動するよう設定します。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
次にfirewalldの確認をします。sshはポート開放されていますが、httpdがポート開放されていません。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ sudo firewall-cmd --list-all
[sudo] password for comicranking:
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
forward: no
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
では、firewalldのhttpdポートを開放し、設定を反映させます。
command
[hogehoge@xxx-xxx-xxx-xxx ~]$ sudo firewall-cmd --zone=public --add-service=http --permanent
success
[hogehoge@xxx-xxx-xxx-xxx ~]$ sudo firewall-cmd --reload
success
ブラウザからIPアドレスを指定すると、下記のようにWebページが表示されます。