Showing posts with label Educational Tutorials. Show all posts
Showing posts with label Educational Tutorials. Show all posts

Friday, February 7, 2014

How to setup Raspberry Pi computer for Torrent downloading and Network Added Storage.

Aim of tutorial : How to setup Raspberry Pi for downloading Torrents and NAS.



This setup will allow one to access their hard disk drive connected to raspberry pi as a network share in windows or an android phone and also enable raspberry pi to download torrents from the internet and automatically share it on the network.  The tutorial is divided into 2 Parts as follows:

1.] Installing Samba server.
2.] Installing the Transmission Torrent Client.

Login to your Raspberry Pi as default user: 
pi user and password: raspberry
Use "sudo" with every command.

Type the following commands:

[Part 1]: Installation of Samba and Mounting an external USB Hard Disk Drive.


1.> Install SAMBA on Raspberry Pi:


sudo apt-get update
sudo apt-get install samba samba-common-bin
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.copy

2.> Add support for NTFS drives:


sudo apt-get install ntfs-3g
sudo fdisk -l

>> Note down the drive name ( my 1TB drive was listed as: 
/sda1)

3.> Mount the harddrive and setup mount points:

sudo mkdir /media/WD1TB

4.> Configuring SAMBA:


sudo nano /etc/samba/smb.conf

Look for ############Authentication############## line

under which you need to remove the # symbol from the line: 

security = user 

and also copy paste the following lines at the end of the file:

[WD_1TB]
comment = WD_1TB
path = /media/WD_1TB
browseable = yes
writeable = yes
public = no
read only = no
valid users = pi


Use "ctrl+x" and then "y" and then "Enter" keys to Save and close the configuration file.

5.> Save and restart SAMBA service:
sudo /etc/init.d/samba restart

6.> Add Unix users: (no need to perform this step if Pi user is already exists)


sudo useradd pi -m -G users
sudo passwd pi

Enter the password twice to confirm.(Entered password will not be shown)


7.> Add pi user to SAMBA Users:


sudo smbpasswd -a pi

Enter the password twice to confirm.(Entered password will not be shown)

8.> Setup hard disk to mount automatically even if Raspberry Pi restarts:


sudo nano /etc/fstab

Enter the following line in the last and Save:


/dev/sda1 /media/WD1TB auto noatime 0 0

9.> Restart Raspberry pi:

      
sudo shutdown -r


By entering the samba user id and password in windows network, you should now be able to access your hard drive connected to raspberry Pi. 

[PART 2]: Installation of Transmission torrent client and configuration

10.> Installing Transmission Torrent downloader:


sudo apt-get update
sudo apt-get install transmission transmission-daemon transmission-cli

11.> Configuring Transmission:


sudo service transmission-daemon stop
sudo nano /etc/transmission-daemon/settings.json

Edit the following lines to your needs:


“rpc-enabled”: true,

“rpc-password”: “raspberry”,
“rpc-port”: “9091”,
“rpc-username”: “pi”,
"download-dir”: “/media/WD1TB/Torrent_Downloads”,
”incomplete-dir”: “/media/WD1TB/Torrent_Downloads”,
”incomplete-dir-enabled”: true,
"rpc-whitelist-enabled": false, 
Use "ctrl+x" and then "y" and then "Enter" keys to Save and close the configuration file.


12.> Creating a Downloads directory for Transmission:


cd /media/WD1TB
sudo mkdir Torrent_Downloads

13. > Start the Transmission daemon service:


sudo service transmission-daemon start

Test if the port 9091 is open:

sudo netstat -antup | grep 9091

14.> Adding Transmission to start-up automatically when raspberry pi starts:


sudo apt-get install chkconfig
sudo chkconfig --add transmission-daemon
sudo /sbin/chkconfig --level 2345 transmission-daemon on

15.> Adding User to transmission-daemon group and set up permissions:

sudo service transmission-daemon stop 
sudo adduser pi debian-transmission
sudo nano /etc/init.d/transmission-daemon
and edit the following:

USER=pi

sudo chown pi -R /var/lib/transmission-daemon/info/ 
sudo chown pi -R /media/WD_1TB/Torrent_Downloads
sudo chown pi -R /etc/transmission-daemon/settings.json 


16.> Start Transmission Daemon:


sudo service transmission-daemon start

17.> Accessing Transmission Webpage:


From any device connected to your same network,

open a browser and type:

http://192.168.2.100:9091

This will open Transmission Web-page where you can add, control and monitor your torrents.

Click on the wrench Icon at the bottom to open settings, Network and edit the port to 9092, save.

18.> Configuring Wifi-Router to forward ports for Transmission torrent downloader.


Check how to forward ports in wifi router here: Port Fowarding


Port forward ports 9091, 9092 for RPC(webserver) and Torrent respectively.


Restart the router if necessary and Raspberry Pi

After the download completes, they will automatically show up in the Network share we created in Part-1 of the tutorial.


Read more...

Thursday, November 11, 2010

How to setup webserver on linux operating system



A web server is a computer program that delivers (serves) content, such as web pages, using the Hypertext Transfer Protocol (HTTP), over the World Wide Web. The term web server can also refer to the computer or virtual machine running the program.

