Social Icons

Showing posts with label raspberry. Show all posts
Showing posts with label raspberry. Show all posts

Install OwnCloud 8 with Nginx and MySql on Raspberry Pi

This article has been long due from our side since OwnCloud 8 has been released, the product is pretty stable and popular now with the latest stable release of version 8.1.1

Like previous iterations, keeping in mind the small footprint and power of Raspberry Pi we would be using following components:
  • Nginx (as Webserver instead of Apache, as it would be faster)
  • MySql
  • Php 5
So without much ado, let get straight into Business...

Step 1.
Update the repositories
sudo apt-get update

Step 2.
Install MySql
sudo apt-get install mysql-server

Enter a password for root account when prompted, and do remember it :)














Step 3.
Let's now configure the mysql so that it runs better on our tiny resource tight Raspberry Pi
Backup existing config
sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak

Use a suitable config for Raspberry Pi
sudo cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf

Edit the config file
sudo nano /etc/mysql/my.cnf

Find the [mysqld] section of the file and place the following line in it:
query_cache_size = 8M

Step 4.
Now we will connect to the database and created required db objects and users
mysql -u root -p

Execute the following at MySql prompt (change the fields in red as per your setup)
CREATE DATABASE owncloud;
CREATE USER techjawab@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON owncloud.* TO techjawab@localhost;
FLUSH PRIVILEGES;
exit;


Step 5.
Install Php5 and related libraries
sudo apt-get install php5-mysql openssl ssl-cert php5-cli php5-common php5-cgi php-pear php-apc curl libapr1 libtool php5-curl libcurl4-openssl-dev php-xml-parser php5-dev php5-gd memcached php5-memcache

Step 6.
Install Nginx
sudo apt-get install php5-fpm nginx

Step 7.
Install and configure OwnCloud
Create directories required for owncloud
sudo mkdir -p /var/www/owncloud
cd /var/www/


Download OwnCloud and set permissions
sudo wget https://download.owncloud.org/community/owncloud-8.1.1.tar.bz2
sudo tar -xvf owncloud-8.1.1.tar.bz2
sudo chown -R www-data:www-data /var/www


Create SSL certificates for https connection
sudo mkdir -p /etc/nginx/ssl
sudo openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /etc/nginx/ssl/owncloud.key -out /etc/nginx/ssl/owncloud.crt

Configure owncloud
Edit the below file and copy - paste the config given below
Note:  Remember to edit your domain name or ip under "server_name" field both for http and https
sudo nano /etc/nginx/sites-available/owncloud



Enabling owncloud settings
sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/owncloud
sudo unlink /etc/nginx/sites-enabled/default


Configure Php FastCGI Process Manager
sudo nano /etc/php5/fpm/php.ini


Set the following values accordingly in the config file, change value for upload directory according to your setup

default_charset = "UTF-8"
upload_max_filesize = 10G
post_max_size = 10G
upload_tmp_dir = /mnt/usbstorage/owncloud/tmp
max_input_time = 360000
#The maximum time in seconds a script is allowed to parse input data.
max_execution_time = 360000
memory_limit = 512M
extension=memcached.so
extension=memcache.so


Restart the services
sudo service nginx restart
sudo service php5-fpm restart


Create directories for owncloud on your mounted external storage
sudo mkdir -p /media/NASDRIVE/owncloud
sudo chown -R www-data:www-data /media/NASDRIVE/owncloud


sudo mkdir -p /media/NASDRIVE/owncloud/tmp
sudo chown -R www-data:www-data /media/NASDRIVE/owncloud/tmp


Step 8.
Open Browser and browse to your domain name or ip address


You would need to setup the following:
  • setup admin username / password
  • Provide the owncloud storage path created above
  • Provide database name, username and password created in step 4, and click "Finish setup"













Viola, you have your "own"cloud up and running now...



Install MiniDLNA on Raspberry Pi



*These steps works both on Raspbian Wheezy & Jessie*

Install MiniDLNA
sudo apt-get update
sudo apt-get install minidlna


Open and edit MiniDLNA's configuration file
sudo vi /etc/minidlna.conf

Configure your media directory
media_dir=V,/media/NASDRIVE/Movies

Note:
Adding "V," as prefix to the path will restrict the media dir to video content type.
Similarly, "A," for Audio and "P," for pictures respectively.

Set a name for your DLNA servers, this will show up on clients
friendly_name=RasPiDLNA

Set inotify to yes to let MiniDLNA automatically pick up file / media changes
inotify=yes
notify_interval=300 

Un-comment the line
log_dir=/var/log

Add minidlna user to pi group
sudo usermod -a -G pi minidlna

Force Restart MiniDLNA to let it build it's media database
sudo service minidlna force-reload

