How to install rtorrent, rutorrent, nginx, php-fpm and more on Arch Linux

shwetha17

Member
May 24, 2018
785
0
16
This guide is for Arch linux. This will be a step by step guide, but it won't be for the complete novice. I'll try to make it as thorough as possible but there are a LOT of config files which need to be written. You can use whatever text editor you are most comfortable with. Typically nano is best for a newbie but that is outside of the scope of this guide.

First step is to update your package lists.

Setting Up The System
Code:
pacman -Syy
pacman --sync --refresh --sysupgrade
Answer yes to any prompts.

Next we will install a lot of dependendies:
Code:
pacman -S gcc binutils perl-archive-zip perl pcre openssl popt \
unzip unrar autoconf automake bison subversion curl libjpeg \
libpng freetype2 t1lib libmcrypt libxslt libxml2 libevent \
libsigc++ ncurses make patch geoip dtach pkgconfig sudo irssi \
vsftpd perl-archive-zip perl-net-ssleay perl-html-parser \
perl-xml-libxml perl-digest-sha1 perl-json perl-json-xs perl-xml-libxslt
Answer yes to the prompts.

Arch, by default, doesn't have the proper configuration to use /usr/local so edit /etc/profile and /etc/ld.so.conf

make /etc/ld.so.conf look like this:
Code:
#
# /etc/ld.so.conf
#
/usr/local/lib

