Showing posts with label rPi. Show all posts
Showing posts with label rPi. Show all posts

Saturday, April 6, 2013

The Big Move

Growing up

I have recently decided to start playing with the grownups. In the past few months, I have moved from using a Raspberry Pi for my webserver, to using a remotely hosted Virtual Private Server(VPS).

My previous post on OwnCloud on the Raspberry Pi has garnered a bit of attention, and seems to have helped a few people out. I couldn't be happier about that! Unfortunately, the Pi has gone dormant for the past few months as I had moved my OwnCloud instance to an old laptop with a bit more RAM and beefier processor.

On to the VPS

Alas, I have also managed to outgrow the laptop. I feel that the laptop was always a stopgap measure, because it is eventually going to be converted into a digital picture frame, but since I keep messing with these web-services, the start date keeps getting pushed back for that little project. This past week, I moved to VPS. I found it on LowEndBox.com for $3.95 per month, from WillHosting.com. Now, this isn't the most powerful VPS, but it has 512MB of RAM, two CPUs, and 60GB of storage. It also runs CentOS, which seems to be a bit of a Fedora derivative. I also get 1TB of bandwidth a month. I am pretty impressed, for $4/month.

Now, I have managed to set up a new instance of OwnCloud, and have also tacked on an instance of Tiny Tiny RSS(TT-RSS). I was heartbroken about Google's big spring cleaning news, so I took it upon myself to make sure that no one can take my RSS reading addiction away again.

A Real Database

I did something a little different this time 'round. Instead of relying on SQLite for OwnClouds database, I decided to do a full jump into MySQL. Either MySQL or PostreSQL is required for Tiny Tiny RSS, so I figured it was time to step into the big database world. It was not too difficult to run some searches to figure out how to build the tables required, to create MySQL users for each service, but I am starting to look into database optimization.

Why optimize something that is only used by one person? Well, on day 2 of using the services, particularly TT-RSS, I noticed a major slowdown. It didn't really seem that the server was under any kind of load, but I was worried that there was something wrong with the MySQL database. After running mysqltuner.pl, I found out that, compared to the instance on my laptop, that there was no caching being done of any of the queries or threads. So, I managed to set those up and have been noticing a steady increase in speed. I also learned that since TT-RSS uses innoDB that I should look into a few other issues. I have not had a chance to try the steps listed in that guy's threads, but I hope to do it soon.

To the Future

Another reason that I decided to implement a more robust database service is because I am planning to start offering these services to friends and family. I am getting ready to start what I am dubbing an 'Internet Services Cooperative.' 

On a Quick Side Note

I have also managed to finally move away from using GoDaddy for my domain registrar and moved to NameCheap! It was an amazingly smooth transition.

Thursday, October 25, 2012

ownCloud on a Raspberry Pi

This is a project that I have wanted to do for quite a while now. I finally got a free day this previous weekend, so I thought I would dedicate a little time to playing with the Raspberry Pi. The Raspberry Pi, for those not in the know, is a $35 ARM powered computer that is about the size of an Altoids Tin. I only had a day for my project and decided that setting up ownCloud would be interesting. ownCloud is an alternative to many different cloud services, such as file storage (Dropbox, Google Drive, SkyDrive, etc.), calendars (Google Calendar, etc.), music player (Google Music), personal picture viewer (Picasa, flickr,etc), and others. It has quite a few interesting features and is very actively developed.

Setting Up the Raspberry Pi

The Raspberry Pi is surprisingly easy to set up with Raspbian, and I was off and running in no time. I would go through the details, but I followed the Raspberry Pi Wiki article on SD card setup. I was able to use SSH to login after the first boot, so I did not even have to plug it into my TV. I did not do anything special with the configuration of my Pi, but I plan on activating the turbo setting in the firmware, so I can get the processor speed up to 1Ghz.

Setting Up nginx and PHP

In order to run ownCloud, you need a webserver and PHP. Apache can be a bit big for the Pi which only has 256MB of RAM (they now come with 512MB), so I chose to install nginx and PHP-FPM
aptitude install nginx php5-fpm php5-sqlite php5-gd
 Then, create a file in /etc/nginx/sites-available/. I called mine owncloud.vhost:
# redirect http to https.
#server {
#  listen 80;
#  server_name owncloud.example.org;
#  rewrite ^ https://$server_name$request_uri? permanent;  # enforce https
#}

# owncloud (ssl/tls)
server {
  #listen 443 ssl;
  listen 80;
  #ssl_certificate /etc/nginx/certs/server.crt;
  #ssl_certificate_key /etc/nginx/certs/server.key;
  #server_name localhost;
  root /usr/share/nginx/www/owncloud;
  index index.php;
  client_max_body_size 1000M; # set maximum upload size

  # deny direct access
  location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
    deny all;
  }

  # default try order
  location / {
    try_files $uri $uri/ @webdav;
  }

  # owncloud WebDAV
  location @webdav {
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param HTTPS on;
    include fastcgi_params;
  }

  # enable php
  location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param HTTPS on;
    include fastcgi_params;
  }
}
I actually got the majority of this file from ownCloud.org. Then create a soft link to /etc/nginx/sites-enabled:

ln -s /etc/nginx/sites-available/owncloud.vhost /etc/nginx/sites-enabled/

Note: I removed the default server in sites-enabled.

I then modified /etc/php5/fpm/php.ini to include the following:

extension=sqlite.so
extension=zip.so
extension=json.so
extension=xmlrpc.so
extension=curl.so
extension=gd.so

Installing ownCloud

I downloaded the gzipped tar of ownCloud 4.5 from ownCloud.org, then decompressed it and copied it to /usr/share/nginx/www/owncloud.

Then,

sudo chown -R www-data:www-data /usr/share/nginx/www/owncloud

You should now be able to start nginx and php-fpm, then using your web browser to go to the IP address of your Pi, and BOOM! ownCloud!