To content | To menu | To search

Tag - FreeBSD

Entries feed - Comments feed

Monday, January 30 2023

Nextcloud で CLI でアップデートが失敗する

Nextcloud をアップデートしようとしたら、以下のエラーがでてアップデートできなかった。

Could not do request to updater server: SSL certificate problem: unable to get local issuer certificate

どうやらローカルにある証明書の問題の模様。

cURL and self signed certificates on FreeBSD 13 を参考に

# certctl -v rehash

で復旧した。

Wednesday, January 18 2023

FreeBSD の ports からインストールした postfixadmin で mysql を組み合わせているとアップデートした後でエラーになる

FreeBSD は 13.1-RELEASE-p3 で postfixadmin は postfixadmin-php81-3.4.d.20211018 。

Apache のエラーログでは

PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /usr/local/www/postfixadmin/functions.inc.php:1740
Stack trace:
#0 /usr/local/www/postfixadmin/functions.inc.php(1740): PDO->__construct('mysql:mysql:hos...', 'XXXXX', 'YYYYY...', Array)
#1 /usr/local/www/postfixadmin/functions.inc.php(1914): db_connect()
#2 /usr/local/www/postfixadmin/functions.inc.php(1875): db_query('SELECT value FR...', Array)
#3 /usr/local/www/postfixadmin/functions.inc.php(2222): db_query_one('SELECT value FR...')
#4 /usr/local/www/postfixadmin/public/login.php(40): check_db_version()
#5 {main}
  thrown in /usr/local/www/postfixadmin/functions.inc.php on line 1740

というエラー。DSN が mysql:mysql となってしまっている。Github 上の postfixadmin ではこうなっていない。

/usr/local/www/postfixadmin/functions.inc.php の db_connection_string() 内、

        $dsn = 'mysql:';
        if ($socket) {
            $dsn .= "unix_socket={$socket}";
        } else {
            $dsn .= "mysql:host={$CONF['database_host']}";
        }

でどちらかの「mysql:」を削除すればひとまず回避できる。

Wednesday, January 20 2021

umami.is を FreeBSD12 にセットアップ

umami.is を FreeBSD12 にセットアップした。

環境は、FreeBSD 12.1-RELEASE-p11 上の jail (qjail で構築) 、node-15.6.0、npm-6.14.8、mysql57-client-5.7.32。
jail の host 側で nginx でリバースプロキシを構成。mysql サーバーは別の jail に。

Continue reading...

Tuesday, December 22 2020

ConoHa VPS 上の FreeBSD に IPv4 アドレスを追加したときの追加 NIC と Jail の対応

2021/Mar/14 追記あり。

ConoHa VPS で IPv4 アドレスを追加すると、追加分は新しい NIC に割り当てられる。

Linux はいいらしいけれど、FreeBSD ではそのままだと活かし方が分からなかったけど、動いたように見える。

Continue reading...

Monday, December 9 2019

FreeBSD の jail で Zabbix が動かなかった話

環境は、
FreeBSD *jail* 12.1-RELEASE-p1 GENERIC amd64
zabbix_server は pkg の 4.2.6 又は ports の 4.4.3

Continue reading...

Thursday, February 2 2017

FreeBSD と Python3 で Jupyter notebook を動かした話

pkg や ports で Python3 をインストールしようとしても、周りのライブラリなどが複数のバージョンの Python2 をインストールしようとするので、観念して pkg や ports を使わずにセットアップした話。

Continue reading...

Thursday, November 10 2016

Let's Encrypt と FreeBSD

今は

Certbot の説明に従って、security/py-certbot をインストールすると OK 。

あらかじめ Apache や Nginx 等の Web サーバーを落としておいて、Certbot が自分で持っている Web サーバーを使うと簡単。

Monday, August 8 2016

FreeBSD での Let's encrypt 更新

2016/11/10 追記

情報更新しました

以下は古い内容。

Continue reading...

Thursday, June 18 2015

IPython Notebook

面白そうだったのでセットアップしてみた。