include /etc/ld.so.conf.d/*.conf
(basically adding /usr/local/lib)

and edit /etc/profile

modify the PATH variable and add the PKG_CONFIG_PATH:

Code:
# Set our default path
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
export PATH

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH


you really just need to change PATH and add PKG_CONFIG_PATH,
(here is the full file just in case)
/etc/profile

Code:
#
# /etc/profile
#
# This file is intended to be used for ALL common
# Bourne-compatible shells. Shell specifics should be
# handled in /etc/profile.$SHELL where $SHELL is the name
# of the binary being run (discounting symlinks)
#
# Sections taken from SuSe's /etc/profile
# Note the explicit use of 'test' to cover all bases
# and potentially incompatible shells

#Determine our shell without using $SHELL, which may lie
shell="sh"
if test -f /proc/mounts; then
case $(/bin/ls -l /proc/$$/exe) in
*bash) shell=bash ;;
*dash) shell=dash ;;
*ash) shell=ash ;;
*ksh) shell=ksh ;;
*zsh) shell=zsh ;;
esac
fi

# Load shell specific profile settings
test -f "/etc/profile.$shell" && . "/etc/profile.$shell"
unset shell

#Set our umask
umask 022

# Set our default path
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
export PATH

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
for profile in /etc/profile.d/*.sh; do
test -x $profile && . $profile
done
unset profile
fi

# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH

Grabbing sourch and building the webstack


I like to build my webstack and rtorrent from source. This guide will cover building Nginx 0.8.53 and Php 5.3.3

First, we need to fetch the source files:

Code:
cd /usr/local/src
wget http://nginx.org/download/nginx-0.8.54.tar.gz
wget http://us2.php.net/distributions/php-5.3.5.tar.gz
wget http://download.suhosin.org/suhosin-patch-5.3.4-0.9.10.patch.gz
wget http://download.suhosin.org/suhosin-0.9.32.1.tar.gz
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.6.tar.gz
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.6.tar.gz





I like to use the svn version of xmlrpc-c (this is a dependency of rtorrent if you wish to use a frontend like rutorrent)

Code:
svn co http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/advanced xmlrpc-c
And extract the files:

Code:
tar zxvf rtorrent-0.8.6.tar.gz
tar zxvf libtorrent-0.12.6.tar.gz
tar zxvf nginx-0.8.54.tar.gz
tar xzvf php-5.3.5.tar.gz
tar xzvf suhosin-0.9.32.1.tar.gz
gunzip suhosin-patch-5.3.4-0.9.10.patch.gz
 
Last edited:

peshua19

Member
May 25, 2018
897
0
16
I'm kind of an 'advanced noob'--I've got PLENTY to learn, and much that confounds me about Linux. A former Debian Dude, I recently have fallen in love with Arch--in large part because of wonderful tutorials/documentation like this one!

I've just spent a couple of hours going through this awesome tutorial (I'm somewhat staggered at how complex a process it is to set up rtorrent with a GUI!), and I'm left with a fundamental--and embarrassing question:

How do you actually start rutorrent?! huh.gif

I suspect I have to put something into my web-browser--but I haven't a clue what that might be, and an half-an-hour of searching hasn't turned anything up. It's not a secret, is it?! wink.gif
 

Attachments

lisas4567

Member
May 25, 2018
773
0
16
That's a little general for me at this point. Everything is on the same box. So..... Do I put something like "127.0.0.1" into my browser?? (When I do, I get: "Oops! Google Chrome could not connect to 127.0.0.1")

But I think I saw a lot of errors flash by at boot. rtorrent isn't starting at boot--but I haven't figured out why yet... Where can I look for any clues?

[edit] http://goo.gl/wG7PU

How significant are these error messages:

Code:
/var/log/nginx/error.log:
2011/02/19 17:05:08 [emerg] 2927#0: unexpected end of file, expecting "}" in /etc/nginx/sites-enabled/rutorrent:18

/var/log/errors.log:
Feb 19 16:09:23 localhost chpwdfile: File /etc/users.htpasswd doesn't exist.
Feb 19 19:57:38 localhost sudo: pam_unix(sudo:auth): conversation failed
 

somus1735

Member
May 25, 2018
833
0
16
Do you open google chrome on the SAME PC as that runs rtorrent & rutorrent ??
If so , then 127.0.0.1 should work .... if not .... make usre your webserver listens on the IP of your pc/server running both apps

And then on the pc you try to open the webui , use the IP of the server/pc
 

peshua19

Member
May 25, 2018
897
0
16
Now we will build nginx. I'm going to install the configs to the standard location but keep most of the webstack in /opt/webstack/ If you wish to change this, edit the following config accordingly:

move to the nginx source directory
Code:
cd /usr/local/src/nginx-0.8.54

and configure it as follows:
Code:
./configure \
--prefix=/opt/webstack \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--http-client-body-temp-path=/var/tmp/nginx/body \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_dav_module \
--user=http \
--group=http \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module

next, build it:
Code:
make
make install

Next we're going to create some directories and alter their permissions:
Code:
mkdir /var/tmp/nginx
mkdir /var/log/nginx
chown -R http:http /var/tmp/nginx /var/log/nginx
touch /etc/conf.d/nginx
Arch uses a sort of hybrid bsd init..more on this later. Now, we need to create the /etc/rc.d/nginx launch script with the following info:

/etc/rc.d/nginx

Code: [Select]
#!/bin/bash

# general config

NGINX_CONFIG="/etc/nginx/nginx.conf"

. /etc/conf.d/nginx
. /etc/rc.conf
. /etc/rc.d/functions

function check_config {
stat_busy "Checking configuration"
/opt/webstack/sbin/nginx -t -q -c "$NGINX_CONFIG"
if [ $? -ne 0 ]; then
stat_die
else
stat_done
fi
}

case "$1" in
start)
check_config
$0 careless_start
;;
careless_start)
stat_busy "Starting Nginx"
if [ -s /var/run/nginx.pid ]; then
stat_fail
# probably ;)
stat_busy "Nginx is already running"
stat_die
fi
/opt/webstack/sbin/nginx -c "$NGINX_CONFIG" &>/dev/null
if [ $? -ne 0 ]; then
stat_fail
else
add_daemon nginx
stat_done
fi
;;
stop)
stat_busy "Stopping Nginx"
kill -QUIT `cat /var/run/nginx.pid` &>/dev/null
if [ $? -ne 0 ]; then
stat_fail
else
rm_daemon nginx
stat_done
fi
;;
restart)
check_config
$0 stop
sleep 1
$0 careless_start
;;
reload)
check_config
if [ -s /var/run/nginx.pid ]; then
status "Reloading Nginx Configuration" kill -HUP `cat /var/run/nginx.pid`
fi
;;
check)
check_config
;;
*)
echo "usage: $0 {start|stop|restart|reload|check|careless_start}"
esac

then chmod +x the file to make it executable:

Code:
chmod +x /etc/rc.d/nginx

and create the logrotation script in /etc/logrotate.d/nginx

/etc/logrotate.d/nginx
Code:
/var/log/nginx/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
sharedscripts
postrotate
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
}


Next, we will build php
Change to the php directory and patch the source with suhosin-patch:

Code:
cd /usr/local/src/php-5.3.5/
patch -p 1 -i ../suhosin-patch-5.3.4-0.9.10.patch
and run the configure script:


Code:
./configure \
--prefix=/opt/webstack \
--with-config-file-path=/opt/webstack/etc \
--with-curl \
--with-pear \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-xpm-dir \
--with-freetype-dir \
--with-t1lib \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-xmlrpc \
--with-xsl \
--with-bz2 \
--with-gettext \
--with-fpm-user=http \
--with-fpm-group=http \
--enable-fpm \
--enable-exif \
--enable-wddx \
--enable-zip \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-sqlite-utf8 \
--enable-shmop \
--enable-dba \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm

And build it:
Code: [Select]
make
make install

This will install php-fpm to our webstack. Next we will create the php-fpm rc.d script:


/etc/rc.d/php-fpm
Code: [Select]
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions


wait_for_pid () {
try=0

while test $try -lt 35 ; do

case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;

'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac

stat_append '.'
try=`expr $try + 1`
sleep 1

done

}

[ -d /var/run/php-fpm ] || install -d -m755 /var/run/php-fpm

case "$1" in
start)
stat_busy 'Starting php-fpm'

/opt/webstack/sbin/php-fpm

if [ "$?" != 0 ] ; then
stat_fail
exit 1
fi

wait_for_pid created /var/run/php-fpm/php-fpm.pid

if [ -n "$try" ] ; then
stat_fail
exit 1
else
add_daemon php-fpm
stat_done
fi
;;

stop)
stat_busy 'Gracefully shutting down php-fpm'

if [ ! -r /var/run/php-fpm/php-fpm.pid ] ; then
stat_fail
exit 1
fi

kill -QUIT `cat /var/run/php-fpm/php-fpm.pid`

wait_for_pid removed /var/run/php-fpm/php-fpm.pid

if [ -n "$try" ] ; then
stat_fail
exit 1
else
rm_daemon php-fpm
stat_done
fi
;;

force-quit)
stat_busy 'Terminating php-fpm'

if [ ! -r /var/run/php-fpm/php-fpm.pid ] ; then
stat_fail
exit 1
fi

kill -TERM `cat /var/run/php-fpm/php-fpm.pid`

wait_for_pid removed /var/run/php-fpm/php-fpm.pid

if [ -n "$try" ] ; then
stat_fail
exit 1
else
rm_daemon php-fpm
stat_done
fi
;;

restart)
$0 stop
$0 start
;;

reload)
stat_busy 'Reload service php-fpm'

if [ ! -r /var/run/php-fpm/php-fpm.pid ] ; then
stat_fail
exit 1
fi

kill -USR2 `cat /var/run/php-fpm/php-fpm.pid`
stat_done
;;

*)
echo "usage: $0 {start|stop|force-quit|restart|reload}"
exit 1
;;

esac

and chmod +x it to make it executable:


Code:
chmod +x /etc/rc.d/php-fpm
create some directories, permissions and config files:

Code:
mkdir /var/run/php-fpm
mkdir /var/log/php-fpm
cp -f php.ini-production /opt/webstack/etc/php.ini
chmod 644 /opt/webstack/etc/php.ini
chown -R http:http /var/run/php-fpm /var/log/php-fpm

we also need to create the php-fpm.conf file:
/opt/webstack/etc/php-fpm.conf


Code:
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
;include=/opt/webstack/etc/fpm.d/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Default Value: none
pid = /var/run/php-fpm/php-fpm.pid

; Error log file
; Default Value: /opt/webstack/var/log/php-fpm.log
error_log = /var/log/php-fpm/error.log

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Start a new pool named 'www'.
[www]

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php-fpm/php-fpm.sock

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1
;listen.backlog = -1

; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0666
listen.owner = http
listen.group = http
listen.mode = 0666

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = http
group = http

; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives:
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; Note: This value is mandatory.
pm = static

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 3

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
;pm.start_servers = 20

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.min_spare_servers = 5

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.max_spare_servers = 35

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
; accepted conn - the number of request accepted by the pool;
; pool - the name of the pool;
; process manager - static or dynamic;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes.
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
; accepted conn: 12073
; pool: www
; process manager: static
; idle processes: 35
; active processes: 65
; total processes: 100
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; The log file for slow requests
; Default Value: /opt/webstack/var/log/php-fpm.log.slow
slowlog = /var/log/php-fpm/slow.log

; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =

; Chdir to this directory at the start. This value must be an absolute path.
; Default Value: current directory or / when chroot
;chdir = /var/www

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Default Value: no
;catch_workers_output = yes

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

run the following command to add the webstack path to /etc/bash.bashrc:

Code:
echo 'if [ -d "/opt/webstack/bin" ] && [ -d "/opt/webstack/sbin" ]; then
PATH="$PATH:/opt/webstack/bin:/opt/webstack/sbin"
fi' >> /etc/bash.bashrc

and manually export the path:
Code:
export PATH=$PATH:/opt/webstack/bin:/opt/webstack/sbin

build APC (hit enter for any defaults)
Code:
/opt/webstack/bin/pecl install APC-3.1.5
and geoip:

Code:
/opt/webstack/bin/pecl install geoip
And install the suhosin module:
Code:
cd /usr/local/src/suhosin-0.9.32.1/
/opt/webstack/bin/phpize
./configure --enable-suhosin
make
make install


next, add the following to php.ini (it's located at /opt/webstack/etc/php.ini if you do not remember)

Code:
extension = suhosin.so
extension = geoip.so
extension = apc.so
apc.enabled = 1
apc.shm_size = 128M
apc.shm_segments=1
apc.write_lock = 1
apc.rfc1867 = On
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1


Edit: In addition to the above, you should set the timezone in your php.ini Failing to set the timezone will cause the trafic plugin to fail. For more info on timezones, see: http://php.net/manual/en/timezones.php
 

peshua19

Member
May 25, 2018
897
0
16
(this is what the full php.ini should look like: http://pastie.org/1314853 )

Next, create the logrotate script for php-fpm's log:
/etc/logrotate.d/php-fpm

Code:
/var/log/php-fpm/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
sharedscripts
postrotate
[ ! -f /var/run/php-fpm/php-fpm.pid ] || kill -USR1 `cat /var/run/php-fpm/php-fpm.pid`
endscript
}

Building rtorrent


Now that we have our webstack build, we need to build rtorrent.

At this point, if you run into issues, it's probably because you didn't configure the system to use /usr/local/ as explained at the begining of this config.

doublecheck your /etc/ld.so.conf file and /etc/profile and if you need to, restart your shell (or simply type "bash" into prompt)

your PATH should include /usr/local/bin:/usr/local/sbin and your PKG_CONFIG_PATH should include /usr/local/lib/pkgconfig

to check them put in the following:
Code:
echo $PATH
echo $PKG_CONFIG_PATH

now we will build xmlrpc-c
Code:
cd /usr/local/src/xmlrpc-c
./configure
make
make install

libtorrent,
code:
cd /usr/local/src/libtorrent-0.12.6
./configure
make
make install


and finally, rtorrent

Code:
cd /usr/local/src/rtorrent-0.8.6
./configure --with-xmlrpc-c=/usr/local/bin/xmlrpc-c-config
make
make install

Adding the Rtorrent user, .rtorrent.rc, userdirectories and whatnot


I am going to call the rtorrent user rtuser1, you can change this to whatever you like:

Code:
useradd -u 5001 -d /home/rtuser1 -m -s /bin/bash rtuser1
chmod 755 /home/rtuser1

and create the directories for rtorrent, irssi, session and sockets

Code:
mkdir -p /home/rtuser1/rtorrent/download
mkdir /home/rtuser1/rtorrent/watch
mkdir /home/rtuser1/.session
mkdir /home/rtuser1/.sockets
chown -R rtuser1:rtuser1 /home/rtuser1/rtorrent/ /home/rtuser1/.sockets /home/rtuser1/.session/


Create a .rtorrent.rc for rtuser1 with the following info:

/home/rtuser1/.rtorrent.rc

Code:
#min_peers = 10
#max_peers = 200
min_peers_seed =1
max_peers_seed = 60
max_uploads = 30
#max_uploads_global = 400
#max_downloads_global = 300

download_rate = 0
upload_rate = 0

directory = /home/rtuser1/rtorrent/download/
session = /home/rtuser1/.session
schedule = watch_directory,5,5,load_start=/home/rtuser1/rtorrent/watch/*.torrent
schedule = low_diskspace,5,60,close_low_diskspace=512M


#ip =
#bind =
check_hash = no
use_udp_trackers = yes
encryption = allow_incoming,enable_retry,prefer_plaintext
dht = off
peer_exchange = no

#do not mess with this stuff unless you know what you're doing.
#hash_read_ahead = 10
#hash_interval = 10
#hash_max_tries = 5
#max_open_files = 128

#change "rtorrent" to your web login
execute = {sh,-c,/opt/webstack/bin/php /opt/webstack/html/php/initplugins.php rutorrent &}

#create directories if they do not exist
execute = {sh,-c,"if [ ! -d ~/./session/ ]; then mkdir -m 777 ~/./session; fi"}
execute = {sh,-c,"if [ ! -d ~/rtorrent/watch/ ]; then mkdir -m 777 ~/rtorrent/watch; fi"}
execute = {sh,-c,"if [ ! -d ~/rtorrent/download/ ]; then mkdir -m 777 ~/rtorrent/download; fi"}

#create directories as 777 and files as 666
umask = 0000
#socket path
scgi_local = /home/rtuser1/.sockets/scgi.sock
port_range = 51001-51001

Password Maker


I've just stumbled onto a great little program which lets you create hashed passwords instead of using a web based htpasswd generator (also, apache comes with a program which can generate htpasswd files but i do not know if arch allows you to install it without installing apache, and i find the following program much more "sane"


First, download the source:
Code:
wget http://cpbotha.net/files/mirror/chpwdfile-0.24.tar.gz
and untar it:
Code
tar xzfv chpwdfile-0.24.tar.gz
next, build it:
Code:
cd chpwdfile-0.24
make
cp chpwdfile /usr/local/bin/

now you can use this to create passwords fromt he command line like follows:
Code:
chpwdfile -a rutorrent -f /etc/users.htpasswd
or to edit a the password for the rutorrent user:
Code:
chpwdfile -m rutorrent -f /etc/users.htpasswd

This little program actually has more options, but you get the idea.
 

peshua19

Member
May 25, 2018
897
0
16
Next we will create a /etc/rc.d script for rtorrent (if you run rtorrent under a different user than rtuser1 be sure to modify the following accordingly)


/etc/rc.d/rtorrent
Code:
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions


case "$1" in
start)
stat_busy "Starting rtorrent"
su rtuser1 -c '/usr/bin/dtach -n /home/rtuser1/.sockets/rtorrent.sock /usr/local/bin/rtorrent' &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon rtorrent1
stat_done
fi
;;
stop)
stat_busy "Stopping rtorrent1"
kill $(pgrep -u rtuser1 rtorrent)
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon rtorrent1
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0


and make it executeable:

Code: [Select]
chmod +x /etc/rc.d/rtorrent
Install rutorrent


Code: [Select]
cd /usr/local/src
svn co http://rutorrent.googlecode.com/svn/trunk
rm -rf trunk/rutorrent/plugins/
mv trunk/plugins/ trunk/rutorrent/
chown -R http:http trunk/rutorrent/share
rm -r /opt/webstack/html/
mv trunk/rutorrent/ /opt/webstack/html/

Install some optional plugins: (plugin nfo, plugin pause and plugin lbll-suite See rutorrent wiki for more details)

Code:
cd /opt/webstack/html/plugins/
wget http://barrel-roll.org/nfo.tar.gz
tar xzfv nfo.tar.gz
rm nfo.tar.gz
svn co http://rutorrent-pausewebui.googlecode.com/svn/trunk pausewebui
wget http://rutorrent-tadd-labels.googlecode.com/files/lbll-suite_0.8.1.tar.gz
tar xzfv lbll-suite_0.8.1.tar.gz
rm lbll-suite_0.8.1.tar.gz

Configure Nginx

Code:
mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled

Optional: Configure ssl
Code:
mkdir /etc/nginx/ssl/
cd /etc/nginx/ssl/
Generate ssl rsa key: (create a pw and verify it when asked)
Code:
openssl genrsa -des3 -out secure.key 1024
Create the csr (enter the pw you created in the last step when prompted. Fill in the certificate however you like but leave the challenge pw blank)
Code:
openssl req -new -key secure.key -out server.csr

Strip the key of the pw: (again enter the pw from 2 steps back when prompted)
Code:
openssl rsa -in secure.key -out server.key
Create the certificate:
Code:
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
finish up:
Code:
mkdir /etc/nginx/ssl/key/
mkdir /etc/nginx/ssl/crt/
mv server.key key/
mv server.crt crt/
rm secure.key server.csr

Next, we will create nginx's basic config (if it's not already clear some of the earlier steps, i like to keep my main nginx config separate from my vhosts, which is what the include line is for)

/etc/nginx/nginx.conf
Code:
user http http;
worker_processes 1;


pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay off;

keepalive_timeout 10 10;

gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;



log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';


include /etc/nginx/sites-enabled/*;

}

Next, create your main rutorrent vhost:

/etc/nginx/sites-available/rutorrent
Code: [Select]
server {
listen *:80;

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log debug;
auth_basic "rutorrent";
auth_basic_user_file /etc/users.htpasswd;

location / {
root /opt/webstack/html;
index index.php index.html;
}

location /RPC1 {
include /etc/nginx/scgi_params;
scgi_pass backend2;
}


location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}

location ~ /\.ht {
deny all;
}
}
upstream backend {
server unix:/var/run/php-fpm/php-fpm.sock;
}

upstream backend2 {
server unix:/home/rtuser1/.sockets/scgi.sock;
}


and if you were doing the optional ssl config:

/etc/nginx/sites-available/rutorrent-ssl
Code: [Select]
server {
listen *:443;

ssl on;
ssl_certificate /etc/nginx/ssl/crt/server.crt;
ssl_certificate_key /etc/nginx/ssl/key/server.key;

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log debug;
auth_basic "rutorrent";
auth_basic_user_file /etc/users.htpasswd;

location / {
root /opt/webstack/html;
index index.php index.html;
}

location /RPC1 {
include /etc/nginx/scgi_params;
scgi_pass backend2;
}





location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}

location ~ /\.ht {
deny all;
}
}
upstream backend {
server unix:/var/run/php-fpm/php-fpm.sock;
}

upstream backend2 {
server unix:/home/rtuser1/.sockets/scgi.sock;
}

and finally, create symbolic links from the sites-available to sites-enabled in order to "enable" the vhosts:

Code: [Select]
cd /etc/nginx/sites-enabled/
ln -s ../sites-available/rutorrent
ln -s ../sites-available/rutorrent-ssl
 

peshua19

Member
May 25, 2018
897
0
16
vsftpd settup

create some directories

Code:
mkdir /var/run/vsftpd
mkdir /home/ftp
I'm going to setup vsftpd with implicit ssl. first, create the config file:


/etc/vsftpd.conf
Code:
xferlog_std_format=YES
xferlog_file=/var/log/vsftpd.log
xferlog_enable=YES
listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
guest_username=rtuser1
guest_enable=YES
user_sub_token=$USER
local_root=/home/ftp/$USER
chroot_local_user=YES
hide_ids=YES
local_umask=0000
implicit_ssl=YES
ssl_enable=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
listen_port=990
rsa_cert_file=/etc/ssl/vsftpd/vsftpd.pem

next, we will create the ssl certificate dir and cert (setup the certificate defaults however you like when prompted)


Code: [Select]
mkdir /etc/ssl/vsftpd/
cd /etc/ssl/vsftpd/
openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -keyout vsftpd.pem -out vsftpd.pem



Next, we will install pam_pwdfile. At the time of writing this config, it doesn't seem to be in the arch repositories but you can build it via AUR if you follow these steps:


First, download the aur source:

Code
cd /root/
wget http://aur.archlinux.org/packages/pam_pwdfile/pam_pwdfile.tar.gz

extract it and cd to the directory:

Code:
tar xzfv pam_pwdfile.tar.gz
cd /root/pam_pwdfile
Then create the package as follows:

(yes, i'm aware Arch documentation says not to create these as root, but this is the only one we're creating)

Code:
makepkg -g --asroot >> PKGBUILD && makepkg --asroot
and install the newly created package:

Code:
pacman -U pam_pwdfile-0.99-1-x86_64.pkg.tar.xz

create a symbolic link to the rtorrent download path for the ftp/web user (for the purposes of this document, we'te going to use the web and ftp user "rutorrent" but you can change this to anything you like. One reason we used pam_pwdfile is so we can use thre same password file for webauth in nginx and ftp auth in vsftpd.)


Code:
cd /home/ftp/
ln -s /home/rtuser1/rtorrent/ rutorrent
go to http://home.flash.net/cgi-bin/pw.pl and get a password for your user (we've used rutorrent but you could use something else)

once you have this, save it in /etc/users.htpasswd

For instance, for username=rutorrent, password=rutorrent

/etc/users.htpasswd

Code: [Select]
rutorrent:8SoETWw/tRtYI

Finally, create the file /etc/pam.d/vsftpd with the following info:

/etc/pam.d/vsftpd
Code: [Select]
auth required pam_pwdfile.so pwdfile /etc/users.htpasswd
account required pam_permit.so


Install Irssi plugin autodl-irssi


We've already installed the dependencies for this plugin. Now we will install and configure the perl script for irssi and the rutorrent plugin, and create an /etc/rc.d script to start it at boot.

First, lets create a daemon to run irssi:

/etc/rc.d/irssi

Code:
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
start)
stat_busy "Starting irssi1"
su rtuser1 -c '/usr/bin/dtach -n /home/rtuser1/.sockets/irssi.sock /usr/bin/irssi' &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon irssi1
stat_done
fi
;;
stop)
stat_busy "Stopping irssi1"
kill $(pgrep -u rtuser1 irssi)
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon irssi1
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0

And make it executable:

Code: [Select]
chmod +x /etc/rc.d/irssi

Next, install the autodl-irssi rutorrent plugin:

Code: [Select]
cd /opt/webstack/html/plugins/
svn co https://autodl-irssi.svn.sourceforge.net/svnroot/autodl-irssi/trunk/rutorrent/autodl-irssi
chown -R http:http autodl-irssi
And create the conf.php for the plugin:

/opt/webstack/html/plugins/autodl-irssi/conf.php


Code: [Select]
<?php
$autodlPort = 54321;
$autodlPassword = "autodlwoot";
?>
Next, we will instal the irssi perl script as the rtorrent user:

Become rtuser1:

Code: [Select]
su rtuser1
cd /home/rtuser1/


And install the irssi script:

Code: [Select]
mkdir -p ~/.irssi/scripts/autorun
cd ~/.irssi/scripts
wget https://sourceforge.net/projects/autodl-irssi/files/autodl-irssi-v1.30.zip
unzip -o autodl-irssi-v*.zip
rm autodl-irssi-v*.zip
cp autodl-irssi.pl autorun/
mkdir -p ~/.autodl
touch ~/.autodl/autodl.cfg
And edit the autodl.cfg: (These settings should match what you set for the rutorrent plugin earlier)

/home/rtuser1/.autodl/autodl.cfg


Code: [Select]
[options]
gui-server-port = 54321
gui-server-password = autodlwoot


Be sure to exit the rtuser1:

Code: [Select]
exit
Configure rutorrent

Earlier, we created the ftp user rutorrent. This will also be the user we use to authenticate the web with (note: If you wish to use a different username, create a different symbolic link for the ftp user, save a different name on line 33 of .rtorrent.rc and the following config:)

(the directory name we're about to create should match the name of the ftp/web user we wish to use...in this guide we've used "rutorrent", but as i've said, you can change this if you like)
Code: [Select]
cd /opt/webstack/html/conf/
mkdir users/rutorrent

And create the rutorrent config.php file for the user as follows:

/opt/webstack/html/conf/users/rutorrent/config.php




Code: [Select]
<?php
// configuration parameters

// for snoopy client
@define(&#39;HTTP_USER_AGENT&#39;, &#39;Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0&#39;, true);
@define(&#39;HTTP_TIME_OUT&#39;, 30, true); // in seconds
@define(&#39;HTTP_USE_GZIP&#39;, true, true);

@define(&#39;RPC_TIME_OUT&#39;, 5, true); // in seconds

@define(&#39;LOG_RPC_CALLS&#39;, false, true);
@define(&#39;LOG_RPC_FAULTS&#39;, true, true);

// for php
@define(&#39;PHP_USE_GZIP&#39;, false, true);
@define(&#39;PHP_GZIP_LEVEL&#39;, 2, true);

$do_diagnostic = true;
$log_file = &#39;&#39;; // path to log file (comment or make empty to disable logging)
$saveUploadedTorrents = true;

$topDirectory = &#39;/home/rtuser1/&#39;; // Upper available directory. Absolute path with trail slash.
$forbidUserSettings = false;

$scgi_port = 0;
$scgi_host = "unix:///home/rtuser1/.sockets/scgi.sock";

// For web->rtorrent link through unix domain socket
// (scgi_local in rtorrent conf file), change variables
// above to something like this:
//
// $scgi_port = 0;
// $scgi_host = "unix:///tmp/rpc.socket";

$XMLRPCMountPoint = "/RPC1"; // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!

$pathToExternals = array(
"php" => &#39;/opt/webstack/bin/php&#39;, // Something like /usr/bin/php. If empty, will be found in PATH.
"curl" => &#39;/usr/bin/curl&#39;, // Something like /usr/bin/curl. If empty, will be found in PATH.
"gzip" => &#39;/bin/gzip&#39;, // Something like /usr/bin/gzip. If empty, will be found in PATH.
"id" => &#39;/usr/bin/id&#39;, // Something like /usr/bin/id. If empty, will be found in PATH.
"stat" => &#39;/usr/bin/stat&#39;, // Something like /usr/bin/stat. If empty, will be found in PATH.
);

$localhosts = array( // list of local interfaces
"127.0.0.1",
"localhost",
);

$profilePath = &#39;../share&#39;; // Path to users profiles
$profileMask = 0777; // Mask for files and directory creation in users profiles.
// Both web-server and rtorrent users must have read-write access to its.
// For example, if web-server and rtorrent users are in some group then value may be 0770

?>





Edit the plugins.ini file to disable rpc and httprpc

/opt/webstack/html/conf/users/rutorrent/plugins.ini

Code: [Select]
;; Plugins' permissions.
;; If flag is not found in plugin section, corresponding flag from "default" section is used.
;; If flag is not found in "default" section, it is assumed to be "yes".
;;
;; For setting individual plugin's permissions you must write something like that:
;;
;; [ratio]
;; enabled = yes
;; canChangeToolbar = yes
;; canChangeMenu = yes
;; canChangeOptions = no
;; canChangeTabs = yes
;; canChangeColumns = yes
;; canChangeStatusBar = yes
;; canChangeCategory = yes

[default]
enabled = yes
canChangeToolbar = yes
canChangeMenu = yes
canChangeOptions = yes
canChangeTabs = yes
canChangeColumns = yes
canChangeStatusBar = yes
canChangeCategory = yes

[rpc]
enabled = no

[httprpc]
enabled = no

Making everything start at boot

This is actually one of the easiest steps.


Edit the /etc/rc.conf file and look for the "DAEMONS" line, add the scripts you wish to start at boot from the /etc/rc.d/ directory. Mine looks like this:

Code: [Select]
DAEMONS=(syslog-ng network netfs crond named sshd rtorrent irssi nginx php-fpm vsftpd)


I'm fairly sure i didn't forget anything. If you run into issues, feel free to respond and ask for help.
 

peshua19

Member
May 25, 2018
897
0
16
If you've already followed this guide, you should know i made a change to the /etc/rc.d/rtorrent and /etc/rc.d/irssi script.


Also, if you're really lazy and don't want to manually edit files i've create a tar archive with all of the config files EXCEPT the password file (/etc/users.htpasswd)


http://www.mediafire.com/?s3x11vzog9fcg7q

If you DO user this archive, and you plan to use multiple users, you will need to edit the nginx config files

These changes are mainly in how it stops the process.

Adding more users
If you wish to add multiple users you can copy the rtorrent and irssi rc.d scripts and edit them as follows:

/etc/rc.d/rtorrent2

Code: [Select]
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions


case "$1" in
start)
stat_busy "Starting rtorrent2"
su rtuser2 -c '/usr/bin/dtach -n /home/rtuser2/.sockets/rtorrent.sock /usr/local/bin/rtorrent' &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon rtorrent2
stat_done
fi
;;
stop)
stat_busy "Stopping rtorrent2"
kill $(pgrep -u rtuser2 rtorrent)
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon rtorrent2
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
/etc/rc.d/irssi2

Code: [Select]
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
start)
stat_busy "Starting irssi2"
su rtuser2 -c '/usr/bin/dtach -n /home/rtuser2/.sockets/irssi.sock /usr/bin/irssi' &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon irssi2
stat_done
fi
;;
stop)
stat_busy "Stopping irssi2"
kill $(pgrep -u rtuser2 irssi)
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon irssi2
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0


We also need to create the unix user:
Code: [Select]
useradd -u 5002 -d /home/rtuser2 -m -s /bin/bash rtuser2
And create the directories:
Code: [Select]
chmod 755 /home/rtuser2/
sudo -u rtuser2 mkdir /home/rtuser2/.session
sudo -u rtuser2 mkdir /home/rtuser2/.sockets
sudo -u rtuser2 mkdir -m 777 /home/rtuser2/rtorrent/
sudo -u rtuser2 mkdir -m 777 /home/rtuser2/rtorrent/download/
sudo -u rtuser2 mkdir -m 777 /home/rtuser2/rtorrent/watch/


And we need to create a .rtorrent.rc for this new user (you can copy the one from your other user and edit the relevant parts but i'll include it here anyways)
/home/rtuser2/.rtorrent.rc
Code: [Select]
#min_peers = 10
#max_peers = 200
min_peers_seed =1
max_peers_seed = 60
max_uploads = 30
#max_uploads_global = 400
#max_downloads_global = 300

download_rate = 0
upload_rate = 0

directory = /home/rtuser2/rtorrent/download/
session = /home/rtuser2/.session
schedule = watch_directory,5,5,load_start=/home/rtuser2/rtorrent/watch/*.torrent
schedule = low_diskspace,5,60,close_low_diskspace=512M


#ip =
#bind =
check_hash = no
use_udp_trackers = yes
encryption = allow_incoming,enable_retry,prefer_plaintext
dht = off
peer_exchange = no

#do not mess with this stuff unless you know what you're doing.
#hash_read_ahead = 10
#hash_interval = 10
#hash_max_tries = 5
#max_open_files = 128

#change "rtorrent" to your web login
execute = {sh,-c,/opt/webstack/bin/php /opt/webstack/http/php/initplugins.php rutorrent2 &}

#create directories if they do not exist
execute = {sh,-c,"if [ ! -d ~/.session/ ]; then mkdir ~/.session; fi"}
execute = {sh,-c,"if [ ! -d ~/rtorrent/watch/ ]; then mkdir -m 777 ~/rtorrent/watch; fi"}
execute = {sh,-c,"if [ ! -d ~/rtorrent/download/ ]; then mkdir -m 777 ~/rtorrent/download; fi"}

#create directories as 777 and files as 666
umask = 0000
#socket path
scgi_local = /home/rtuser2/.sockets/scgi.sock
port_range = 51002-51002

next, we need to create the link for the ftp user (i'm assuming a ftp/web user of rutorrent2 but you can name this anything you like, remember to change the .rtorrent.rc line 33 accordingly)
Code: [Select]
cd /home/ftp/
ln -s /home/rtuser2/rtorrent/ rutorrent2

and we need to make some changes in rutorrent as well. If you plan to run autodl-irssi with multiple users, you will want to move the user config to their directory, so first lets do this for your first user and then lets create a new config for your second user: (again, this is assuming web/ftp users of rutorrent and rutorrent2)

Code: [Select]
cd /opt/webstack/html/conf/users/
mkdir -p rutorrent/plugins/autodl-irssi/
mkdir -p rutorrent2/plugins/autodl-irssi/
cp /opt/webstack/html/plugins/autodl-irssi/conf.php rutorrent/plugins/autodl-irssi/

next, we need to create the main rutorrent config for your second user:
/opt/webstack/html/conf/users/rutorrent2/config.php


Code: [Select]
<?php
// configuration parameters

// for snoopy client
@define(&#39;HTTP_USER_AGENT&#39;, &#39;Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0&#39;, true);
@define(&#39;HTTP_TIME_OUT&#39;, 30, true); // in seconds
@define(&#39;HTTP_USE_GZIP&#39;, true, true);

@define(&#39;RPC_TIME_OUT&#39;, 5, true); // in seconds

@define(&#39;LOG_RPC_CALLS&#39;, false, true);
@define(&#39;LOG_RPC_FAULTS&#39;, true, true);

// for php
@define(&#39;PHP_USE_GZIP&#39;, false, true);
@define(&#39;PHP_GZIP_LEVEL&#39;, 2, true);

$do_diagnostic = true;
$log_file = &#39;&#39;; // path to log file (comment or make empty to disable logging)
$saveUploadedTorrents = true;

$topDirectory = &#39;/home/rtuser2/&#39;; // Upper available directory. Absolute path with trail slash.
$forbidUserSettings = false;

$scgi_port = 0;
$scgi_host = "unix:///home/rtuser2/.sockets/scgi.sock";

$XMLRPCMountPoint = "/RPC2"; // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!

$pathToExternals = array(
"php" => &#39;/opt/webstack/bin/php&#39;, // Something like /usr/bin/php. If empty, will be founded in PATH.
"curl" => &#39;/usr/bin/curl&#39;, // Something like /usr/bin/curl. If empty, will be founded in PATH.
"gzip" => &#39;/bin/gzip&#39;, // Something like /usr/bin/gzip. If empty, will be founded in PATH.
"id" => &#39;/usr/bin/id&#39;, // Something like /usr/bin/id. If empty, will be founded in PATH.
"stat" => &#39;/usr/bin/stat&#39;, // Something like /usr/bin/stat. If empty, will be founded in PATH.
);

// For web->rtorrent link through unix domain socket
// (scgi_local in rtorrent conf file), change variables
// above to something like this:
//
// $scgi_port = 0;
// $scgi_host = "unix:///tmp/rpc.socket";

?>

and you will want to create a config for your autodl-irssi using a different port than your first one...i'm going to put port 54322 but youcan use anything you like here:

/opt/webstack/html/conf/users/rutorrent/plugins/autodl-irssi/conf.php

Code: [Select]
<?php
/*
* Rename this file to conf.php. Make sure only your web server can read the renamed file!
*
* You need to edit ~/.autodl/autodl.cfg and add a few options to the [options] section
* # ...
* [options]
* gui-server-port = 12345
* gui-server-password = abcdef
* # ...
*
* $autodlPort and gui-server-port must have the same value.
* $autodlPassword and gui-server-password must have the same value.
* The password cannot be blank.
*/

