CentOS 8.5にApache httpd をインストールする

2021年12月22日

環境
# cat /etc/redhat-release
CentOS Linux release 8.5.2111

インストールの方法
1.httpd をインストールします
# dnf -y install httpd httpd-tools httpd-devel httpd-manual

2.バージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# httpd -V
Server version: Apache/2.4.37 (centos)
Server built: Nov 12 2021 04:57:27
# httpd -V Server version: Apache/2.4.37 (centos) Server built: Nov 12 2021 04:57:27
# httpd -V
Server version: Apache/2.4.37 (centos)
Server built:   Nov 12 2021 04:57:27

3.HTTP サービスを許可します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# firewall-cmd --add-service=http --permanent
success
# firewall-cmd --reload
success
# firewall-cmd --add-service=http --permanent success # firewall-cmd --reload success
# firewall-cmd --add-service=http --permanent
success
# firewall-cmd --reload
success

4.配置ファイルを設定します

# vi /etc/httpd/conf/httpd.conf
89行目
修正前
ServerAdmin root@localhost
修正後
ServerAdmin 管理者メールアドレス

98行目
修正前
#ServerName www.example.com:80
修正後
ServerName サーバー名

147行目
修正前
Options Indexes FollowSymLinks
修正後
Options FollowSymLinks

154行目
修正前
AllowOverride None

修正後
AllowOverride All

167行目
修正前
DirectoryIndex index.html

修正後
DirectoryIndex index.html index.php

最終行に追記
ServerTokens Prod

5.httdを起動します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# systemctl enable --now httpd
# systemctl enable --now httpd
# systemctl enable --now httpd

 

CentOS8

Posted by arkgame