Basic steps in installing a Web-server:



1.> Connect yourself to any possible network and determine your system’s IP- address.

2.> By typing “ ifconfig –a ” in the terminal, or right-clicking on the network icon and choosing “connection information ”.

3.> Now, in terminal type: gedit /etc/httpd/conf/httpd.conf
This will open up a configuration document in gedit.

4.> You have to make changes in this configuration file as given in one of the three methods below.

5.> Once done you should restart/start the httpd server by typing: /etc/init.d/httpd start
This will restart the server with new settings in the config file.

6.> Next you should make entries in the host file by typing: gedit /etc/hosts
This will open up a host file in gedit, where you should type for example:
10.10.212.32 bvcoe.home www.abcd.com (note that you may have to make more such entries if you are hosting more than one webserver.)

7.> Now, you have to close it and restart the web server again by typing /etc/init.d/httpd restart.
You can check for working of webserver by typing: ping www.abcd.com

8.> Now open the web-browser and type the URL which you have defined.
You should see your page.

9.>To open you site in other computers you should switch off the fire wall of your computer by typing: /etc/init.d/iptables stop.
If you are hosting many servers you document root may be different or same for all servers.

10.> Test you webserver by typing in adderss bar of browser : 123.456.123.12:8080(your ip add) for port based hosting.
Other wise just the ip-address: 123.456.123.12
11.> To view your html page 123.456.123.12/yourpage.html

12.> To make your own directory in html directory:
Cd /var/www/html
Mkdir
Cd /var/www/html/

13.> Now you have to make a html page which will be stored in this folder.
By typing: gedit page1.html

This will open up a blank gedit editor where you have to type you html code for ex.



14.> Save the file and close. You html page is ready.







Experiment # 1
Web-server Installation
IP Based virtual hosting:

In IP-based virtual hosting the server is configured with multiple physical network interfaces, virtual network interfaces on the same physical interface or multiple IP addresses on one interface. IP-based virtual hosts use multiple hosts for different IP addresses but on same server. This allows running multiple websites, each with a different IP, on a single machine. This can be achieved by hosts that have multiple network connections, or by virtual interfaces.

For example, www.acn1.com and www.acn2.com have ip addresses 127.0.0.100 and 127.0.0.101 respectively and share the same web server. In this scenario, both www.acn1.com and www.acn2.com are registered with the standard domain name service registry as having the IP address 127.0.0100 and 127.0.0.101. A user types in the URL http://www.acn1.com in his browser. The user's computer resolves the name www.acn1.com to the IP address 127.0.0.100 and similarly www.acn1.com to the IP address:
127.0.0.100.
The web server can obtain the address the TCP connection was intended for using a standard API and use this to determine which website to serve. The client is not involved in this process and therefore (unlike with name based virtual hosting) there are no compatibility issues.



The main server can never catch a request, because all IP addresses of our machine are in use for IP-based virtual hosts (only localhost requests can hit the main server).




Experiment # 2 Web-server Installation

Name Based virtual hosting:

Name-based virtual hosts use multiple host names for the same webserver IP address. In name based virtual hosting multiple hosts are assigned same IP address.
Name-based virtual hosts allow multiple websites on a single IP address. This is in contrast to IP-based virtual hosts, where you need an IP address for each website. IP-based virtual hosts rely explicitly on IP addresses to determine the correct virtual host to the server. Name-based virtual hosts rely on the client to specify the hostname in the HTTP headers. Name-based virtual hosts are easy to configure, and do not require multiple IP addresses, and can, therefore, work in situations in which you are short of IPs.
For example, www.acn1.com and www.acn2.com have the same ip address 127.0.0.100 and share the same web server. In this scenario, both www.acn1.com and www.acn2.com are registered with the standard domain name service registry as having the IP address 127.0.0100. A user types in the URL http://www.acn1.com in his browser. The user's computer resolves the name www.acn1.com to the IP address 127.0.0.100. Server is created on the machine that has the IP address 127.0.0.100, so it receives the request. Server determines which virtual host to use by looking at the request URL.

Server configuration:



The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.domain.tld is first in the configuration file, it has the highest priority and can be seen as the default or primary server.



Experiment # 3
Web-server Installation
Port- Based virtual hosting:

The default port number for HTTP is 80. However, most webservers can be configured to operate on almost any port number, provided the port number is not in use by any other program on the server.
For instance, a server may host the website www.example.com. However, if they wish to operate a second site, do not have access to the domain name configuration for their domain name, and/or own no other IP addresses which they could use to serve the site from, they could instead use another port number, for example, www.example.com:81 for port 81, or www.example.com:8000 for port 8,000.
Setup: The server machine has one IP address (111.22.33.44) which resolves to the name domain.com. If we don't have the option to get another address or alias for our server we can use port-based virtual hosts if we need a virtual host with a different configuration.
Server configuration:




A request to domain.com on port 80 is served from the main server and a request to domain2.com on port 8080 is served from the virtual host.
Read more...

Related Posts Plugin for WordPress, Blogger...