raspi:certbot – nginx

Let’s encryptを使い証明書を取得します。

apache2でもnginxでも証明書を作成する手順は変わらない。

photo.viasv.comの名前解決が出来るよう、DNSを設定しnslookupなどで解決できているか確認します。

確認出来れば、作業を開始する。

最初に、photo.viasv.comを公開するディレクトリを作成

mkdir /var/www/html/photo
chown www-data:www-data /var/www/html/photo

ls -la /var/www/html/
total 48
drwxr-xr-x 5 root     www-data  4096 Oct  9 08:59 .
drwxr-xr-x 3 root     root      4096 Sep 27 14:30 ..
drwxr-xr-x 2 www-data www-data  4096 Oct  9 08:59 photo

nginxのVirtualHostの設定を行い、https://photo.viasv.com/を表示出来るか確認する。最初は、sslの設定はコメントアウトしておく。

server {
        listen 443 ssl;
        listen [::]:443 ssl;

        server_name photo.viasv.com;

        root /var/www/html/photo;
#        ssl_certificate /etc/letsencrypt/live/photo.viasv.com/fullchain.pem;
#        ssl_certificate_key /etc/letsencrypt/live/photo.viasv.com/privkey.pem;
#       ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        index index.html index.htm index.php index.nginx-debian.html;

        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        include         fastcgi_params;
        }

        location / {
                try_files $uri $uri/ =404;
        }
}

nginxの設定が終われば、再起動する。

$ sudo service nginx restart

きちんと、表示出来れば、certbotを使い、証明書を取得する。

certbot certonly --webroot -w /var/www/html/photo -d photo.viasv.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Obtaining a new certificate
An unexpected error occurred:
There were too many requests of a given type :: Error creating new authz :: too many failed authorizations recently: see https://letsencrypt.org/docs/rate-limits/
Please see the logfiles in /var/log/letsencrypt for more details.
root@ras:/var/www/html/photo/.well-known# certbot certonly --webroot -w /var/www/html/photo -d photo.viasv.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for photo.viasv.com
Using the webroot path /var/www/html/photo for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Generating key (2048 bits): /etc/letsencrypt/keys/0002_key-certbot.pem
Creating CSR: /etc/letsencrypt/csr/0002_csr-certbot.pem

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/photo.viasv.com/fullchain.pem. Your cert will
   expire on 2019-01-07. To obtain a new or tweaked version of this
   certificate in the future, simply run certbot again. To
   non-interactively renew *all* of your certificates, run "certbot
   renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

証明書を確認する。

$ ls /etc/letsencrypt/live/photo.viasv.com/
cert.pem  chain.pem  fullchain.pem  privkey.pem  README

証明書がきちんと出来ていることを確認出来れば、nginxの設定でsslのコメントを外し、nginxを再起動する。

cert.pem 証明書
privkey.pem 秘密鍵
chain.pem 中間証明書
fullchain.pem 証明書+中間証明書(結合したもの)

raspi:nginx

apacheを使ってhttpsを設定・運用していたが、なにか設定を触った時に、http+let’s encryptで使っている鍵が合わないと表示されapacheが起動しなくなっていた。certbotで鍵を作り替えたり、apacheの設定を見直してみたが、原因わからず、結局web serverをapache2からnginxに切り替えることにした。

apache2の自動起動を止める。

# systemctl disable apache2

nginxをinstall

$ sudo apt-get install nginx

設定する。
sslはcertbotで作成済みなので、流用する。

vi /etc/nginx/sites-enabled/default
server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name domain_name;
        root /var/www/html;
        ssl_certificate /etc/letsencrypt/live/domain_name/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/domain_name/privkey.pem;
        index index.html index.htm index.php index.nginx-debian.html;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        include         fastcgi_params;
        }

        location / {
                try_files $uri $uri/ =404;
        }
}

nginxを再起動

$ sudo service nginx restart

raspi:rpi-update

raspberry piのFirmwareを最新版に更新してみます。

現状の確認後、aptを使ってシステムを更新します。

$ uname -a

Linux ras2 4.14.70-v7+ #1144 SMP Tue Sep 18 17:34:46 BST 2018 armv7l GNU/Linux

$ sudo apt-get update