Check the logs at /var/logs (check if your media library is being indexed)
tail -f  minidlna.log



Viola... Your video collection should soon  show up on your DLNA devices :)

Dynamic DNS the easy way

THIS GUIDE IS NOT VALID ANYMORE SINCE dns4e.com IS NOT AVAILABLE ANYMORE
PLEASE REFER TO OUR OLD GUIDE HERE
In a previous post quite sometime back we explained how to configure a DynDNS service on your Raspberry pi or any similar unix system. This is no different, except for the super easy way of doing the similar thing.

Here we would be using the free DynDNS service of dns4e.com

Step. 1
Goto to https://dns4e.com/registration and sign up

Step. 2
Verify the registered email to activate the service

Step. 3
Add a zone in your account (e.g.: techjawab.dns4e.net)
You can add your own host (which you might have bought separately), in that case you will also need to update the name-servers after this step.

Step. 4
Setup a cron job to update your dynamic ip to dns4e
sudo crontab -e

In the editor add the following line on a new line to update your DNS every 10 minutes
*/10 * * * * curl 'https://api.dns4e.com/v7/<zone address>/a' --user '<Public Key>:<Secret Key>' --data '' -X POST

That's all, you should be able to reach out to your hosted server via the zone address you just configured after the DNS propagates.

Note: If your raspberry pi or unix box is behind a router or firewall then you might have to do port forwarding accordingly to enable the outside world to reach your server.

How to install Transmission on Raspberry Pi (with external storage)


Well there are already many guides on this topic, however, what I found is not all are in complete detail, or misses out on something of the other (completely personal opinion though :) ). Here comes my guide to install Transmission BitTorrent client on headless Raspberry Pi. This will especially be helpful for users who have followed my guides on setting up NAS drive with RasPi.

Let's Start...

Step 1
Install transmission
sudo apt-get update
sudo apt-get install transmission-daemon

Step 2
Create required directories on your NAS storage (path to storage is assumed as /media/NASDRIVE)
mkdir -p /media/NASDRIVE/Torrent_inprogress
mkdir -p /media/NASDRIVE/Torrent_complete

Step 3
Permissions
Transmission by default runs with user "debian-transmission", as it is recommended not to change this due to security reasons. In our setup the NASDRIVE has the permission set as 770 for pi : pi. Thus we will add user "debian-transmission" to "pi" group to give rwx access on our NASDRIVE. You can go ahead and modify this step as per your security requirement, but just make sure your torrent download directories are having rw access for "debian-transmission" user.
sudo usermod -a -G pi debian-transmission

Step 4
Configure Transmission
While most of the parameters are self explanatory in the conf file, you can use the file given below, except for modify the parameters download-dir, incomplete-dir, rpc-username, rpc-password 
Note: rpc-password will automatically converted to hashstring on saving the file
sudo nano /etc/transmission-daemon/settings.json


Step 5
Reload Transmission
Do not restart, It overwrites the configuration file in that case
sudo service transmission-daemon reload

Step 6
Open web browser and hit http://your_raspberry_pi_IP:9091
Enter the user id and password you've configured, and viola!

How to configure Static IP on Raspbian (Raspberry Pi)

It's a common requirement to have a Static IP address assigned to your Raspberry Pi, as it makes life a lot easier to SSH into a box for which you know the IP address, instead of looking around in your router's pages.

This guide is for Raspbian OS for Raspberry Pi, and also tested on B+ model

Log on into Raspbian onto command line and list the network interfaces currently available:
cat /etc/network/interfaces



Note, eth0 is by default configured as dhcp (dynamic ip address)

We will change this behavior to static.

Before we proceed we need to determine the following information. All of these you can easily determine if you have setup your local network (wifi router/switch/hub/etc..), alternatively if your have your Raspberry Pi connected to LAN (eth0) you can run the following commands to get details:
ifconfig



Now note the following values:
inet addr:192.168.2.2
Bcast:192.168.2.255
Mask:255.255.255.0


Next get the Gateway and Destination address (ideally your router IP addess, or use below command):
netstat -nr

Gateway Address – 192.168.2.1
Destination Address – 192.168.2.1

Now, we will edit config and set the static ip details:
sudo nano /etc/network/interfaces


Change the line that reads:
iface eth0 inet dhcp

to

iface eth0 inet static

Next enter the details that you have collected in previous steps:

address 192.168.2.2                Pi's IP address
netmask 255.255.255.0           Mask address
network 192.168.2.1                Destination address
broadcast 192.168.2.255      Broadcast address
gateway 192.168.2.1          Gateway address



Now reboot your Raspberry Pi, and next check the config once again:
sudo reboot

after reboot
ifconfig


That's all folks!