Raspberry PiにRDPで接続する

リファレンス

手順

  • xrdpをインストール
$ sudo apt install xrdp
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  xorgxrdp
提案パッケージ:
  guacamole xrdp-pulseaudio-installer
以下のパッケージが新たにインストールされます:
  xorgxrdp xrdp
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。
452 kB のアーカイブを取得する必要があります。
この操作後に追加で 2,716 kB のディスク容量が消費されます。
続行しますか? [Y/n] 
取得:1 http://ports.ubuntu.com bionic/universe armhf xorgxrdp armhf 0.9.5-2 [68.3 kB]
取得:2 http://ports.ubuntu.com bionic/universe armhf xrdp armhf 0.9.5-2 [384 kB]
452 kB を 4秒 で取得しました (109 kB/s)
以前に未選択のパッケージ xorgxrdp を選択しています。
(データベースを読み込んでいます ... 現在 141558 個のファイルとディレクトリがインストールされています。)
.../xorgxrdp_0.9.5-2_armhf.deb を展開する準備をしています ...
xorgxrdp (0.9.5-2) を展開しています...
以前に未選択のパッケージ xrdp を選択しています。
.../xrdp_0.9.5-2_armhf.deb を展開する準備をしています ...
xrdp (0.9.5-2) を展開しています...
libc-bin (2.27-3ubuntu1) のトリガを処理しています ...
xrdp (0.9.5-2) を設定しています ...

Generating 2048 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

Created symlink /etc/systemd/system/multi-user.target.wants/xrdp-sesman.service → /lib/systemd/system/xrdp-sesman.service.
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /lib/systemd/system/xrdp.service.
systemd (237-3ubuntu10.22) のトリガを処理しています ...
man-db (2.8.3-2ubuntu0.1) のトリガを処理しています ...
xorgxrdp (0.9.5-2) を設定しています ...
libc-bin (2.27-3ubuntu1) のトリガを処理しています ...
  • xrdpを起動
$ sudo service xrdp restart
  • Windowsでrdpのクライアントを起動
    • 名前を指定して実行 -> mstsc

f:id:cutxout:20190617232527j:plain
f:id:cutxout:20190617232529j:plain
f:id:cutxout:20190617232531j:plain

  • キーボードレイアウトの調整方法

ハイパー日記システムのインストール

手順

$ sudo a2enmod cgi
Enabling module cgi.
To activate the new configuration, you need to run:
  systemctl restart apache2

$ sudo a2enmod cgid
Enabling module cgid.
To activate the new configuration, you need to run:
  systemctl restart apache2

$ sudo apachectl graceful
  • nkfをインストール(依存関係)
$ sudo apt install nkf
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
  nkf
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
126 kB のアーカイブを取得する必要があります。
この操作後に追加で 283 kB のディスク容量が消費されます。
取得:1 http://ports.ubuntu.com bionic/universe armhf nkf armhf 1:2.1.4-1ubuntu2 [126 kB]
126 kB を 2秒 で取得しました (69.6 kB/s)
以前に未選択のパッケージ nkf を選択しています。
(データベースを読み込んでいます ... 現在 141534 個のファイルとディレクトリがインストールされています。)
.../nkf_1%3a2.1.4-1ubuntu2_armhf.deb を展開する準備をしています ...
nkf (1:2.1.4-1ubuntu2) を展開しています...
nkf (1:2.1.4-1ubuntu2) を設定しています ...
man-db (2.8.3-2ubuntu0.1) のトリガを処理しています ...
  • makeをインストール(依存関係)
$ sudo apt install make
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
提案パッケージ:
  make-doc
以下のパッケージが新たにインストールされます:
  make
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
142 kB のアーカイブを取得する必要があります。
この操作後に追加で 303 kB のディスク容量が消費されます。
取得:1 http://ports.ubuntu.com bionic/main armhf make armhf 4.1-9.1ubuntu1 [142 kB]
142 kB を 2秒 で取得しました (58.4 kB/s)
以前に未選択のパッケージ make を選択しています。
(データベースを読み込んでいます ... 現在 141542 個のファイルとディレクトリがインストールされています。)
.../make_4.1-9.1ubuntu1_armhf.deb を展開する準備をしています ...
make (4.1-9.1ubuntu1) を展開しています...
make (4.1-9.1ubuntu1) を設定しています ...
man-db (2.8.3-2ubuntu0.1) のトリガを処理しています ...
$ mkdir ~/diary   #日記を収納するフォルダ
$ mkdir ~/public_html/diary   #cgiスクリプトをインストールするフォルダ
  • hns-2.19.9.tar.gzをダウンロードして展開する
