ポジローぽけっと

昨日より今日、今日より明日を信じて、トライトライ

debianのnginxでredmineをspawn-fcgiで動作させたくなったら

試したのはdebian 8, jessie

redmineのインストー

redmine - Debian Wikiの2までやる。
インストールとは別だが、フォルダ配置が純粋redmineと異なる点に注意
詳細はページ最下段のDifferences_from_upstream_Redmineにある通り

nginxのインストールとconf修正

まずは、インストー

apt install nginx

次は、confを準備・修正
nginxは起動時に/etc/nginx/nginx.confを読み込み、
defaultのnginx.confはinclude /etc/nginx/conf.d/*.confするので

# default.confを読み込まないよう名前を変更
mv /etc/nginx/conf.d/default.conf default
# テンプレをredmine.confとしてコピー
cp /usr/share/doc/redmine/examples/nginx-alias.conf /etc/nginx/conf.d/redmine.conf

最後に、redmine.confを修正

upstream redmine_default {
    # the socket a fastcgi process is bound to
    server unix:/var/run/redmine/sockets/default/fcgi.socket;
}
server {
    location / {
        alias      /usr/share/redmine/public;
        try_files $uri @fcgi;
    }
    location @fcgi {
        include /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME /usr/share/redmine/public/$fastcgi_script_name;
        fastcgi_pass    redmine_default;
        #fastcgi_pass    127.0.0.1:9999; #unixドメインソケットを使わないなら、こっち
        fastcgi_index   index.html;
    }
}

spawn-fcgiとnginxの起動

Unixドメインソケットなら、

RAILS_ENV=production spawn-fcgi -U nginx -s /var/run/redmine/sockets/default/fcgi.socket -S -d /usr/share/redmine -- /usr/share/redmine/public/dispatch.fcgi
systemctl start nginx

tcpなら、

RAILS_ENV=production spawn-fcgi -a 127.0.0.1 -p 9999 -d /usr/share/redmine -- /usr/share/redmine/public/dispatch.fcgi
systemctl start nginx

以上

debianで不要なLISTENポートを閉じたくなったら

誰がどのポートでLISTENしてるか調べて、意図していない不要なserviceは止める

netstatで調べる

-l:listening sockets, -t:tcp, -p:name of the program

# netstat -ltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost:postgresql    *:*                     LISTEN      19605/postgres
tcp        0      0 localhost:smtp          *:*                     LISTEN      25998/exim4
tcp        0      0 *:47709                 *:*                     LISTEN      419/rpc.statd
tcp        0      0 *:sunrpc                *:*                     LISTEN      28638/rpcbind
tcp        0      0 *:http                  *:*                     LISTEN      27662/nginx.conf
tcp6       0      0 localhost:postgresql    [::]:*                  LISTEN      19605/postgres
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      25998/exim4
tcp6       0      0 [::]:53129              [::]:*                  LISTEN      419/rpc.statd
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN      28638/rpcbind

systemctlで止める

rpcbindとrpc.statdはNFSのためらしいので止める

rpcbindは

# systemctl disable rpcbind
# systemctl stop rpcbind

rpc.statdは

# systemctl disable nfs-common
# systemctl stop nfs-common

参考

debian - rpc.statd running on system not using NFS - Unix & Linux Stack Exchange

以上

debianにsshできるけどsftpできなかったら

接続先の.bashrcで以下記述より以前で標準出力していないか確認する

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

してたら実行を上記より下に移す

参考

サーバーにsftpできないときは - console.lealog();

bashrc - sftp gives an error: "Received message too long" and what is the reason? - Unix & Linux Stack Exchange

https://www.complang.tuwien.ac.at/doc/openssh-server/faq.html#2.9