[sudo] kaz のパスワード:
ヒット:1 http://archive.raspberrypi.org/debian stretch InRelease
取得:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB]
15.0 kB を 2秒 で取得しました (5,685 B/s)
パッケージリストを読み込んでいます… 完了
$ sudo apt-get upgrade
パッケージリストを読み込んでいます… 完了
依存関係ツリーを作成しています
状態情報を読み取っています… 完了
アップグレードパッケージを検出しています… 完了
以下のパッケージはアップグレードされます:
libfm-data libfm-extra4 libfm-gtk-data libfm-gtk4 libfm-modules libfm4 python-unicornhathd
python3-unicornhathd
アップグレード: 8 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
592 kB のアーカイブを取得する必要があります。
この操作後に追加で 15.4 kB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://archive.raspberrypi.org/debian stretch/ui armhf libfm-data all 1.2.5-1+rpi6 [234 kB]
取得:2 http://archive.raspberrypi.org/debian stretch/ui armhf libfm-extra4 armhf 1.2.5-1+rpi6 [29.4 kB]
取得:3 http://archive.raspberrypi.org/debian stretch/ui armhf libfm-gtk-data all 1.2.5-1+rpi6 [34.1 kB]
取得:4 http://archive.raspberrypi.org/debian stretch/ui armhf libfm-gtk4 armhf 1.2.5-1+rpi6 [134 kB]
取得:5 http://archive.raspberrypi.org/debian stretch/ui armhf libfm4 armhf 1.2.5-1+rpi6 [101 kB]
取得:6 http://archive.raspberrypi.org/debian stretch/ui armhf libfm-modules armhf 1.2.5-1+rpi6 [45.9 kB]
取得:7 http://archive.raspberrypi.org/debian stretch/main armhf python-unicornhathd all 0.0.4 [6,428 B]
取得:8 http://archive.raspberrypi.org/debian stretch/main armhf python3-unicornhathd all 0.0.4 [6,504 B]
592 kB を 2秒 で取得しました (291 kB/s)
changelog を読んでいます… 完了
(データベースを読み込んでいます … 現在 117874 個のファイルとディレクトリがインストールされています。)
…/0-libfm-data_1.2.5-1+rpi6_all.deb を展開する準備をしています …
libfm-data (1.2.5-1+rpi6) で (1.2.5-1+rpi5 に) 上書き展開しています …
…/1-libfm-extra4_1.2.5-1+rpi6_armhf.deb を展開する準備をしています …
libfm-extra4:armhf (1.2.5-1+rpi6) で (1.2.5-1+rpi5 に) 上書き展開しています …
…/2-libfm-gtk-data_1.2.5-1+rpi6_all.deb を展開する準備をしています …
libfm-gtk-data (1.2.5-1+rpi6) で (1.2.5-1+rpi5 に) 上書き展開しています …
…/3-libfm-gtk4_1.2.5-1+rpi6_armhf.deb を展開する準備をしています …
libfm-gtk4:armhf (1.2.5-1+rpi6) で (1.2.5-1+rpi5 に) 上書き展開しています …
…/4-libfm4_1.2.5-1+rpi6_armhf.deb を展開する準備をしています …
libfm4:armhf (1.2.5-1+rpi6) で (1.2.5-1+rpi5 に) 上書き展開しています …
…/5-libfm-modules_1.2.5-1+rpi6_armhf.deb を展開する準備をしています …
libfm-modules:armhf (1.2.5-1+rpi6) で (1.2.5-1+rpi5 に) 上書き展開しています …
…/6-python-unicornhathd_0.0.4_all.deb を展開する準備をしています …
python-unicornhathd (0.0.4) で (0.0.3 に) 上書き展開しています …
…/7-python3-unicornhathd_0.0.4_all.deb を展開する準備をしています …
python3-unicornhathd (0.0.4) で (0.0.3 に) 上書き展開しています …
python3-unicornhathd (0.0.4) を設定しています …
libfm-data (1.2.5-1+rpi6) を設定しています …
libfm-extra4:armhf (1.2.5-1+rpi6) を設定しています …
libc-bin (2.24-11+deb9u3) のトリガを処理しています …
python-unicornhathd (0.0.4) を設定しています …
libfm-gtk-data (1.2.5-1+rpi6) を設定しています …
shared-mime-info (1.8-1+deb9u1) のトリガを処理しています …
libfm4:armhf (1.2.5-1+rpi6) を設定しています …
libfm-gtk4:armhf (1.2.5-1+rpi6) を設定しています …
libfm-modules:armhf (1.2.5-1+rpi6) を設定しています …
libc-bin (2.24-11+deb9u3) のトリガを処理しています …

$ sudo apt-get dist-upgrade

パッケージリストを読み込んでいます… 完了
依存関係ツリーを作成しています
状態情報を読み取っています… 完了
アップグレードパッケージを検出しています… 完了
アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。

次に、rpi-updateを行います。

$ sudo rpi-update