$ cd hns-2.19.9/
$ sh hns-setup.ja

# 以後、対話型シェルに従ってインストールを進める
  • インストール完了。しかし、ダメだった。orz

f:id:cutxout:20190615184641j:plain

原因の切り分け

$ tail -f /var/log/apache2/error.log

[Sat Jun 15 18:40:13.087682 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at lib/ObjectTemplate.pm line 68.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.087997 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: Compilation failed in require at lib/DateTime/Date.pm line 14.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.088134 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: BEGIN failed--compilation aborted at lib/DateTime/Date.pm line 14.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.088323 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: Compilation failed in require at lib/DateTime/Time.pm line 13.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.088647 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: BEGIN failed--compilation aborted at lib/DateTime/Time.pm line 13.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.088760 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: Compilation failed in require at lib/DateTime/Format.pm line 6.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.088890 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: BEGIN failed--compilation aborted at lib/DateTime/Format.pm line 6.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.089096 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: Compilation failed in require at /home/cutxout/public_html/diary/index.cgi line 32.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.089281 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] AH01215: BEGIN failed--compilation aborted at /home/cutxout/public_html/diary/index.cgi line 32.: /home/cutxout/public_html/diary/index.cgi, referer: http://192.168.100.4/index2.html
[Sat Jun 15 18:40:13.089420 2019] [cgi:error] [pid 4666] [client 192.168.100.2:63976] End of script output before headers: index.cgi, referer: http://192.168.100.4/index2.html
  • error.logを見ると、2種類のエラーが混ざっているように見える。
    • Can't use 'defined(@array)' (Maybe you should just omit the defined()?)
    • Compilation failed in require at lib/DateTime/Date.pm line 14
  • 前者は、perl 5.20でdefined()の仕様変更があったことに起因する。
defined(@array) と defined(%hash) は致命的エラーになりました
これは v5.6.1 から廃止予定で、v5.16 から廃止予定警告が出力されていました。
Can't use 'defined(@array)' (Maybe you should just omit the defined()?)

