1、安装Nginx+PHP

1)安装

pkg install nginx php74

2)配置

配置vhost,在/usr/loca/etc/nginx/nginx.conf的http{}中加入相关信息。

http {
……
    include /usr/local/etc/nginx/vhost/*.conf;
……
}

创建vhost目录,并创建ruTorrent.conf文档,输入相应内容。

mkdir vhost

ruTorrent.conf配置信息:

server {
    server_name  "ServerName";

    root /home/data/www/html/ruTorrent;
    index index.html index.htm index.php;

    listen 443 ssl http2; # managed by Certbot

    ssl_certificate /usr/local/etc/nginx/ssl/cert.pem; # managed by Certbot
    ssl_certificate_key /usr/local/etc/nginx/ssl/key.pem; # managed by Certbot
    include /usr/local/etc/nginx/ssl/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /usr/local/etc/nginx/ssl/dhparam.pem; # managed by Certbot
    add_header Strict-Transport-Security "max-age=31536000";

    auth_basic "User Authentication";
    auth_basic_user_file /path/.htpasswd;

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
                return 404;
        }

        fastcgi_param HTTP_PROXY "";

        fastcgi_pass unix:/var/run/php-fpm.socket;
        fastcgi_index index.php;

        include fastcgi_params;

        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    }
}

注意Ngix和PHP-FPM的相关参数要一致。

3)生成认证用户及密码,把USER和PASSWD换成你要的用户名和密码即可。

printf "USER:$(openssl passwd -crypt PASSWD)\n" >> /path/.htpasswd

2、安装rtorrent

1)安装

pkg install rtorrent screen

2)rtorrent启动脚本

#!/bin/sh

case "$1" in
start)
echo -n "Starting rtorrent"
su - awei -c "screen -A -m -d -S rtorrent /usr/local/bin/rtorrent" &
echo "."
;;
stop)
echo -n "Stopping rtorrent"
ppid=`ps ax | grep "/usr/local/bin/rtorrent" | grep -v grep | grep -v screen | awk '{ print $1 }'`
kill ${ppid}
echo "."
;;
restart)

echo -n "Restarting rtorrent"
ppid=`ps ax | grep "/usr/local/bin/rtorrent" | grep -v grep | grep -v screen | awk '{ print $1 }'`
kill ${ppid}
sleep 1
su - awei -c "screen -A -m -d -S rtorrent /usr/local/bin/rtorrent" &
echo "."
;;
*)
echo "Usage: {start|stop|restart}" >&2
exit 1
;;
esac

exit 0

3)启动

sysrc rtorrent_enable="YES"

server rtorrent start

自动启动我老失败,干脆,每次要运行时手动输入:server rtorrent start。

3、安装ruTorrent

直接上官网下载,然后解压放到相应目录,即可。

Related content