*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13545 100 13545 0 0 30329 0 –:–:– –:–:– –:–:– 30369
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** We’re running for the first time
*** Backing up files (this will take a few minutes)
*** Backing up firmware
*** Backing up modules 4.14.70-v7+
#############################################################
This update bumps to rpi-4.14.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=197689
##############################################################
*** Downloading specific firmware revision (this will take a few minutes)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 168 0 168 0 0 187 0 –:–:– –:–:– –:–:– 188
100 56.1M 100 56.1M 0 0 2740k 0 0:00:20 0:00:20 –:–:– 2060k
*** Updating firmware
*** Updating kernel modules
*** depmod 4.14.73+
*** depmod 4.14.73-v7+
*** Updating VideoCore libraries
*** Using HardFP libraries
*** Updating SDK
*** Running ldconfig
*** Storing current firmware revision
*** Deleting downloaded files
*** Syncing changes to disk
*** If no errors appeared, your firmware was successfully updated to 9f230923e419d942cf02fe936ea4fd186d3a21fa
*** A reboot is needed to activate the new firmware

うまくいったようで、再起動すると、New Firmwareで起動します。

再起動後、確認

Linux ras2 4.14.73-v7+ #1148 SMP Mon Oct 1 16:57:50 BST 2018 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

(旧)Linux ras2 4.14.70-v7+ #1144 SMP Tue Sep 18 17:34:46 BST 2018 armv7l GNU/Linux

(新)Linux ras2 4.14.73-v7+ #1148 SMP Mon Oct 1 16:57:50 BST 2018 armv7l GNU/Linux

kernelが変わっています。

www.club535.com 特定のディレクトリのOptions Indexes

たぶんですけど、www.club535.comの常時SSL化に伴って、全てのディレクトリで、Indexesの許可が無くなっていたと思う。

特定ディレクトリのみ許可の設定をした。

.htaccess

DirectoryIndex index.html index.htm index.shtml index.php index.cgi
Options +Indexes
Order deny,allow

2020年までに相続税が大きく変わるらしいぞ

約40年ぶりに相続の法制度が変わるらしいです。
概要を言うと、

配偶者居住権の新設

相続時、自宅の所有権は全て取得せずに、無償で使用する権利(居住権)を設定することで、配偶者が、終身、無償で生活を続けることができる権利です。所有権全部を取得するのではなく、居住権の範囲(所有権より安い)で単独取得するので、他の相続人に支払う金銭の額が減るのです。
遺産分割が確定するまでの暫定的な居住関係についても、民法改正の要綱案において、短期居住権という制度が整理されているところです。

長期居住権の簡易な評価方法について(民法(相続関係)部会 資料19-2)

遺産のうち、土地建物で6000万円と現金4000万円 合計1億円の遺産で、法定相続人は、配偶者と子供二人と仮定

土地建物 現金 合計
遺産額 6,000万円 4,000万円 10,000万円
配偶者 子供 子供 合計
改正前 遺産額 5,000万円 2,500万円 2,500万円 10,000万円
配偶者 子供 子供 合計
改正後 土地建物 3,000万円 1,500万円 1,500万円 6,000万円
改正後 現金 2,000万円 1,000万円 1,000万円 4,000万円

改正前は、遺産総額1億円の2分の1の5,000万円が配偶者、子供一人当たり2,500万円が子供の相続額となる。この場合、遺産のうち現金が4,000万円なので、子供二人に対して2,500万円の相続が出来ず、自宅を売却して資金を確保しなければならない。

改正後は、遺産のうち土地建物6000万円のうち3,000万円を配偶者が居住権として相続し、土地建物ののこり3,000万円を子供二人が所有権として1,500万円ずつと、遺産のうち現金4,000万円を配偶者2,000万円、子供1人あたり現金1,000万円を相続する。この場合、自宅を売却しなくても配偶者は自宅に住み続けることが出来、子供に対しても遺産のうちの現金で相続することが出来る。

自宅を遺産分割の対象外に

婚姻の期間が20年以上の夫婦が生前に贈与或いは遺贈された家は、遺産分割の対象から外れる。

上記例の通り、遺産総額1億円のうち、土地建物は配偶者に生前贈与されたものであると仮定すると、遺産分割の対象となるのは4,000万円の現金であるため、相続税額は、基礎控除の4,800万円を加味すると納税額は「0」となる。

しかし、配偶者の死亡後すぐに無くなった場合の2次相続では納税額が上がる可能性が高い。

2次相続の場合、6,000万円の不動産と現金1,000万円と仮定した場合、7,000万円-4,200万円=2,800万円が課税対象となり、税額が上がる。

預貯金がすぐに引き出せる

遺言書より登記

遺産の請求権

遺言書の形式・保管

法制度の内容を良く確認し、事前に対策を行えば節税することが可能になる反面、二次相続発生時の相続税額が増える可能性もある。

法制度の変更があっても、節税の際に有効なのは、計画的に、「生前贈与」を行うこと、いかに「土地評価を落とす」ことには変わりないようです。