$autodlPort = 54322;
$autodlPassword = "password12";

?>


next, we need to add the RPC2 scgi setup to your nginx config. remember, we have 2 configs, one for normal and one for ssl.

you'll want to add the following to both:
Code: [Select]
location /RPC2 {
include /etc/nginx/scgi_params;
scgi_pass backend3;
}


upstream backend3 {
server unix:/home/rtuser2/.sockets/scgi.sock;
}



You could just add it to the bottom of the file but i like to keep my configs somewhat orderly looking, so the new /etc/nginx/sites-available/rutorrent would look like this:

/etc/nginx/sites-available/rutorrent


Code: [Select]
server {
listen *:80;

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log debug;


location / {
root /opt/webstack/html;
index index.php index.html;

auth_basic "rutorrent";
auth_basic_user_file /etc/users.htpasswd;
}

location /RPC1 {
include /etc/nginx/scgi_params;
scgi_pass backend2;
}

location /RPC2 {
include /etc/nginx/scgi_params;
scgi_pass backend3;
}


location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}

location ~ /\.ht {
deny all;
}
}
upstream backend {
server unix:/var/run/php-fpm/php-fpm.sock;
}

upstream backend2 {
server unix:/home/rtuser1/.sockets/scgi.sock;
}

upstream backend3 {
server unix:/home/rtuser2/.sockets/scgi.sock;
}

