#cloud #raspberrypi #linux #storage
"CLOUD" a word that no-one knows exactly what the hell it really means, but it sure is something isn't it? We can cloud it up all day long if we want, cloudy cloudy cloud. But what if I told you that you were capable of making your own cloud? Capable all by yourself of having 3TB of cloud storage all to yourself, accessible everywhere? Time to get awesome. Before we begin, I'm not going to take full credit for this, it was an instructable by a user named koff1979, I followed his instructions and they were AMAZING!!! A few tweaks did have to be made though.
(original instructables: http://www.instructables.com/id/Raspberry-Pi-Owncloud-dropbox-clone/)
To start all you're really going to need is two parts.
- A raspberry pi
http://www.adafruit.com/products/1914?gclid=CJaU2tSOwcUCFcQUHwod5UEAKg - And external storage of any capacity
http://www.newegg.com/External-Hard-Drives/Category/ID-344
There are standard tools you'll need such as a display and a keyboard, but that's somewhat of a given when it comes to working anything computers. An enclosure is suggested but not required. As a matter of fact mines kind of just sitting on the counter. Sure it doesn't exactly look elegant, but it does the job.
When you configure your Pi, use the most recent release of Raspbian if possible. The one released on 05-05-2015 is the one I used, and was ten times easier than the version that requires internet connection to install. I spent about 3 hours trying to install with that version, and it was nothing but problematic.
For links to the Raspbian download here you go.
https://www.raspberrypi.org/downloads/
To start lets assume you've already got raspberry pi installed, you're using your command line interface, and its great. You're going to want to jump over to sudo su to do everything, I found a few issues working with some commands when not using sudo su.
When you configure your Pi, use the most recent release of Raspbian if possible. The one released on 05-05-2015 is the one I used, and was ten times easier than the version that requires internet connection to install. I spent about 3 hours trying to install with that version, and it was nothing but problematic.
For links to the Raspbian download here you go.
https://www.raspberrypi.org/downloads/
To start lets assume you've already got raspberry pi installed, you're using your command line interface, and its great. You're going to want to jump over to sudo su to do everything, I found a few issues working with some commands when not using sudo su.
sudo nano /etc/network/interfaces
Your ip address is going to be set to DHCP and we're going to need a static IP to make this work and you're going to want to make changes under the iface etho0 part like so.
auto eth0
iface eth0 inet static
address 192.168.1.XXX
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
Your ip range may be different, if you're using 10.1.1.X or anything similar, please make the required adjustments. Once you've made the changes above hit ctrl + o to write the file and then ctrl + x to exit. Now we need to restart the networking service.
sudo /etc/init.d/networking restart
Now that the network interface is we're going to need to force an update.
sudo apt-get update
All updates will be processed, system will be fully updates and ready for the next step. Installing Apache with SSL, PHP5, PHP APC, this will take some time to load, its going to be a lot.
sudo apt-get install apache2 php5 php5-json php5-gd php5-sqlite curl libcurl3 libcurl4-openssl-dev php5-cirl php5-gd php5-cgi php-pear php5-dev build-essential libpcre3-dev php5 libapache2-mod-php5 php-apc gparted
For those unaware all the above, for the most part are web applications, Apache with SSL is a web service with SSL encryption, and PHP is a web language. We're going to implement a PHP application to run over the internet.
Now that the software has been download, its time to install.
sudo pecl install apc
This is going to install the apc service on php, which increases the speed of php. Now we need to create the apc.ini
sudo nano /etc/php5/cig/conf.d/apc.ini
We need to enter the following information into this file, the file will be empty so don't be alarmed.
extension=apc.so
apc.enabled=1
apc.shm_size=30
Next we need to change an entry in the php.ini file to increase the upload limit. I did fine a few discrepencies between the instructables and what I did, I'm not sure if its just a lack of understanding on my end, but I did modify this part.
sudo nano /etc/php5/apache2/php.ini
You're going to look for a part of the file that says upload_max_filesize you're going to want to alter this to most likely somewhere above a gigabyte, the maximum is 11GB, so choose somewhere between 1 and 11 and make it look like so 10G or 8G. The original will say something like 1024M. I tried inserting a larger M to see if it would convert to GB, but for some reason it just said MB instead. Yeah I have much larger than 8MB files.
Inside this same file you're going to want to look for a section that says extension= and modify it to say extension=apc.so
Yes this is the longest part, finding small lines of code is very tedious, but it must be done to make it work, trust me its worth it. Now we need to configure apache and enable SSL
sudo nano /etc/apache2/sites-enabled/000-default
In this file you're going to need to change Allow over ride to All from none
(This part I didn't come across, I entered the above command and nothing came up, seems to be running fine without it, sure there is some sluggish behavior, but I'm running over a powerline adaptor I'm not expecting much. I'll check later and see if I should run this again and it may increase speed? I don't know.)
Onward to setup SSL
sudo a2enmod rewrite
sudo a2enmod headers
After that is done type in the below command
sudo openssl genrsa -des3 -out server.key 1024; sudo openssl rsa -in server.key -out server.key.insecure;sudo openssl req -new -key server.key -out server.csr;sudo openssl x509 -req 365 -in server.csr -singkey server.key -out server.crt;sudo cp server.crt /etc/ssl/certs;sudo cp server.key /etc/ssl/private;sudo a2enmod ssl;sudo a2ensite default-ssl
This will configure all of your SSL requirements and create a nice safe security net. Now time to quickly restart apache and move on to the cloud software.
sudo service apache2 restart
Time to download owncloud. I ended up going through the GUI to download, I couldn't seem to get this command to work, and since 4.5.1 is retired, the same command doesn't work, but the below command should work and includes the latest version of owncloud (as of 5-14-2015 of course)
wget https://download.owncloud.org/community/owncloud-8.0.3.tar.bz2
Now that it's downloaded, unzip and extract all the information.
sudo tar -xjf owncloud-8.0.3.tar.bz2
And then copy to the web root
sudo cp -r owncloud /var/www
Now that it has been trasnferred to the root, its time to give the web service access to that directory.
sudo chown -R www-data:www-data /var/www/owncloud
Before we setup owncloud, we need to open the following file and change the value to what was set in php.ini
sudo nano /var/www/owncloud/.htcaccess
Time to jump into the GUI by entering the below command
startx
Be patient it's not an instant running situation, it'll take about a minute to load.
While inside the gui open up the terminal program, if you don't have a mouse, hitting the windows button on your keyboard opens the start menu and you can scroll to accessories using your arrow keys. Now we set up your partition.
sudo gparted
From here choose the drive you need to format, once again based on your drive size this could take a while. Finally time to give your cloud service access to that drive.
sudo chown -R www-data:www-data /media/owncloud
The external storage is now registered as the owncloud, from any browser inside the local network enter the ipaddress of the pi followed by /owncloud. http://IPADDRESS/owncloud
It'll ask some simple configuration information and you're good. Configure port forwarding on your firewall and you have external access to your cloud storage.
There it is, you have yourself a fully functional cloud drive, as I said I set up a 3TB HDD and gave each of my brothers complete access. They now have access from anywhere in the world to 3TB of storage. But as previously stated its not super fast in my situation, I may move it and plug it directly into the router opposed to over powerline adaptors into a corner of nowhere.
This brings me to question for my readers, in terms of enclosures what would be cooler, a hand made wooden TARDIS with an 80mm fans for cooling? Or a plastic lump that you can buy at a store. Please let me know in the comments below, I may go and design a custom enclosure for everything.
Lastly I'd like to reiterate this wasn't 100% designed by myself, koff1979 over on instructables was responsible for the initial code and design. I did do some modifications as required for the newer versions of the programs, as well as a few changes to what the code said. It is in no way shape or form me taking credit for his work, he deserves the credit, I just wanted to recreate it with updated information. So once again koff1979 I applaud you, your code and design works beautifully.
This brings me to question for my readers, in terms of enclosures what would be cooler, a hand made wooden TARDIS with an 80mm fans for cooling? Or a plastic lump that you can buy at a store. Please let me know in the comments below, I may go and design a custom enclosure for everything.
Lastly I'd like to reiterate this wasn't 100% designed by myself, koff1979 over on instructables was responsible for the initial code and design. I did do some modifications as required for the newer versions of the programs, as well as a few changes to what the code said. It is in no way shape or form me taking credit for his work, he deserves the credit, I just wanted to recreate it with updated information. So once again koff1979 I applaud you, your code and design works beautifully.
This was a fun project, so anyone out there who is afraid, really the step by step was beyond easy. You don't have to know what you're doing for it to work, but a little hands on education never hurt.
ReplyDeleteAnd yes I know I need to clean my office and desk :-P, lots of dust and debris.
ReplyDelete