How to set up a Linux VPS to be used as a seedbox

What is a seedbox?

A seedbox is a private server used for uploading and downloading digital files. Since VPSes are cheap and usually connected with speeds of 100mpbs and above they make great budget seedboxes.

What software and configuration is required?

The software installed with this guide will be rTorrent (a command-line torrent client), ruTorrent (a web interface for rTorrent), lighttpd (a webserver used to access ruTorrent), PHP (required by ruTorrent) and Screen (required for running rTorrent in the background)

Removing default apps and upgrading

Since we’re going to be using this VPS for torrents and will install lighttpd, we can remove the pre-installed webserver, mailserver, etc.

To do this, enter the following command and press enter

apt-get update && apt-get remove --purge -y apache2* bind9* sendmail* samba* && apt-get -y autoremove && apt-get -y upgrade

Sometimes, sendmail doesn’t get fully removed, so once that has finished, press the up arrow on your keyboard (which repeats the previous command, without submitting it) and then press enter and let it run again.

Installing and setting up the required apps

To install the apps we need, enter the following command and press enter

apt-get install -y screen rtorrent lighttpd php5-cgi php5-cli curl ffmpeg mediainfo unrar nano && lighty-enable-mod fastcgi-php auth

Setting up the folders

We need a folder for current torrents (session), a folder for ruTorrent to watch (watch) for new torrents, a folder for ruTorrent (/var/www/t) and a folder for the downloads (/var/www/d) so run the following command to create these folders

cd ~ && mkdir rtorrent && mkdir rtorrent/watch rtorrent/session /var/www/t /var/www/d

Installing ruTorrent

Run the following command to install ruTorrent into the /var/www/t folder

cd /var/www && wget https://github.com/Novik/ruTorrent/archive/master.zip && unzip master.zip && rm master.zip && mv ruTorrent-master/ t && chmod 0777 t/share/settings t/share/torrents

Starting rTorrent

We need to run rTorrent in a screen session so it will continue to run when the connection to the VPS is closed. Run the following command

cd ~ && screen -S rt

Then, you’ll have be in a screen session so type the following

rtorrent

Then, hold Ctrl + A and press D which will disconnect the screen session and leave it running in the background

Securing your webserver

Of course, we don’t want everyone accessing ruTorrent and our downloads, so we need to password protect the folders

Run the following command

cd /etc/lighttpd/conf-enabled && rm 05-auth.conf && wget ehwtf.com/seedbox/05-auth.conf && nano /etc/lighttpd/lighttpd.user && /etc/init.d/lighttpd restart

It will then bring up a blank white window

Head to this site and generate a htpasswd file (delete everything in the left hand box and type in admin (space) yourPasswordHere then click Generate htpasswd content)

Copy everything from the box on the right hand side (example: admin:$apr1$sgwrguwr$egrrrhr) and then go back to PuTTY, press Ctrl + X then type Y and then press enter

Now we just need to make sure we can see a list of files when we access the torrents folder. Enter the following command

echo ‘dir-listing.activate = “enable”‘ >> /etc/lighttpd/lighttpd.conf && /etc/init.d/lighttpd restart

Finished

To test it, access your webserver like this

http://YOURSERVERIP/t

It should ask you for a username and password. Use admin and the password you chose earlier. You should then be able to use ruTorrent. To see downloads, just go to the following address

http://YOURSERVERIP/d

If you find any problems, or it doesn’t ask for a username/password, please leave a comment and I will try to help.

How to set up a VPS to host websites without a control panel

About VPS hosting and this guide

When it comes to hosting a website, there are three options. Shared hosting, VPS hosting and dedicated server hosting.

Shared hosting is the most basic and fine for very small low-traffic websites, but sometimes you want that extra bit of control over your website without having to pay the cost of renting a dedicated server. This is where a VPS (virtual private server) comes in. You get full root access to a virtual machine, which is fully isolated and therefore acts like a dedicated server, but is much cheaper!

Since the price of hosting has come down in price so much lately, if you don’t mind putting in a little effort, it’s often more cost-effective to get a VPS than shared hosting.

This guide will go through the steps of setting up and securing your VPS, as well as installing a webserver (Lighttpd), a database server (MySQL) and some other things required to run most websites (like PHP and phpMyAdmin).

Purchasing a VPS and setting up PuTTY

One of the best and most highly recommended VPS hosts is Ramnode. They offer VPS hosting for as low as $15/year (including 128MB RAM, 64MB VSwap, 12GB pure SSD disk space and 500GB bandwidth). For further information you can read my post on Why Ramnode is the best VPS provider. I also recommend Vultr if you’re looking for more locations worldwide!

