0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AlmaLinuxで構築するWeb3層構造:Webサーバ編(Apache httpdの導入と設定)

Posted at

1.はじめに

前回は仮想環境を構築しました。今回はWebサーバ(httpd)のインストールと基本的な設定を行います。
Apacheは最も広く利用されているWebサーバソフトウェアで、HTMLファイルの配信やリバースプロキシなど多用途に使えます。

2.環境構成と前提

ホスト名 役割 IPアドレス
webserver Webサーバ 192.168.56.10
apserver APサーバ 192.168.56.20
dbserver DBサーバ 192.168.56.30

※ AlmaLinux 9.x 、SELinux無効の状態を前提とします。

3.名前解決設定

3-1.DNS参照順設定(/etc/nsswitch.conf)

/etc/nsswitch.confファイルを編集し、名前解決の参照順を調整します。

パラメータ 設定値
passwd: files
shadow: files
group: files
hosts: files dns myhostname
services: files
netgroup: files
automount: files

hostsはfiles dns myhostnameの順にして、まず/etc/hostsを優先します。

3-2./etc/hostsに固定IPとホスト名の紐付けを記述

以下のように記述し、名前解決を行います。

192.168.56.11  dbserver
192.168.56.12  apserver
192.168.56.13  webserver

4.ファイアウォール設定

HTTPアクセスを許可します。

firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload

5.NTP設定(時刻同期)

/etc/chrony.confに以下を追記し、時刻の精度と安定性を確保します。

server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server time.google.com iburst
allow 192.168.56.0/24

6.Webサーバ構築

5-1.Apacheインストール・起動

dnf install httpd -y
systemctl start httpd
systemctl enable httpd

5-2.動作確認用のHTMLの設置

echo "Hello,World" > /var/www/html/index.html

ブラウザで確認

以下にアクセスして、Hello, Worldが表示されれば成功です。

http://<WebサーバのIPアドレス>/index.html

まとめ

Apache httpdの導入と設定が完了し、Webページの表示確認もできました。
次回はAPサーバであるTomcatを導入し、JSPページの実行環境を構築します。

本記事は「AlmaLinuxで構築するWeb3層構造」シリーズの第2弾です。
前回までの内容はこちらからどうぞ:

  • 第1回:仮想環境とAlmaLinux構築
  • 第3回:APサーバ(Tomcat)構築
  • 第4回:DBサーバ(MySQL + sakila)構築
  • 第5回:Web/AP/DB連携編
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?