FlyingPersian
Patron
- Joined
- Jan 27, 2014
- Messages
- 237
Hi
After switching back to rutorrent from deluge I decided to try it out with lighttpd instead of an apache server, because lighttpd is lighter (duh) and since I'm not that big of a poweruser I thought it'd be enough to use lighttpd. Since it was not that easy to install and people might be interested I decided to share a short tutorial on how I did it. These are my following sources for installing it to a jail:
There are some basic things I’m not going to go over with you since they’re pretty basic (creating jail, adding user etc.). There needs to be a user you want to run rtorrent as and an according jail obviously (refer to the "adduser" command). I’ll do everything as root here since you can just destroy the jail and redo it.
1. We update ports and pkg
2. We install nano, screen & lighttpd
I prefer to use nano as my text editor, but feel free to use anything you like. Screen is needed to run rtorrent.
3. We install rtorrent
Accept all defaults
4. We install php
Accept all defaults
5. We install php53-extensions
Here we don't install just the defaults. First do
Then check all the following points. Some might not exist, others but be already checked.
You'll have to confirm a lot of stuff. Don't change anything then, just hit enter to confirm everything.
6. We copy over a php.ini
7. We copy over a .rtorrent.rc into the home dir of the user we created. I'll stick to the user "admin"
8. We create a bunch of folders needed for rtorrent
9. We edit the .rtorrent.rc
The thing I recommend here is just to read through it once completely. For people who used torrent clients before most of the stuff is self explanatory. The settings are quite basic and universal accross most other clients. Standard things are to disable DHT and peer-exchange, change the encryption accordingly to your needs and set a descent amount of uploadslots and peers to connect to, so that your router doesn't crash.
10. We then download rutorrent & plugins
The download may fail, then just download it with your windows machine and move it over by adding storage to the jail (e.g. into the /media/ folder).
11. We then edit the lighttpd.conf. Never forget to remove the # in front of a line to actually activate it.
12. We create a .pem file for SSL
13. We create a .htpasswd file which is used to verify the login credentials
htpasswd comes with apache, but not with lighttpd. You can use the following website to create the neccessary line for the file. Use your user (admin in my case) and secure password. The file has to be stored somewhere outside the webspace. I chose /etc/private/. If for any reason you want to store it somewhere else you have to edit the "auth.backend.htpasswd.userfile = "/etc/private/.htpasswd"" line in the lighttpd.conf which we added at the very end.
At the bottom you see a line like this:
Copy that line and do the following:
14. We configure lighttpd to use the FastCGI module
The weird thing is here that the auth.conf only has to be imported, but nothing has to be changed there. The lines neccessary for authentication are in the lighttpd.conf, which we did earlier. I've no idea why that is, but it works this way.
Then we add the following line to the fastcgi.conf
15. We change the scgi port in the rutorrent config
16. We make lighttpd start automatically
I haven't figured out how to make screen start automatically on system boot, but I'll work on that and add the lines.
17. Start up everything
I think we're done here. If you run into any issues let me know! If you've suggestions post them!!
After switching back to rutorrent from deluge I decided to try it out with lighttpd instead of an apache server, because lighttpd is lighter (duh) and since I'm not that big of a poweruser I thought it'd be enough to use lighttpd. Since it was not that easy to install and people might be interested I decided to share a short tutorial on how I did it. These are my following sources for installing it to a jail:
- First off my own tutorial on how to install rutorrent in a jail
- Secondly DrKK’s Definitive Guide to Installing OwnCloud in FreeNAS (or FreeBSD), which helped me in setting up lighttpd
- Thridly this Blogger’s tutorial
There are some basic things I’m not going to go over with you since they’re pretty basic (creating jail, adding user etc.). There needs to be a user you want to run rtorrent as and an according jail obviously (refer to the "adduser" command). I’ll do everything as root here since you can just destroy the jail and redo it.
1. We update ports and pkg
Code:
portsnap fetch portsnap extract pkg update pkg upgrade cd /usr/ports/ports-mgmt/portmaster make install clean echo 'WITH_PKGNG=yes' >> /etc/make.conf pkg2ng portmaster -avB <accept all of the defaults>
2. We install nano, screen & lighttpd
I prefer to use nano as my text editor, but feel free to use anything you like. Screen is needed to run rtorrent.
Code:
pkg install nano pkg install lighttpd cd /usr/ports/sysutils/screen make install clean
3. We install rtorrent
Accept all defaults
Code:
cd /usr/ports/net-p2p/rtorrent make install clean
4. We install php
Accept all defaults
Code:
cd /usr/ports/lang/php53 make install clean
5. We install php53-extensions
Here we don't install just the defaults. First do
Code:
cd /usr/ports/lang/php53-extensions make install clean
Then check all the following points. Some might not exist, others but be already checked.
Code:
BZ2, CTYPE, CURL, DOM, FILEINFO, FILTER, GD, HASH, ICONV, JSON, MBSTRING, MBCRYPT, MYSQL, MYSQLI MHASH, OPENSSL, PCRE, PDO, PDO_SQLITE, POSIX, SESSION, SIMPLEXML, SOCKETS, SPL, SQLITE, TOLKENIZER, XML, XMLREADER, XMLRPC, XMLWRITER, ZIP
You'll have to confirm a lot of stuff. Don't change anything then, just hit enter to confirm everything.
6. We copy over a php.ini
Code:
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
7. We copy over a .rtorrent.rc into the home dir of the user we created. I'll stick to the user "admin"
Code:
cp /usr/local/share/examples/rtorrent/rtorrent.rc /home/admin/.rtorrent.rc chown admin:admin .rtorrent.rc
8. We create a bunch of folders needed for rtorrent
Code:
cd /home/admin/ mkdir rtorrent cd rtorrent/ mkdir .session mkdir downloads mkdir watch chown -R admin:admin /home/admin/
9. We edit the .rtorrent.rc
Code:
nano /home/admin/.rtorrent.rc --Change the following lines-- # Default directory to save the downloaded torrents. directory = /home/admin/rtorrent/watch/ # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a # relative path? session = /home/admin/rtorrent/.session/ --The port range should be something above 50.000 I think, just chose whatever you want and forward the port from your router to the jail's IP-- port_range = 50001-50001 --We add the following line to the end of the file scgi_port = 127.0.0.1:5001 --Press ctrl + x, hit y to confirm, hit enter to confirm the name. It's now saved and you left nano.
The thing I recommend here is just to read through it once completely. For people who used torrent clients before most of the stuff is self explanatory. The settings are quite basic and universal accross most other clients. Standard things are to disable DHT and peer-exchange, change the encryption accordingly to your needs and set a descent amount of uploadslots and peers to connect to, so that your router doesn't crash.
10. We then download rutorrent & plugins
Code:
cd /usr/local/www/ wget --no-certificate-check https://bintray.com/artifact/download/novik65/generic/rutorrent-3.6.tar.gz wget --no-certificate-check https://bintray.com/artifact/download/novik65/generic/plugins-3.6.tar.gz tar -xfvz rutorrent-3.6.tar.gz tar -xfvz plugins-3.6.tar.gz mv plugins rutorrrent/ rm *.gz
The download may fail, then just download it with your windows machine and move it over by adding storage to the jail (e.g. into the /media/ folder).
11. We then edit the lighttpd.conf. Never forget to remove the # in front of a line to actually activate it.
Code:
nano /usr/local/etc/lighttpd/lighttpd.conf --I don't want to use http, only https, so I hashed out (added a #) this line: #server.port = 80 --I also disabled IPv6-- #server.use-ipv6 = "enable" --change-- server.document-root = "/usr/local/www/data/" --to-- server.document-root = "/usr/local/www/rutorrent/ --add these lines for SSL-- server.port = 443 ssl.engine = "enable" ssl.pemfile = "/usr/local/etc/lighttpd/certs/lighttpd.pem" --add these lines for password protection of the WebGUI-- auth.backend = "htpasswd" auth.backend.htpasswd.userfile = "/etc/private/.htpasswd" auth.require = ( "/RPC2" => ( "method" => "basic", "realm" => "My ruTorrent web site", "require" => "user=admin", ), "/" => ( "method" => "basic", "realm" => "My ruTorrent web site", "require" => "valid-user", ) ) --Save it--
12. We create a .pem file for SSL
Code:
mkdir -p /usr/local/etc/lighttpd/certs/ cd /usr/local/etc/lighttpd/certs/ openssl req -new -x509 -keyout lighttpd.pem -out lighttpd.pem -days 3650 -nodes chmod 400 lighttpd.pem chown -R www:www /usr/local/etc/lighttpd/
13. We create a .htpasswd file which is used to verify the login credentials
htpasswd comes with apache, but not with lighttpd. You can use the following website to create the neccessary line for the file. Use your user (admin in my case) and secure password. The file has to be stored somewhere outside the webspace. I chose /etc/private/. If for any reason you want to store it somewhere else you have to edit the "auth.backend.htpasswd.userfile = "/etc/private/.htpasswd"" line in the lighttpd.conf which we added at the very end.
Code:
http://www.engr.sjsu.edu/daluu/scripts/htpasswd.php
At the bottom you see a line like this:
Code:
admin:c3Q1dT1i56d6I
Copy that line and do the following:
Code:
mkdir -p /etc/private/ cd /etc/private/ nano .htpasswd --Paste the line you just copied and save it. chown www:www .htpasswd chmod 400 .htpasswd
14. We configure lighttpd to use the FastCGI module
Code:
nano /usr/local/etc/lighttpd/modules.conf --Change-- # "mod_auth", --to-- "mod_auth", #include "conf.d/fastcgi.conf" --which is somewhere at the bottom, to-- include "conf.d/fastcgi.conf"
The weird thing is here that the auth.conf only has to be imported, but nothing has to be changed there. The lines neccessary for authentication are in the lighttpd.conf, which we did earlier. I've no idea why that is, but it works this way.
Then we add the following line to the fastcgi.conf
Code:
nano /usr/local/etc/lighttpd/conf.d/fastcgi.conf --add to the bottom-- fastcgi.server = ( ".php" => (( "bin-path" => "/usr/local/bin/php-cgi", "socket" => "/tmp/php.socket", "max-procs" => 1, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "3", "PHP_FCGI_MAX_REQUESTS" => "1000" ), "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), "broken-scriptfilename" => "enable" )))
15. We change the scgi port in the rutorrent config
Code:
nano /usr/local/www/rutorrent/conf/config.php --Change-- $scgi_port = 5000; --to-- $scgi_port = 5001;
16. We make lighttpd start automatically
Code:
sysrc lighttpd_enable=yes
I haven't figured out how to make screen start automatically on system boot, but I'll work on that and add the lines.
17. Start up everything
Code:
--Make lighttpd start/stop/restart-- service lighttpd onestart/onestop/onerestart --Start rtorrent-- su admin screen rtorrent --Press and hold ctrl, then press a and then d to detach from screen. Now it runs in the background. Release a before pressing d and do it quickly--
I think we're done here. If you run into any issues let me know! If you've suggestions post them!!
Last edited: