Ubuntu21.04にApache2をインストールする

1.Apache httpd をインストール
root@ubuntu:~# apt -y install apache2

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
ufw (0.36-7.1) のトリガを処理しています ...
man-db (2.9.4-2) のトリガを処理しています ...
libc-bin (2.33-0ubuntu5) のトリガを処理しています ...
略 Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service. Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service. ufw (0.36-7.1) のトリガを処理しています ... man-db (2.9.4-2) のトリガを処理しています ... libc-bin (2.33-0ubuntu5) のトリガを処理しています ...
略
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
ufw (0.36-7.1) のトリガを処理しています ...
man-db (2.9.4-2) のトリガを処理しています ...
libc-bin (2.33-0ubuntu5) のトリガを処理しています ...

2.Apache httpd の設定
ディレクトリ名のみでアクセスできるファイル名を設定
root@ubuntu:~# vi /etc/apache2/mods-enabled/dir.conf

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.php
2行目 修正前 DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm 修正後 DirectoryIndex index.html index.php
2行目
修正前
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
修正後
DirectoryIndex index.html index.php

3.サーバー名を追記
root@ubuntu:~# vi /etc/apache2/apache2.conf

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
70行目
修正前
#ServerRoot "/etc/apache2"
修正後
#ServerRoot "/etc/apache2"
ServerName manage.arkgame.com
70行目 修正前 #ServerRoot "/etc/apache2" 修正後 #ServerRoot "/etc/apache2" ServerName manage.arkgame.com
70行目
修正前
#ServerRoot "/etc/apache2"
修正後
#ServerRoot "/etc/apache2"
ServerName manage.arkgame.com

4.管理者アドレスを指定
root@ubuntu:~# vi /etc/apache2/sites-enabled/000-default.conf

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
11行目
修正前
ServerAdmin webmaster@localhost
修正後
ServerAdmin contact@arkgame.com
11行目 修正前 ServerAdmin webmaster@localhost 修正後 ServerAdmin contact@arkgame.com
11行目
修正前
ServerAdmin webmaster@localhost
修正後
ServerAdmin contact@arkgame.com

5.apacheを再起動
root@ubuntu:~# systemctl restart apache2

6.動作確認
http://サーバーのホスト名(IPアドレス)

Ubuntu 21.04

Posted by arkgame