ただの備忘録

2021年もあっという間に過ぎ、気づけば2022年になってしまいました。

まだまだコロナの影響が各所に出ている状況で、早く収束することを願うばかりです。

今回の投稿は、備忘録として残しておくだけなので意味わからないことがたくさん書いてあります。ご了承くださいm(__)m

準備するもの

Ubuntuの設定

インストールメディアからのインストールが終了したら、sudo apt-get updateで更新し、sudo apt installで必要なものをインストールする。

このときddclientを入れるが、バージョンが古いので以下の手順で更新する。

wget https://github.com/ddclient/ddclient/archive/v3.9.1.tar.gz

tar -xf v3.9.1.tar.gz

sudo cp ddclient-3.9.1/ddclient /usr/sbin/ddclient

rm -rf v3.9.1.tar.gz ddclient-3.9.1/

sudo mkdir /etc/ddclient

sudo mv /etc/ddclient.conf /etc/ddclient/

この後は、sudo vim /etc/ddclient/ddclient.conf でConfigファイルに設定情報を書き込み、sudo ddclient -daemon=0 -verbose -noquiet で正常に動作するか確認する。

# Configuration file for ddclient generated by debconf

# /etc/ddclient.conf

# Configuration file for ddclient

##

## Global Config

##

daemon=3600

ssl=yes

## CloudflareでDDNSする場合##

protocol=cloudflare

use=web

login=dev@example.tld ##←にCloudflareアカウントのメールアドレス

password=exampleAPIkey ##←にCloudflareのAPIkey

zone=your-own-domain.tld ##←に取得したドメイン

subdomain.your-own-domain.tld ##←に使いたいFQDN

sudo vim /etc/default/ddclientでデーモンが動くように修正する。

# Set to "true" if ddclient should be run every time a new ppp connection is established. This might be useful, if you are using dial-on-demand.

run_ipup="false"

# Set to "true" if ddclient should run in daemon mode. If this is changed to true, run_ipup and run_dhclient must be set to false.

run_daemon="true"

設定ミスでデーモンが動かなかった時のために、cronにddclientの実行を設定しておく。IPアドレスの紐付けが正しくできていれば大丈夫。

OpenLiteSpeedとLet's encryptの導入

まず、Let's encryptの証明書を発行してもらう。ワイルドカードの証明書を発行するにはDNS認証が必須。

sudo apt-get install certbot

sudo certbot certonly --manual -d *.your-own-domain.tld --preferred-challenges dns

##DNSレコードにTXTで文字列を登録しなさいと言われるので従う##

 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your-own-domain.tld/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-own-domain.tld/privkey.pem

   Your cert will expire on 20XX-XX-XX. 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"

これにて証明書の発行が完了する。

次にOpenLiteSpeedをインストールする。公式サイトに従ってレポジトリを追加し、設定していくだけ。昔はIDがadmin、パスワードが123456に固定されていたが、今はパスワードが「ランダムに生成」されているみたいなので、必要に応じてパスワードを変更する。

sudo wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh | sudo bash

sudo apt-get install openlitespeed

sudo apt-get install lsphp80 lsphp80-pgsql

cat /usr/local/lsws/adminpasswd ##←で設定されているパスワードが見れる

sudo /usr/local/lsws/admin/misc/admpass.sh

##ここでアカウントの設定をする

User name [admin]: ログインで使用するID

Password : 任意のパスワード

Retype password: 任意のパスワード(もう一度)

 

sudo /usr/local/lsws/bin/lswsctrl start

この後、ドメイン:7080でアクセスし、LSPHPのバージョンをlsphp80に変更したり、HTTPSリスナーを作成してSSL証明書のフルパスを指定したり、リバースプロキシの設定をしたりすることになりますが、ネット上に情報があふれているので割愛します。ちなみに、以下のサイトが分かりやすいと思います。

blog.litespeedtech.com

blog.apar.jp

mebee.info

openlitespeed.org

後は、Pythonを入れて実験プログラムを導入するだけ。今回はここまでで終わります。