and the ssl config:
/etc/nginx/sites-available/rutorrent-ssl


Code: [Select]
server {
listen *:443;

ssl on;
ssl_certificate /etc/nginx/ssl/crt/server.crt;
ssl_certificate_key /etc/nginx/ssl/key/server.key;

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log debug;


location / {
root /opt/webstack/html;
index index.php index.html;

auth_basic "rutorrent";
auth_basic_user_file /etc/users.htpasswd;
}

location /RPC1 {
include /etc/nginx/scgi_params;
scgi_pass backend2;
}

location /RPC2 {
include /etc/nginx/scgi_params;
scgi_pass backend3;
}


location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}

location ~ /\.ht {
deny all;
}
}
upstream backend {
server unix:/var/run/php-fpm/php-fpm.sock;
}

upstream backend2 {
server unix:/home/rtuser1/.sockets/scgi.sock;
}

upstream backend3 {
server unix:/home/rtuser2/.sockets/scgi.sock;
}


hopefully, you get the idea. Next, we need to install the autodl-irssi perl script for the new user:


become rtuser2:
Code: [Select]
su rtuser2
cd /home/rtuser2
and enter the following:
Code: [Select]
mkdir -p ~/.irssi/scripts/autorun
cd ~/.irssi/scripts
wget https://sourceforge.net/projects/autodl-irssi/files/autodl-irssi-v1.10.zip
unzip -o autodl-irssi-v*.zip
rm autodl-irssi-v*.zip
cp autodl-irssi.pl autorun/
mkdir -p ~/.autodl
touch ~/.autodl/autodl.cfg
next, edit the autodl.cfg file with the settings you made earlier:
/home/rtuser2/.autodl/autodl.cfg
Code: [Select]
[options]
gui-server-port= 54322
gui-server-password = password12

