Web サーバの構築(1)apache のインストールとセットアップ

AWS Debian

DNS サーバで身元保証ができ、メールサーバで連絡先の確保ができたので、
次は自己主張のため(笑)の Web サーバを構築する。

apache のインストール

yasunari@aws:~$ sudo apt-get install apache2
[sudo] password for yasunari:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap liblua5.2-0 ssl-cert
Suggested packages:
  www-browser apache2-doc apache2-suexec-pristine | apache2-suexec-custom openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap liblua5.2-0 ssl-cert
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,144 kB of archives.
After this operation, 7,137 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
	:
	:
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.
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for systemd (232-25+deb9u1) ...
yasunari@aws:~$

シンボリックリンク

自宅サーバは、Vine だった頃の名残で /home/httpd/{html|cgi-bin} に依存する箇所がある。
シンボリックリンクを張る。
yasunari@aws:~$ sudo -i
root@aws:~# mkdir /home/httpd
root@aws:~# ls /var/www/html
index.html
root@aws:~# ln -s /var/www/html /home/httpd
root@aws:~# ls /usr/lib/cgi-bin/
root@aws:~# ln -s !$ /home/httpd
ln -s /usr/lib/cgi-bin/ /home/httpd
root@aws:~# ls -l /home/httpd/
total 0
lrwxrwxrwx 1 root root 17 Dec 27 19:21 cgi-bin -> /usr/lib/cgi-bin/
lrwxrwxrwx 1 root root 13 Dec 27 19:20 html -> /var/www/html
root@aws:~#

ポート開放

セキュリティグループに HTTP を追加する

アクセスしてみる

ブラウザからアクセスしてみる

It Works!

グループの設定

html と cgi-bin へ www-data グループから書けるようにし、
yasunari を www-data グループに所属させる。
ちょっと強引
root@aws:~# chgrp www-data /usr/lib/cgi-bin /var/www/html
root@aws:~# chmod g+ws /usr/lib/cgi-bin/ /var/www/html/
root@aws:~# ls -ld /usr/lib/cgi-bin/ /var/www/html/
drwxrwsr-x 2 root www-data 4096 Sep 20 03:58 /usr/lib/cgi-bin/
drwxrwsr-x 2 root www-data 4096 Dec 27 19:18 /var/www/html/
root@aws:~# addgroup yasunari www-data
Adding user `yasunari' to group `www-data' ...
Adding user yasunari to group www-data
Done.
root@aws:~# rm /var/www/html/index.html
root@aws:~#

自宅サーバからコンテンツのコピー

yasunari@xhl:~$ cd /home/httpd/html
yasunari@xhl:/home/httpd/html$ rsync -rtuvpogtlH --timeout=360 -e "ssh -p 内緒 -i /home/yamasita/yasunari/.ssh/aws1.pem" index.html aws.yamasita.jp:/var/www/html
sending incremental file list
index.html

sent 7810 bytes  received 31 bytes  5227.33 bytes/sec
total size is 7712  speedup is 0.98
yasunari@xhl:/home/httpd/html$
などなど。略

再度ブラウザからアクセス

見慣れた景色が!!

DNS への登録変更

www.yamasita.jp を aws.yamasita.jp の別名とする。
www    IN      CNAME   aws.yamasita.jp.
bind の再起動。

これで www.yamasita.jp は雲の上へ



メールサーバの構築(4)alias の設定
山下康成の
雲の上

Web サーバの構築(2)Movable Type のインストール

Copyright (C) 2003-2018 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市/東京都新宿区