(F) defined() は配列に使っても有用ではありません; 未定義の スカラ 値を チェックするからです。 配列が空かどうかを知りたい場合は、例えば単に if (@array) { # not empty } を 使ってください。
  • それを踏まえて、lib/ObjectTemplate.pmの68行目を確認してみる。
sub get_attribute_names {
    my $pkg = shift;
    $pkg = ref($pkg) if ref($pkg);
    my @result = @{"${pkg}::_ATTRIBUTES_"};
    if (defined (@{"${pkg}::ISA"})) {
        foreach my $base_pkg (@{"${pkg}::ISA"}) {
           push (@result, get_attribute_names($base_pkg));
        }
    }
    @result;
}
  • 原因はこれか!
#    if (defined (@{"${pkg}::ISA"})) {
#    if (defined (@{"${pkg}::ISA"})) {
#    if (defined (@{"${pkg}::ISA"})) {
  • 手作業で修正を試みる。
#    if (defined (@{"${pkg}::ISA"})) {
      if (@{"${pkg}::ISA"}) {
  • ビンゴ!しかし、その修正は次のエラーを呼ぶことに。orz
[Sat Jun 15 19:33:37.068314 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: Can't use 'defined(%hash)' (Maybe you should just omit the defined()?) at lib/jcode.pl line 684.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.068672 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: Compilation failed in require at lib/CodeConv.pm line 61.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.068787 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: BEGIN failed--compilation aborted at lib/CodeConv.pm line 64.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.068937 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: Compilation failed in require at lib/HNS/Diary.pm line 30.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.069103 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: BEGIN failed--compilation aborted at lib/HNS/Diary.pm line 30.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.069247 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: Compilation failed in require at lib/HNS/Collection.pm line 26.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.069448 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: BEGIN failed--compilation aborted at lib/HNS/Collection.pm line 26.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.069747 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: Compilation failed in require at lib/HNS/Calendar/Table.pm line 32.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.069894 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: BEGIN failed--compilation aborted at lib/HNS/Calendar/Table.pm line 32.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.070112 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: Compilation failed in require at lib/HNS.pm line 32.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.070273 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: BEGIN failed--compilation aborted at lib/HNS.pm line 32.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.070478 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: Compilation failed in require at /home/cutxout/public_html/diary/index.cgi line 35.: /home/cutxout/public_html/diary/index.cgi
[Sat Jun 15 19:33:37.070632 2019] [cgi:error] [pid 5148] [client 192.168.100.2:64257] AH01215: BEGIN failed--compilation aborted at /home/cutxout/public_html/diary/index.cgi line 35.: /home/cutxout/public_html/diary/index.cgi
  • defined()の誤った使い方をしているらしき箇所を調べると23件ヒットする。正確には、配列@とハッシュ%に限定してよいはずだから、もうちょっと減るだろう。あれ、jcodeも対象なのか。しかも、jcode.pmではなくてjcode.plかよ!これだったら、誰かがパッチあてたバージョンを公開している気がする。
$ grep -r "defined *(" ./diary/ 
./diary/i/index.cgi:    if (!defined(&main::nkf)) {
./diary/lib/HNS/Hnf/Command.pm:    } elsif ($$attr =~ /^([\d\w-]+):/ && defined($Template{$1})) {
./diary/lib/HNS/Tools/Title.pm: if (defined($value)) {
./diary/lib/HNS/Tools/Title.pm:    if (defined(@Selected)) { # ?2001, ?200105, ?2001050, ?200105a
./diary/lib/HNS/Tools/Title.pm:    if (defined($Selected{YEAR})) { # YEAR=2001&MONTH=5
./diary/lib/HNS/Tools/Title.pm:     if (defined($Selected{MONTH}) && $Selected{MONTH}->[0] ne "ALL") {
./diary/lib/HNS/Tools/Title.pm:             if (defined($Selected{DAY}) &&
./diary/lib/HNS/Tools/Title.pm:    if (defined(%selected_cat)) {
./diary/lib/HNS/Diary.pm:       if (defined($value)) {
./diary/lib/HNS/Diary.pm:           if (defined($cat_selected{"ALL"})) {
./diary/lib/HNS/Diary.pm:                   if (defined($cat_selected{$cat})) {
./diary/lib/HNS/Diary.pm:       if ($flg_display || defined($cat_selected{"ALL"})) {
./diary/lib/Board/System.pm:    $refid_hash->{$article->refid} = [] unless (defined($refid_hash->{$article->refid}));
./diary/lib/Board/Article.pm:    if (defined($msgid_hash) && defined($refid_hash)) {
./diary/lib/ObjectTemplate.pm:    if (defined (@{"${pkg}::ISA"})) {
./diary/lib/ObjectTemplate.pm:            if (defined(\$_free[\$_free])) {
./diary/lib/jcode.pl:;# while (defined($s = <>)) {
./diary/lib/jcode.pl:;# while (defined($s = <>)) {
./diary/lib/jcode.pl:;#     defined(&f) || next;
./diary/lib/jcode.pl:;# while (defined($s = <>)) {
./diary/lib/jcode.pl:;#     while (defined($s = shift(@buf))) {
./diary/lib/jcode.pl:;#     while (defined($s = <>)) {
./diary/lib/jcode.pl:    if (!defined($prev_from) || $from ne $prev_from || $to ne $prev_to) {
./diary/lib/jcode.pl:   defined($table{$1}) && ++$n ? $table{$1} : $1
  • 後者のエラーは、use文を辿ってみるとDateTime系のモジュールからObjectTemplate.pmを呼び出すところに帰着するので、一つ目のエラーと根は同じだと思われる。

対応方針を検討

  • 覚悟を決めて、自力でパッチをあてていく。
  • 最新のCPANモジュールをシステムレベルでインストールして、そちらを読み込む
    • ローカル側の*.cgiをuse lib qw(lib);を削除して、代わりにuse ###を追加していくことになるのか?
  • 最新のCPANモジュールをダウンロードして、lib配下の古いモジュールと置き換える
    • 単純に数えて92ファイル。古いものばかりで、おまけに独自実装らしきものもある。
    • 置き換えただけで本当に動作するかは甚だあやしい。
$ ls -lR
.:
total 92
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 Board
-rw-r--r-- 1 cutxout cutxout  4835  4月  6  2002 Board.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 CGI
-rw-r--r-- 1 cutxout cutxout  4160  5月 30  2003 CodeConv.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 DateTime
drwxr-xr-x 7 cutxout cutxout  4096 11月  5  2006 HNS
-rw-r--r-- 1 cutxout cutxout  8481 11月  5  2006 HNS.pm
-rw-r--r-- 1 cutxout cutxout  2389 12月  7  2000 HTTP.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 Image
-rw-r--r-- 1 cutxout cutxout  2233 12月  7  2000 LIRS.pm
-rwxr--r-- 1 cutxout cutxout  4216  6月 15 19:34 ObjectTemplate.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 SimpleDB
-rw-r--r-- 1 cutxout cutxout 21093 10月 14  2000 jcode.pl

./Board:
total 16
-rw-r--r-- 1 cutxout cutxout 5987  4月  6  2002 Article.pm
-rw-r--r-- 1 cutxout cutxout 6887  5月 28  2003 System.pm

./CGI:
total 12
-rw-r--r-- 1 cutxout cutxout 2399 11月 24  1999 Cookie.pm
-rw-r--r-- 1 cutxout cutxout 1328 11月 24  1999 QueryString.pm
-rw-r--r-- 1 cutxout cutxout  825  2月  2  2002 Tools.pm

./DateTime:
total 20
-rw-r--r-- 1 cutxout cutxout 5347  7月 21  2000 Date.pm
-rw-r--r-- 1 cutxout cutxout 1006  5月  1  1999 Format.pm
-rw-r--r-- 1 cutxout cutxout  606 11月  3  2002 Qreki.pm
-rw-r--r-- 1 cutxout cutxout 1383 11月 24  1999 Time.pm

./HNS:
total 112
-rw-r--r-- 1 cutxout cutxout  4701  1月  7  2001 AccessControl.pm
-rw-r--r-- 1 cutxout cutxout  3134  9月 30  2001 Admini.pm
-rw-r--r-- 1 cutxout cutxout  4161  2月  3  2002 Cache.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 Calendar
-rw-r--r-- 1 cutxout cutxout  2204  4月 15  2001 CategoryList.pm
-rw-r--r-- 1 cutxout cutxout 10574 11月 22  2003 Collection.pm
-rw-r--r-- 1 cutxout cutxout  2718 11月 24  1999 DateSelect.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 Diary
-rw-r--r-- 1 cutxout cutxout 13253  1月  6  2005 Diary.pm
-rw-r--r-- 1 cutxout cutxout  1057  4月 15  2001 ExtHTML.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 Hnf
-rw-r--r-- 1 cutxout cutxout  5939  8月 21  2005 IntelliSearch.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 PIM
-rw-r--r-- 1 cutxout cutxout  6020  9月 15  2001 Status.pm
-rw-r--r-- 1 cutxout cutxout  6494 11月  3  2002 Style.pm
-rw-r--r-- 1 cutxout cutxout  1761  3月 29  2002 System.pm
-rw-r--r-- 1 cutxout cutxout  1500 11月 24  1999 Template.pm
drwxr-xr-x 2 cutxout cutxout  4096 11月  5  2006 Tools

./HNS/Calendar:
total 20
-rw-r--r-- 1 cutxout cutxout  886 10月  5  2002 Direct.pm
-rw-r--r-- 1 cutxout cutxout 4404 11月  3  2002 NoTable.pm
-rw-r--r-- 1 cutxout cutxout 5383 11月  3  2002 Table.pm

./HNS/Diary:
total 4
-rw-r--r-- 1 cutxout cutxout 2377 11月 15  2001 Template.pm

./HNS/Hnf:
total 56
-rw-r--r-- 1 cutxout cutxout 35070 10月  4  2005 Command.pm
-rw-r--r-- 1 cutxout cutxout 11394  6月 19  2002 TreeBuilder.pm
-rw-r--r-- 1 cutxout cutxout  2037 10月 21  2000 UserVar.pm
-rw-r--r-- 1 cutxout cutxout  1557  7月 24  2000 Warning.pm

./HNS/PIM:
total 28
-rw-r--r-- 1 cutxout cutxout  2437  5月 28  2003 Link.pm
-rw-r--r-- 1 cutxout cutxout 20354 10月 28  2003 Schedule.pm
-rw-r--r-- 1 cutxout cutxout  1822  5月 28  2003 Todo.pm

./HNS/Tools:
total 32
-rw-r--r-- 1 cutxout cutxout  5231 11月 15  2001 HeadLine.pm
-rw-r--r-- 1 cutxout cutxout  6484  4月 25  2005 RSS.pm
-rw-r--r-- 1 cutxout cutxout 15266  5月 28  2003 Title.pm

./Image:
total 4
-rw-r--r-- 1 cutxout cutxout 3124  3月 18  2000 Size.pm

./SimpleDB:
  • perl 5.20より前のバージョンのperlをインストールして、共存させる or 置き換える。
    • hns的にはperl 5.004が要求仕様で、defined()の仕様変更があったのがperl 5.20なので、perl 5.19系列の採取バージョンが狙い目。
    • 実現できるならこれが手っ取り早そうだけど、そんなことできるのだろうか?

Apache 2.4 on Ubuntuの設定

目的

Apacheの設定ファイルの構成

apache2.confの記載

  • The configuration layout for an Apache2 web server installation on Ubuntu systems is as follows:
/etc/apache2/
|-- apache2.conf
|       `--  ports.conf
|-- mods-enabled
|       |-- *.load
|       `-- *.conf
|-- conf-enabled
|       `-- *.conf
|-- sites-enabled
|       `-- *.conf
  • apache2.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server.
  • ports.conf is always included from the main configuration file. It is used to determine the listening ports for incoming connections, and this file can be customized anytime.
  • Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ directories contain particular configuration snippets which manage modules, global configuration fragments, or virtual host configurations, respectively.
  • They are activated by symlinking available configuration files from their respective *-available/ counterparts. These should be managed by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and a2enconf, a2disconf . See their respective man pages for detailed information.
  • The binary is called apache2. Due to the use of environment variables, in the default configuration, apache2 needs to be started/stopped with /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not work with the default configuration.

サマリー

  • apache2.conf
    • Webサーバとしての基本設定
    • 非公開の自宅サーバなら変更不要と考えてよし
  • ports.conf
    • ポートの設定
    • 標準のhttp/80とhttps/443でよいなら変更不要
  • conf-availableとconf-enabled
    • conf-availableが、設定ファイル置き場(雛形と設定を兼ねる)
    • conf-enabledが、有効化した設定ファイル置き場(conf-availableに対するsymbolic link)
    • 設定ファイルの有効化と無効化は、a2enconfとa2disconfで変更する
  • site-availableとsite-enabled
    • site-availableが、仮想ホストの設定置き場
    • site-enabledが、有効化した仮想ホストの設定ファイル置き場site-availableに対するsymblic link)
    • 設定ファイルの有効化と無効化は、a2ensiteとa2dissiteで変更する
  • mods-availableとmods-enabled
    • mods-availableが、利用可能なモジュール置き場
    • mods-enabledが、有効化したモジュール(mods-availableに対するsymbolic link)
    • モジュールの有効化と無効化は、a2enmodとa2dismodで変更する

Apache2起動時のAH00558エラー

  • Apache2を起動する時にAH00558エラーが表示される。ホスト名の定義に関するエラーで、実用上の問題はなさそうだが、気持ち悪いので対応しておくことに。
$ sudo apachectl graceful
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
  • ホスト名を確認
$ hostname
rp3
  • /etc/apache2/conf-available/fqdn.confにホスト名を記載する
$ cd /etc/apache2/conf-available/
$ sudo touch fqdn.conf
$ cat fqdn.conf 
ServerName rp3
$ sudo a2enconf fqdn
$ sudo apachectl graceful
$ sudo apachectl graceful

php(pukiwiki)

  • php自体の動作確認はできているので、コンテンツとしてのpukiwikiが動作するかどうか。
  • 何も考えずにpukiwikiにアクセスすると、phpのエラーが発生して動作しない。原因は、PHP5 -> PHP7へのアップグレードで、オブジェクトの渡し方に関するsyntaxが変更になったことに起因するようだ。ならば、pukiwikiを最新版にアップグレードすれば解決するはず。
[Sat Jun 15 20:20:28.888350 2019] [php7:emerg] [pid 5149] [client 192.168.100.2:64541] PHP Parse error:  syntax error, unexpected 'new' (T_NEW) in /home/cutxout/public_html/wiki/lib/func.php on line 463, referer: http://192.168.100.4/index2.html
  • pukiwiki公式サイトのアップグレード手順に沿ってデータを移行して、無事に動くことを確認。動作もこころなしかきびきびしている気がする。
  • ここで気づいたのが、文字コードをどうするか問題。当時のコンテンツはeucで構成されているが、今の主流はutf-8で公式サイトもこちらを推奨している。今のところeuc版も提供されているが、これを機にutf-8に移行してしまうのがよさそうである。

pukiwikieucからutf-8へ移行

  • utf-8版を展開してリネーム
$ unzip pukiwiki-1.5.2_utf8.zip
$ mv pukiwiki-1.5.2_utf8 wiki8
  • コンテンツをコピー
$ cp -R wiki/attach/* wiki8/attach/
$ cp -R wiki/backup/* wiki8/backup/
$ cp -R wiki/cache/* wiki8/cache/
$ cp -R wiki/wiki/* wiki8/wiki/
  • 文字コードeucからutf-8に一括変換
    • ここで躓いてしまった。nkf、convertcode.inc.php、data2utf8.phpなどのツールを試してみたのだが、いずれもうまく行かない。

cgiの環境構築

$ cat /etc/apache2/sites-available/rp3.conf 
<VirtualHost *:80>
        ServerName www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /home/cutxout/public_html

        DirectoryIndex index.html index.html.var index.cgi index.php
        AddHandler cgi-script .cgi .pl

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Directory "/home/cutxout/public_html">
                Require all granted
                Options +ExecCGI
        </Directory>

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  • テストコードで動作確認
$ cat test.cgi 
#!/usr/bin/perl

print "Content-type: text/html\n\n";
print '<html>';
print "<body>&nbsp;<p><h1>GCI with Perl</h1>";
print "CGI with Perl is ready ...</body></html>";

感想

  • ここでの最終目標はハイパー日記システムのインストールだったけど、トラブル続きで一筋縄ではいかなそうな気がするので、別ページにまとめることにしましょう。
  • 最近のLinuxの環境構築はとてもよくできていて、個別にソースコードからコンパイルしていた頃とは隔絶の差ですね。ほぼデフォルトでここまで動いていて、苦労しているのはレガシーをなんとかしようとしているからと言う自業自得以外何物でもないわけで。

Ubuntu MATE (18.04.2) にTaskselとLAMP環境をインストール

手順

  • Taskselをインストール
$sudo apt install tasksel
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが自動でインストールされましたが、もう必要とされていません:
  apt-clone archdetect-deb cryptsetup-bin dpkg-repack gir1.2-json-1.0 gir1.2-nm-1.0 gir1.2-nma-1.0 gir1.2-timezonemap-1.0 gir1.2-xkl-1.0 grub-common
  libdebian-installer4 libtimezonemap-data libtimezonemap1 os-prober python3-icu python3-pam rdate
これを削除するには 'sudo apt autoremove' を利用してください。
以下の追加パッケージがインストールされます:
  tasksel-data
以下のパッケージが新たにインストールされます:
  tasksel tasksel-data
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。
34.2 kB のアーカイブを取得する必要があります。
この操作後に追加で 292 kB のディスク容量が消費されます。
続行しますか? [Y/n] 
取得:1 http://ports.ubuntu.com bionic/main armhf tasksel-data all 3.34ubuntu11 [5,476 B]
取得:2 http://ports.ubuntu.com bionic/main armhf tasksel all 3.34ubuntu11 [28.7 kB]
34.2 kB を 2秒 で取得しました (18.3 kB/s)
パッケージを事前設定しています ...
以前に未選択のパッケージ tasksel-data を選択しています。
(データベースを読み込んでいます ... 現在 140635 個のファイルとディレクトリがインストールされています。)
.../tasksel-data_3.34ubuntu11_all.deb を展開する準備をしています ...
tasksel-data (3.34ubuntu11) を展開しています...
以前に未選択のパッケージ tasksel を選択しています。
.../tasksel_3.34ubuntu11_all.deb を展開する準備をしています ...
tasksel (3.34ubuntu11) を展開しています...
menu (2.1.47ubuntu2.1) のトリガを処理しています ...
man-db (2.8.3-2ubuntu0.1) のトリガを処理しています ...
tasksel-data (3.34ubuntu11) を設定しています ...
tasksel (3.34ubuntu11) を設定しています ...
menu (2.1.47ubuntu2.1) のトリガを処理しています ...
  • Taskselでlamp-serverをインストール
sudo tasksel install lamp-server
  • バージョンを確認
$apachectl -v
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2019-04-03T13:22:37


$perl -v
This is perl 5, version 26, subversion 1 (v5.26.1) built for arm-linux-gnueabihf-thread-multi-64int
(with 67 registered patches, see perl -V for more detail)

Copyright 1987-2017, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


$php --version
PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun  4 2019 14:48:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies


$mysql --version
mysql  Ver 14.14 Distrib 5.7.26, for Linux (armv7l) using  EditLine wrapper
$sudo service apache2 start

f:id:cutxout:20190615115238j:plain
f:id:cutxout:20190615115642j:plain

Ubuntu MATE (18.04.2) にsambaで接続する

手順

  • sambaのインストール
$sudo apt install samba

tdb-tools (1.3.15-2) を展開しています...
以前に未選択のパッケージ samba を選択しています。
.../02-samba_2%3a4.7.6+dfsg~ubuntu-0ubuntu2.11_armhf.deb を展開する準備をしています ...
samba (2:4.7.6+dfsg~ubuntu-0ubuntu2.11) を展開しています...
以前に未選択のパッケージ attr を選択しています。
.../03-attr_1%3a2.4.47-2build1_armhf.deb を展開する準備をしています ...
attr (1:2.4.47-2build1) を展開しています...
以前に未選択のパッケージ libnl-route-3-200:armhf を選択しています。
.../04-libnl-route-3-200_3.2.29-0ubuntu3_armhf.deb を展開する準備をしています ...
libnl-route-3-200:armhf (3.2.29-0ubuntu3) を展開しています...
以前に未選択のパッケージ libibverbs1:armhf を選択しています。
.../05-libibverbs1_17.1-1ubuntu0.1_armhf.deb を展開する準備をしています ...
libibverbs1:armhf (17.1-1ubuntu0.1) を展開しています...
以前に未選択のパッケージ ibverbs-providers:armhf を選択しています。
.../06-ibverbs-providers_17.1-1ubuntu0.1_armhf.deb を展開する準備をしています ...
ibverbs-providers:armhf (17.1-1ubuntu0.1) を展開しています...
以前に未選択のパッケージ librados2 を選択しています。
.../07-librados2_12.2.11-0ubuntu0.18.04.2_armhf.deb を展開する準備をしています ...
librados2 (12.2.11-0ubuntu0.18.04.2) を展開しています...
以前に未選択のパッケージ libcephfs2 を選択しています。
.../08-libcephfs2_12.2.11-0ubuntu0.18.04.2_armhf.deb を展開する準備をしています ...
libcephfs2 (12.2.11-0ubuntu0.18.04.2) を展開しています...
以前に未選択のパッケージ samba-dsdb-modules を選択しています。
.../09-samba-dsdb-modules_2%3a4.7.6+dfsg~ubuntu-0ubuntu2.11_armhf.deb を展開する準備をしています ...
samba-dsdb-modules (2:4.7.6+dfsg~ubuntu-0ubuntu2.11) を展開しています...
以前に未選択のパッケージ samba-vfs-modules を選択しています。
.../10-samba-vfs-modules_2%3a4.7.6+dfsg~ubuntu-0ubuntu2.11_armhf.deb を展開する準備をしています ...
samba-vfs-modules (2:4.7.6+dfsg~ubuntu-0ubuntu2.11) を展開しています...
python-dnspython (1.15.0-1) を設定しています ...
ufw (0.36-0ubuntu0.18.04.1) のトリガを処理しています ...
samba-vfs-modules (2:4.7.6+dfsg~ubuntu-0ubuntu2.11) を設定しています ...
libnl-route-3-200:armhf (3.2.29-0ubuntu3) を設定しています ...
libc-bin (2.27-3ubuntu1) のトリガを処理しています ...
systemd (237-3ubuntu10.22) のトリガを処理しています ...
tdb-tools (1.3.15-2) を設定しています ...
update-alternatives: /usr/bin/tdbbackup (tdbbackup) を提供するために自動モードで /usr/bin/tdbbackup.tdbtools を使います
man-db (2.8.3-2ubuntu0.1) のトリガを処理しています ...
samba (2:4.7.6+dfsg~ubuntu-0ubuntu2.11) を設定しています ...
Samba is not being run as an AD Domain Controller, masking samba-ad-dc.service.
Please ignore the following error about deb-systemd-helper not finding samba-ad-dc.service.
Created symlink /etc/systemd/system/multi-user.target.wants/nmbd.service → /lib/systemd/system/nmbd.service.
Failed to preset unit: Unit file /etc/systemd/system/samba-ad-dc.service is masked.
/usr/bin/deb-systemd-helper: error: systemctl preset failed on samba-ad-dc.service: No such file or directory
Created symlink /etc/systemd/system/multi-user.target.wants/smbd.service → /lib/systemd/system/smbd.service.
samba-dsdb-modules (2:4.7.6+dfsg~ubuntu-0ubuntu2.11) を設定しています ...
attr (1:2.4.47-2build1) を設定しています ...
libibverbs1:armhf (17.1-1ubuntu0.1) を設定しています ...
librados2 (12.2.11-0ubuntu0.18.04.2) を設定しています ...
libcephfs2 (12.2.11-0ubuntu0.18.04.2) を設定しています ...
ibverbs-providers:armhf (17.1-1ubuntu0.1) を設定しています ...
libc-bin (2.27-3ubuntu1) のトリガを処理しています ...
systemd (237-3ubuntu10.22) のトリガを処理しています ...
ufw (0.36-0ubuntu0.18.04.1) のトリガを処理しています ...
  • sambaのユーザ設定
$sudo pdbedit -a cutxout
new password:
retype new password:
Unix username:        cutxout
NT username:          
Account Flags:        [U          ]
User SID:             S-1-5-21-587575283-722104280-531879302-1000
Primary Group SID:    S-1-5-21-587575283-722104280-531879302-513
Full Name:            cutxout
Home Directory:       \\rp3\cutxout
HomeDir Drive:        
Logon Script:         
Profile Path:         \\rp3\cutxout\profile
Domain:               RP3
Account desc:         
Workstations:         
Munged dial:          
Logon time:           0
Logoff time:          never
Kickoff time:         never
Password last set:    土, 15  6月 2019 10:23:08 JST
Password can change:  土, 15  6月 2019 10:23:08 JST
Password must change: never
Last bad password   : 0
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  • /etc/samba/smb.confの編集
    • [global]セクションに、以下の文字列を追加
## Character Set ##
unix charset = UTF-8
dos charset = CP932
    • [homes]セクションに、以下の文字列を追加
comment = Home Directories
browseable = no
read only = no
valid users = %S
  • smbd/nmbdの再起動
$sudo systemctl restart smbd nmbd
  • 動作確認
$sudo tail /var/log/samba/log.smbd
[2019/06/15 10:31:04.298043,  0] ../lib/util/become_daemon.c:124(daemon_ready)
  STATUS=daemon 'smbd' finished starting up and ready to serve connections

$ sudo tail /var/log/samba/log.nmbd
[2019/06/15 10:31:03.922425,  0] ../source3/nmbd/nmbd.c:58(terminate)
  Got SIGTERM: going down...
[2019/06/15 10:31:04.077190,  0] ../lib/util/become_daemon.c:124(daemon_ready)
  STATUS=daemon 'nmbd' finished starting up and ready to serve connections
[2019/06/15 10:31:26.028932,  0] ../source3/nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
  *****

  Samba name server RP3 is now a local master browser for workgroup WORKGROUP on subnet 192.168.100.4

  *****
top - 10:53:57 up 1 day, 16:16,  3 users,  load average: 0.86, 0.97, 0.78
Tasks: 188 total,   1 running, 137 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  3.3 sy,  0.0 ni, 90.7 id,  3.7 wa,  0.0 hi,  2.1 si,  0.0 st
KiB Mem :   946152 total,    34568 free,   302204 used,   609380 buff/cache
KiB Swap:   131068 total,   130292 free,      776 used.   553640 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 9635 cutxout   20   0   45004  16184  13388 S  11.6  1.7   2:18.60 smbd
 9654 root      20   0       0      0      0 I   8.6  0.0   0:10.23 kworker/0:2
    7 root      20   0       0      0      0 S   3.3  0.0   1:22.38 ksoftirqd/0
  222 root      20   0       0      0      0 D   1.7  0.0   0:21.89 usb-storage
 9638 cutxout   20   0    8120   2592   2052 R   1.3  0.3   0:11.54 top
 9646 root      20   0       0      0      0 D   1.0  0.0   0:01.72 kworker/u8:1
   51 root      20   0       0      0      0 S   0.7  0.0   0:10.32 kswapd0
 9529 root      20   0       0      0      0 I   0.3  0.0   0:00.36 kworker/1:0
 9597 root      20   0   39424   4636   2708 S   0.3  0.5   0:00.64 smbd-notifyd
    1 root      20   0   28968   5108   3380 S   0.0  0.5   0:15.39 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.14 kthreadd
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H
    6 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq
    8 root      20   0       0      0      0 I   0.0  0.0   0:04.12 rcu_preempt
    9 root      20   0       0      0      0 I   0.0  0.0   0:00.01 rcu_sched
   10 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.02 migration/0
   12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1
   14 root      rt   0       0      0      0 S   0.0  0.0   0:00.04 migration/1
   15 root      20   0       0      0      0 S   0.0  0.0   0:03.33 ksoftirqd/1

f:id:cutxout:20190615104445j:plain
f:id:cutxout:20190615104441j:plain

  • できました!

Seleniumで書いたスクリプトが動かなくなった件

Poderosaのアップデート

状況

  • Raspberry Pisshの設定ができたのでWindows側からログインしようと思ってPoderosaを起動したら、エラーが発生して利用できない。調べてみたら、Poderosaが古すぎて今時の鍵交換方式をサポートしていないのが原因のようだ。
接続エラー
Server does not support diffie-hellman-group1-sha1 for keyexchange
  • 2006年頃から使い続けているけど、4.1.1というのはいつのバージョンだろう。我ながら、安定稼働している限りアップデートの類を全くしないからなあ。
  • ところで、4系列と5系列では開発元からライセンスから変わってしまったようだ。せっかくなので、こちらも調査してみよう。