FreeBSD なら

# pkg install devel/ipython

で一発。
ローカルで動かすなら

$ ipython notebook

でいいけれど、サーバーで動かしたいとき。

# ipython notebook --no-browser --port=80 --ip=xxx.xxx.xxx.xxx

ポート 80 はルート権限でないと使わせてくれない?あと Listen するアドレスの指定が必要だった。
さすがにこのまま外には公開できないのでもう少しセットアップ。

必要なことは全て

$ ipython help notebook --help-all

ここから。

とりあえず TLS 対応してみたい。ひとまず勝手証明書で。ディレクトリは適当。

# mkdir /usr/local/etc/cert
# cd /usr/local/etc/cert/
root@freebsd:/usr/local/etc/cert # openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
......++++++
...........................................................++++++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
root@freebsd:/usr/local/etc/cert # openssl req -new -days 365 -key server.key -out server.csr
Enter pass phrase for server.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]: **
State or Province Name (full name) [Some-State]: *****
Locality Name (eg, city) []:*****
Organization Name (eg, company) [Internet Widgits Pty Ltd]:*****
Organizational Unit Name (eg, section) []:*****
Common Name (e.g. server FQDN or YOUR name) []:*****.example.jp
Email Address []:*****@example.jp

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
root@freebsd:/usr/local/etc/cert #
root@freebsd:/usr/local/etc/cert # openssl x509 -req -signkey server.key -days 365 -in server.csr -out server.crt
Signature ok
subject=/C=**/ST=*****/L=*****/O=*****/OU=*****/CN=*****.example.jp/emailAddress=*****@example.jp
Getting Private key
Enter pass phrase for server.key:
root@freebsd:/usr/local/etc/cert # mv server.key server.key.bak
root@freebsd:/usr/local/etc/cert # openssl rsa -in server.key.bak -out server.key
Enter pass phrase for server.key.bak:
writing RSA key
root@freebsd:/usr/local/etc/cert # ls
server.crt      server.csr      server.key      server.key.bak

(この鍵の作り方は古いかもしれない)
として関連ファイルを作ったあとで、

# ipython notebook --no-browser --port=443 --ip=***.example.jp --NotebookApp.certfile=/usr/local/etc/cert/server.crt --NotebookApp.keyfile=/usr/local/etc/cert/server.key

とすると https://***.example.jp/ で TLS 接続。

IPython のためのディレクトリも作っておこう。

# mkdir /home/ipython
# mkdir /home/ipython/.ipython
# mkdir /home/ipython/notebook

あとは、開きっぱなしっていうのもいやなので、パスワードを設定したい。

$ ipython
Python 2.7.9 (default, Jun 12 2015, 19:23:08)
Type "copyright", "credits" or "license" for more information.

IPython 3.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from IPython.lib import passwd; passwd()
Enter password:
Verify password:
Out[1]: 'sha1:****************************************************************'

In [2]: exit

というわけで全部設定。ロギングも入れた。

# ipython notebook --no-browser --port=443 --ip=*****.example.jp --NotebookApp.certfile=/usr/local/etc/cert/server.crt --NotebookApp.keyfile=/usr/local/etc/cert/server.key --NotebookApp.password='sha1:****************************************************************' --ipython-dir=/home/ipython/.ipython --notebook-dir=/home/ipython/notebook --log-level=WARN

ログインのときユーザー名は無いので、共用には向かないみたい。

あとこのままではルート権限で動いているので、起動しっぱなし、というのは怖い。

Monday, July 14 2014

qjail で作った jail 内で ping や traceroute

FreeBSD 10 と qjail で作った jail 内から、ping や traceroute を使用とすると、

icmp socket: Operation not permitted

と怒られる。

/etc/sysctl.conf に

security.jail.allow_raw_sockets=1

と追加してみたり、

/etc/rc.conf に

jail_{jail名}_parameters="allow.raw_sockets=1"

を追加してもだめ。

でも を見て解決。

# qjail config -k

小文字の k で ON、大文字 K で OFF、らしい。