Ubuntu 21.10にApache2をインストールする

OSバージョンの確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.10
Release: 21.10
Codename: impish
# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 21.10 Release: 21.10 Codename: impish
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.10
Release: 21.10
Codename: impish

1.Apache をインストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# apt -y install apache2
バージョンの確認
# apache2 -v
Server version: Apache/2.4.48 (Ubuntu)
Server built: 2021-09-28T12:52:26
# apt -y install apache2 バージョンの確認 # apache2 -v Server version: Apache/2.4.48 (Ubuntu) Server built: 2021-09-28T12:52:26
# apt -y install apache2
バージョンの確認
# apache2 -v
Server version: Apache/2.4.48 (Ubuntu)
Server built: 2021-09-28T12:52:26

2.httpdの設定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# vi /etc/apache2/conf-enabled/security.conf
25行目
修正前
ServerTokens OS
修正後
ServerTokens Prod
# vi /etc/apache2/conf-enabled/security.conf 25行目 修正前 ServerTokens OS 修正後 ServerTokens Prod
# vi /etc/apache2/conf-enabled/security.conf
25行目
修正前
ServerTokens OS
修正後
ServerTokens Prod

3.ディレクト名のみでアクセスできるファイル名を設定する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
2行目
修正前
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
修正後
DirectoryIndex index.html index.htm
2行目 修正前 DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm 修正後 DirectoryIndex index.html index.htm
2行目
修正前
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
修正後
DirectoryIndex index.html index.htm

4.サーバー名を追加

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# vi /etc/apache2/apache2.conf
70行目
ServerName www.xxx.com
管理者メールアドレスを変更
# vi /etc/apache2/sites-enabled/000-default.conf
修正前
ServerAdmin webmaster@localhost
修正後
ServerAdmin contact@xxx.com
# vi /etc/apache2/apache2.conf 70行目 ServerName www.xxx.com 管理者メールアドレスを変更 # vi /etc/apache2/sites-enabled/000-default.conf 修正前 ServerAdmin webmaster@localhost 修正後 ServerAdmin contact@xxx.com
# vi /etc/apache2/apache2.conf
70行目
ServerName www.xxx.com

管理者メールアドレスを変更
# vi /etc/apache2/sites-enabled/000-default.conf
修正前
ServerAdmin webmaster@localhost
修正後
ServerAdmin contact@xxx.com

5.apache2を再起動
# systemctl restart apache2

6.アプリケーションプロファイルを一覧表示

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo ufw app list
利用可能なアプリケーション:
Apache
Apache Full
Apache Secure
CUPS
OpenSSH
Squid
# sudo ufw app list 利用可能なアプリケーション: Apache Apache Full Apache Secure CUPS OpenSSH Squid
# sudo ufw app list
利用可能なアプリケーション:
Apache
Apache Full
Apache Secure
CUPS
OpenSSH
Squid

ポート80のトラフィックを許可

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo ufw allow 'Apache'
ルールをアップデートしました
ルールをアップデートしました(v6)
# sudo ufw allow 'Apache' ルールをアップデートしました ルールをアップデートしました(v6)
# sudo ufw allow 'Apache'
ルールをアップデートしました
ルールをアップデートしました(v6)

Webサーバーの確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
Active: active (running) since Sat 2021-10-23 03:38:33 PDT; 13min ago
# sudo systemctl status apache2 ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese> Active: active (running) since Sat 2021-10-23 03:38:33 PDT; 13min ago
# sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
Active: active (running) since Sat 2021-10-23 03:38:33 PDT; 13min ago

 

Ubuntu 21.10

Posted by arkgame