restart nginx, start the new rtorrent and irssi script, and be sure to add your user to the password file at /etc/users.htpasswd


You can use the same steps above to create multiple users. The important points are:

  • Each user needs a unix user
  • Each user needs SCGI (/RPC# )
  • Each user needs an .rtorrent.rc with correct settings
  • Each user needs a web/ftp username (this doesn't have to match the unix user and i prefer that it doesn't)
  • Rutorrent uses webauto for multiple users
  • Be sure to create a directory with the web/ftp user name in conf/users/ and create a unique rutorrent config for each user.
 

peshua19

Member
May 25, 2018
897
0
16
I've edited this post, but i feel i should respond to it as well to make sure people who used it see this info.


be sure to edit the php.ini to include your timezone. If you fail to do so, some plugins will not work (trafic for instance)

see http://php.net/manual/en/timezones.php for timezones you can set.
 

peshua19

Member
May 25, 2018
897
0
16
I editted this to change where the webauth setting is....it should be set on the server location and not just on location /

The reason for this is that if it's not set on the server location /RPC1 is exposed....this was a mistake on my part.


Antoher option would be to add
Code:
auth_basic "rutorrent";
auth_basic_user_file /etc/users.htpasswd;


to the /RPC1 location as well.


I will update the pack of files as well
 

randac56

Member
May 25, 2018
915
0
16
I editted this to change where the webauth setting is....it should be set on the server location and not just on location /

The reason for this is that if it's not set on the server location /RPC1 is exposed....this was a mistake on my part.


Antoher option would be to add
Code:
auth_basic "rutorrent";
auth_basic_user_file /etc/users.htpasswd;


to the /RPC1 location as well.


I will update the pack of files as well
I'm kind of an 'advanced noob'--I've got PLENTY to learn, and much that confounds me about Linux. A former Debian Dude, I recently have fallen in love with Arch--in large part because of wonderful tutorials/documentation like this one!

I've just spent a couple of hours going through this awesome tutorial (I'm somewhat staggered at how complex a process it is to set up rtorrent with a GUI!), and I'm left with a fundamental--and embarrassing question:

How do you actually start rutorrent?!


I suspect I have to put something into my web-browser--but I haven't a clue what that might be, and an half-an-hour of searching hasn't turned anything up. It's not a secret, is it?!
 

peshua19

Member
May 25, 2018
897
0
16
I'm kind of an 'advanced noob'--I've got PLENTY to learn, and much that confounds me about Linux. A former Debian Dude, I recently have fallen in love with Arch--in large part because of wonderful tutorials/documentation like this one!

I've just spent a couple of hours going through this awesome tutorial (I'm somewhat staggered at how complex a process it is to set up rtorrent with a GUI!), and I'm left with a fundamental--and embarrassing question:

How do you actually start rutorrent?!


I suspect I have to put something into my web-browser--but I haven't a clue what that might be, and an half-an-hour of searching hasn't turned anything up. It's not a secret, is it?!
you don't have to use such a complicated guide for installing rutorrent honestly. I just provided it for people who are looking to make the next step.


Basically, it works like this:

rtorrent is the client. You will run the client as a linux user, if you followed this guide it would be rtuser1

rutorrent is the webui. This can be run via any webserver. If you followed this guide, you would be using nginx with php-fpm.


if you followed THIS guide, you'd go to the ip/domain of the machine running everything in a web browser.
 

saroos1

Member
May 25, 2018
718
0
16
Quote
if you followed THIS guide, you'd go to the ip/domain of the machine running everything in a web browser.​


