Social Icons

Showing posts with label own cloud. Show all posts
Showing posts with label own cloud. 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...



How to setup ownCloud 7 on Raspberry Pi





This is the second installment of the guide to install ownCloud on Raspberry Pi. Our earlier guide was for ownCloud 5.0.20 (Enterprise Edition) and can be found here.

There has been certain changes with the latest version of ownCloud 7, and this guide should be able to help you to sail through smooth. Without much ado about what is ownCloud (which you already know) let's dive deep into tech details.

Following software / packages we will be using for this setup, ideal for a personal cloud on Raspberry Pi:
  • ownCloud 7
  • Nginx
  • OpenSSL
  • php 5
  • Raspbian Wheezy
1. Tuning up the Raspberry Pi
Following changes needs to be made under Raspberry Pi configuration
sudo raspi-config

a. Expand the root filesystem to have enough space for the cloud
    Select "Expand Filesystem"

b. Change locale to en_US.UTF8
    Select "Internationalisation  Options"

c. Memory split, allocate 16M to video graphics (if you are not using X-server)
    Select "Advanced Options" --> "Memory Split"

d. Overclock to Modest or Medium (Optional Step)
    Select "Overclock" (You might have to reboot if asked)

2. Updating the package lists on Raspberry Pi
  sudo apt-get update
    sudo apt-get upgrade

3. Creating users (Raspbian might already have is user & group)
    sudo groupadd www-data
    sudo usermod -a -G www-data www-data

4. Installing the packages
    sudo apt-get install nginx openssl ssl-cert php5-cli php5-sqlite php5-gd php5-common php5-cgi sqlite3 php-pear php-apc curl libapr1 libtool curl libcurl4-openssl-dev php-xml-parser php5 php5-dev php5-gd php5-fpm memcached php5-memcache varnish


5. Make sure php5-curl is not installed
    sudo apt-get --purge remove php5-curl

6. Creating your SSL certificates for 2 years
    sudo openssl req $@ -new -x509 -days 730 -nodes -out /etc/nginx/cert.pem -keyout /etc/nginx/cert.key

   
sudo chmod 600 /etc/nginx/cert.pem
   
sudo chmod 600 /etc/nginx/cert.key

7. Configuring Ngnix web server
    sudo nano /etc/nginx/sites-available/default

    Copy and replace the entire content below:
    Note: You'll have to replace technet.example.com with the local IP of your Raspberry Pi or the domain name (make sure it matches with the details you have provided to create the certificate, else ownCloud won't work). If you have planned instead to use any Dynamic DNS domain, then use your  domain name instead of the local IP address. You can follow our guide for setting up a Dynamic DNS domain.

8. Configuring max upload limit in php
    sudo nano /etc/php5/fpm/php.ini

    Tip: Use ctrl+w to search below lines and update:
    upload_max_filesize = 1000M
    post_max_size = 1000M

9. Configuring PHP 
    sudo nano /etc/php5/fpm/pool.d/www.conf
    Change the following line from:
    listen = /var/run/php5-fpm.sock
    to 
    listen = 127.0.0.1:9000

    sudo nano /etc/dphys-swapfile
    Change the following line from:
    CONF_SWAPSIZE=100
    to 
    CONF_SWAPSIZE=512

10. Restart web server and Php
    sudo /etc/init.d/php5-fpm restart
    sudo /etc/init.d/nginx restart

11. Install ownCloud (version 7.0.1 used here)
    sudo mkdir -p /var/www/owncloud
    sudo wget https://download.owncloud.org/community/owncloud-7.0.1.tar.bz2
    sudo tar xvf owncloud-7.0.1.tar.bz2
    sudo mv owncloud/ /var/www/
    sudo chown -R www-data:www-data /var/www
    rm -rf owncloud owncloud-7.0.1.tar.bz2

12. Setup admin account
     While setting up the admin account you should provide the path to your data folder. You can ideally set this to your NAS drive or external drive which you may have mounted. Owncloud will complain and not proceed with admin account if the data directory path is not readable & writable by the user www-data. Also it should not be readable by "others". You can refer to our guide here for setting up appropriate permission before proceeding to create the admin account.
     Now in the browser, login to the ip address of Raspberry Pi or if you have configured your domain name then use that and set up the admin account.
    https://yourdomain.com    or    https://192.168.XXX.XX


That's all... Celebrate the fun... Fly high on clouds... and if you liked this guide, got benefited or feel worth reading kindly do share with your network, and share your comments.