2026/06/05(金)Ubuntuのadiaryをlibfcgi-perlで動かす方法

サイト環境を移転したのでadiaryのパフォーマンス計測をやってみたの環境構築した時のログ。

確認環境

Env Ver
Ubuntu 24.04.4 LTS
nginx 1.26.1
adiary 3.52dev / Extends 0.25.0
libfcgi-perl 0.82+ds-3build2

前提

nginxとperlがインストール済

手順

  1. libfcgi-perlをインストールする
    sudo apt install libfcgi-perl
    
  2. /etc/systemd/system/adiary.serviceを次のように作成し、adiaryのFastCGIデーモンを作る

    [Unit]
    Description=adiary daemon
    After=network.target
    
    [Service]
    Type=simple
    User=www-data
    Group=www-data
    WorkingDirectory=/var/www/path/to
    ExecStart=/usr/bin/perl /var/www/path/to/adiary.fcgi /var/www/path/to/adiary.sock 10 100
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  3. サービスを有効化する
    sudo systemctl enable adiary.service
    sudo systemctl start adiary.service
    
  4. nginxの設定を書く

    server {
       listen 443 ssl;
       listen [::]:443 ssl;
       server_name  blog.example.com;
    
       client_max_body_size 100M;
    
       ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
       ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    
       root /var/www/path/to/blog;
    
       location / {
          try_files $uri @adiary;
       }
    
       location /__cache   { deny all; }
       location /data      { deny all; }
       location ~ \.cgi$   { deny all; }
    
       location @adiary {
          include fastcgi_params;
          fastcgi_pass unix:/var/www/path/to/adiary.sock;
          fastcgi_param   Basepath        /;
       }
    }
    
  5. nginxを再起動する
    sudo systemctl restart nginx
    

あとがき

adiary.httpd.plがオススメらしいのは見たが、HTTPサーバーは脆弱になりやすいことや、ログの使い勝手がどうなのか確認するのが面倒なこと、IPv6対応させるのが面倒だったことがあり採用しなかった。