That's a little general for me at this point. Everything is on the same box. So..... Do I put something like "127.0.0.1" into my browser?? (When I do, I get: "Oops! Google Chrome could not connect to 127.0.0.1")

But I think I saw a lot of errors flash by at boot. rtorrent isn't starting at boot--but I haven't figured out why yet... Where can I look for any clues?

[edit] http://goo.gl/wG7PU

How significant are these error messages:

Code:
/var/log/nginx/error.log:
2011/02/19 17:05:08 [emerg] 2927#0: unexpected end of file, expecting "}" in /etc/nginx/sites-enabled/rutorrent:18

/var/log/errors.log:
Feb 19 16:09:23 localhost chpwdfile: File /etc/users.htpasswd doesn't exist.
Feb 19 19:57:38 localhost sudo: pam_unix(sudo:auth): conversation failed
 

simur612

Member
May 25, 2018
879
0
16
That's a little general for me at this point. Everything is on the same box. So..... Do I put something like "127.0.0.1" into my browser?? (When I do, I get: "Oops! Google Chrome could not connect to 127.0.0.1")
Do you open google chrome on the SAME PC as that runs rtorrent & rutorrent ??
If so , then 127.0.0.1 should work .... if not .... make usre your webserver listens on the IP of your pc/server running both apps

And then on the pc you try to open the webui , use the IP of the server/pc
 

randac56

Member
May 25, 2018
915
0
16
I think this guide is a little outside the scope of someone who is as new to linux as you are. Arch isn't a beginner's linux, it's for intermediate to expert users.

You'd be better off with ubuntu using the script brock made which does all the hard stuff for you
 

peshua19

Member
May 25, 2018
897
0
16
Thank you for the guide! But why the hell would you install from source when there's a perfectly viable package manager? This isn't slackware, man. How do you update it when ngix is updated? Do you go and download the new package and recompile it every time?
 

saroos1

Member
May 25, 2018
718
0
16
you're free to install any method you like my friend.

I prefer to handle managing my webstack. If you wish to use a different method, that's up to you.