This guide will assume you’re using a VPS from Ramnode running Debian, but it should work with any VPS running Debian or Ubuntu.

The first thing you need to do is purchase your VPS. It should ask you to choose an operating system, so Once you’ve done this, you should receive an email from your host with your server’s IP and root password.

If you’re using Windows, you will also need to download PuTTY (choose putty.exe from the list). If you’re using Linux or OSX on your local machine you don’t need this.

Once you’ve downloaded PuTTY, open it up, and in the Host Name box, enter your server IP. Then, under Connection on the left click Data and in the Auto-login username box type in root.

Then, click Session on the left and click Default Settings. Then click Save (so you don’t have to enter this every time) and finally click OK.

If you use Linux or OSX, instead of using PuTTY, just open up a terminal and enter ssh [email protected] (where xxx.xxx.xxx.xxx is your server’s IP address).

You should now have a screen which says:

Using username “root”.
[email protected]’s password:

Just enter the root password you were given and press enter. You should now see the following:

root@yourserverhostname:~#

Setting up the VPS

Once I’ve logged into a recently set up VPS, I always like to change the password before anything else.

Enter passwd and press enter.

Enter a new password, press enter and then enter your new password again to confirm it. Of course, next time you log in (using the steps above) you’ll need to use this password.

The next thing we’re going to do is remove some applications we don’t need or want, and update everything else.

Type the following commands into PuTTY/terminal and press enter.

apt-get update && apt-get remove --purge -y apache2* bind9* sendmail* samba* && apt-get -y autoremove && apt-get -y upgrade

Sometimes, sendmail doesn’t get fully removed, so once that has finished, press the up arrow on your keyboard (which repeats the previous command, without submitting it) and then press enter and let it run again.

Now it’s time to start installing things, so enter the following command and press enter. During this stage, you’ll be prompted for a MySQL password.

apt-get install -y lighttpd php5-cgi mysql-server php5-mysql fail2ban unattended-upgrades

Once this has been completed, enter the following command and press enter to enable PHP and restart the webserver

lighty-enable-mod fastcgi-php && /etc/init.d/lighttpd restart

Next, we need to replace the MySQL config file with one which uses less memory and then restart MySQL. Enter the following command and press enter

mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bk && cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf && /etc/init.d/mysql restart

Installing phpMyAdmin

If you’re using a PHP/MySQL script, you’ll probably want phpMyAdmin to help you set up the database. This is easily done. First, enter the following command and press enter

cd /var/www/

Now go to the phpMyAdmin download page and find the latest version ending in .tar.gz. Right click on the link and choose copy link address. The end of the link will have something like #!md5!79f36ee849381ad93c71f7cbbd5ef2a9 so remove this, including the hash, and then add the link into the command below where specified (including the quotes) and press enter

wget --no-check-certificate https://your-link-here.com/file.tar.gz

It will then download a .tar.gz file to your server. It will be something like phpMyAdmin-4.4.9-english.tar.gz. Now we will extract the files and remove this file. Enter the following command, replacing yourfile.tar.gz with the actual name of your .tar.gz file and press enter.

tar -zxvf yourfile.tar.gz && rm yourfile.tar.gz

You will then be left with a folder named something similar to phpMyAdmin-4.4.9-english depending on the version you downloaded. You can now access this by going to the following link where xxx.xxx.xxx.xxx is your server IP and foldername is the name of the phpmyadmin folder. I would advise renaming this to something of your choosing, just to avoid bots which actively look for phpMyAdmin installations.

http://xxx.xxx.xxx.xxx/foldename

Keeping everything updated and setting up your sites

That’s it! You now have a fully working VPS with a webserver (lighttpd) and a database server (MySQL) along with PHP  and phpMyAdmin installed. We also installed fail2ban to help protect us against bots trying to guess our SSH password, and unattended-upgrades to install critical updates automatically.

However, you should also log into your VPS often and run the following command to make sure everything is updated

apt-get update && apt-get -y upgrade

To install your sites/scripts (WordPress, phpBB, etc.) you need to move them into the /var/www/ directory. This is the root folder for lighttpd and the files/folders in here are what you see when accessing the following (where xxx.xxx.xxx.xxx is your server IP)

http://xxx.xxx.xxx.xxx/fileorfolder

Finished

That’s it! Now you can actually set up your websites. If you have any issues please leave a comment below.

Thanks for reading.