Volume 2: lighttpd: An Easy Fling

(This is part of My ownCloud Adventure)

While my initial foray into ownCloud was successful… Even if I did not see it all the way through…  I felt I needed to investigate a solution that would bet better suited for the limited hardware of my Raspberry Pi.

The path chosen was a brief dalliance with lighttpd.

Taking advantage of Win32 Disk Imager, I was able to write an image to the SD card with all the completed prep work that covered in the Preface.  This did save a good bit of time.

  1. sudo apt-get update
  2. sudo apt-get install lighttpd php5-cgi curl libcurl3 php5-curl php5-common php5-gd php-sml-serializer php5-mysql
  3. cd /etc/php5/cgi
  4. sudo nano php.ini
    • uncomment:  “cgi.fix_pathinfo = 1”
    • Not actually sure this is required, as a re-read of the description says that “1” is now the default value
  5. cd /etc/lighttpd
  6. sudo lighty-enable-mod fastcgi-php
  7. cd conf-available
  8. sudo cp 10-expire.conf 10-expire-myHost.conf
  9. sudo nano 10-expire-myHost.conf
    • Append
      • $HTTP[“url”] =~ “(css|js|png|jpg|ico|gif)$” {
        expire.url = ( “” => “access 7 days” )
        }
      • etag.use-inode = “enable”
      • etag.use-mtime = “enable”
      • etag.use-size = “enable”
      • static-file.etags = “enable”
  10. sudo service lighttpd restart

And with that the ownCloud first-run webpage should be accessible at https://server.ip.or.fqdn/owncloud.  Which leaves things in basically the same spot as the end of Volume 1.

After describing everything needed to get lighttpd up and running with ownCloud though, I’m hoping a detail was not left out… This does appear to live up to the “Easy Fling” description though.

Its possible this would have been the end of my adventure, except for one detail.  In the Preface I mentioned security… And while I have no particular knowledge or specific security concern to doubt lighttpd… I was a little put-off by the last update being over 9 months ago in November 2012.

And similarly, while I cannot speak to nginx’s security posture being better that lighttpd, it appears to be more actively maintained… Not to mention its quickly growing popularity.

Which leads us to… Volume 3:  nginx:  A Successful Foundation

Various References:

Volume 1: Apache2: A Heavy Duty Companion

(This is part of My ownCloud Adventure)

My adventure with ownCloud started out well, focusing on the goal of using Apache for my webserver, but it appears that some of my records were lost during my adventure… With the actual commands I used to install Apache now unavailable (i.e. never recorded to begin with).

So I’ll be providing what believe to be the best reconstruction (i.e. guess) that I am able to provide.

  1. sudo apt-get update
  2. sudo apt-get install apache2 php5-gd php5-curl  php5-cgi libapache2-mod-php5 php5-mysql libcurl3 php5-common php-xml-serializer
  3. cd /etc/apache2/sites-available
  4. sudo cp default mySite
  5. sudo cp default-ssl mySite-ssl
  6. sudo nano mySite-ssl
    1. edit:  SSLCertificateFile /etc/ssl/localcerts/mySite.fqdn.pem
    2. edit:  SSLCertificateKeyFile /etc/ssl/localcerts/mySite.fqdn.key
    3. save and exit
  7. sudo service apache2 stop
  8. sudo a2dissite default
  9. sudo a2ensite mySite
  10. sudo a2ensite mySite-ssl
  11. sudo service apache2 start
  12. Test:  https://server.ip/ownCloud
    1. If the certificates are working, you’ll have to tell your browser that you accept the risk of accepting a self-signed cert
  13. Assuming it worked…
    1. cd /etc/apache2/sites-available
    2. sudo nano mySite
      1. After “DocumentRoot” line, add…
        1. Redirect permanent / https://site.ip/
        2. or:  Redirect permanent / https://fqdn/
      2. save and exit
    3. sudo service apache2 reload

These instructions make a few assumptions that should be mentioned before progressing further.

  • The Preface has been followed
  • apache’s default root directory is “/var/www”
  • an owncloud directory (or symlink) exists at “/var/www/owncloud”

At this point, going to “https://site.ip.or.fqdn/owncloud” should bring one to the initial configuration page for ownCloud.  On a Raspberry Pi, with its limited hardware, It may take more than a few seconds to appear.

One last parting thought… Apache2 is a good webserver.  It has served me well over the years, but as the years have passed its put on some weight.  During this initial ownCloud endeavor… And it hit me when loading ownCloud for the first time…  I learned that there are other, less weighty (i.e. light) webserver options.

So in an effort to not repeat myself, its at this point that Volume 1 will wrap up, as I plan to go into more post-installation details at the end of Volume 3.

Until next time…  Volume 2:  lighttpd:  An Easy Fling

Various References:

 

Preface: Common ownCloud Path

(This is part of My ownCloud Adventure)

For any adventure to come to a successful conclusion, the proper preparations must first be made.

With my previous experience working with the Raspberry Pi I was able to quickly get a dedicated server setup and connected to my Synology NAS via NFS.

I should mention here, to plant a seed of thought, that throughout my endeavors the security posture of my system has been a constant consideration.  As an example, with my NFS configuration there are mounts available on my network that I did not give my ownCloud host access to… I am just not comfortable with some files being remotely accessible.

While not exhaustive, there are some common tasks that should probably be performed when setting up a new Raspbian instance:

SD Card Images

Throughout my adventure I made extensive use of Win32 Disk Imager to create images of the SD card.  This allowed me to configure common features once and just reload an image to start over if needed.

For example, I have an image that I created after performing my basic Raspbian updates and configurations.  After that I have an image with SSL certs and MySQL already taken completed.  This definitely made it much easier to go from Apache2, to lighttpd and finally end up at nginx with a “clean” system.

SSL Certs

To allow any of the webservers to utilize HTTPS, generating SSL certificates is the first task.  There are MANY resources available out there, but here are the basic commands I performed.

  1. cd /etc/sll
  2. sudo mkdir localcerts
  3. sudo openssl req -newkey rsa:2048 -x509 -days 365 -nodes -out /etc/ssl/localcerts/myServer.fqdn.pem -keyout /etc/ssl/localcerts/myServer.fqdn.key
  4. sudo chmod 600 localcerts/meister*

These commands result in 2 files as output:  a PEM certificate & a key.  Both are used by any webserver to enable HTTPS.

You will be asked a number of questions during key generation.  Since this results in a self-signed key, answer them however you like.  Except for the FQDN question, I’m not sure any of them even technically matter.  And in the case of the FQDN question, I didn’t care if its value matched my dynamic DNS name or not.

The one important technical detail is that if you do not want to enter a password every time your webserver starts, then do not enter a password when prompted.

Good Resources:

MySQL

ownCloud supports multiple database backends, but I chose MySQL since its familiar to me (although I do wish MariaDB were available in the Raspbian repository).

  1. sudo aptitude
    1. Install MySQL server
    2. The install will ask for a ‘root’ password for your new database server
  2. mysql_secure_installation
    • A script that performs a number of standard bets practice configurations.  Be sure to follow its recommendations!
  3. mysql -u root -p
    • No need to put your password in as an option, you will be prompted
  4. At the “mysql>” prompt
    • create database myOcDbase;
    • create user ‘myOcUser’@’localhost’ identified by ‘myUserPass’;
    • create user ‘myOcUser’@’127.0.0.1’ identified by ‘myuserPass’;
    • grant all privileges on myOcDbase.* to ‘myOcUser’@’localhost’;
    • grant all privileges on myOcDbase.* to ‘myOcUser’@’127.0.0.1’;
    • exit

Good Resource:  http://dev.mysql.com/doc/refman/5.5/en/index.html

Acquiring ownCloud

Getting a hold of ownCloud is not difficult and can be accomplished via various means.

I originally dabbled with manually adding an ownCloud repository to my system’s repo list.  I just followed the instructions found for Debian off ownCloud’s Linux packages install link.

  1. cd /etc/apt/sources.list.d
  2. sudo nano owncloud.list
    • Enter:  “deb http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/ /”
    • save and exit
  3. cd
  4. wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key
  5. apt-key add – < Release.key
  6. sudo apt-get update
  7. sudo apt-get install owncloud

While this method did work and is not a bad way to go, especially considering its many advantages… I was unsure of how quickly the repository would be updated with new versions, so I instead elected to go with the manual install.

  • cd
  • wget http://download.owncloud.org/community/owncloud-5.0.10.tar.bz2
    • As versions change, this link will change.  So be sure to get the latest Tar link.
  • tar -xjvf owncloud-5.0.10.tar.bz2
  • mv owncloud owncloud_5.0.10
  • cp -r owncloud_5.0.10 /var/www
  • cd /var/www
  • sudo chmod -R www-data:www-data owncloud_5.0.10
  • sudo ln -s owncloud_5.0.10 owncloud
    • Using a symbolic link in this fashion can help in the future with manual updates.  Just follow ownCloud’s manual update instructions and pre-position the latest version’s directory under /var/www and re-do the symlink for a quick and easy upgrade

And that seems to wrap up the common activities across each of the volumes in my adventure.

My ownCloud Adventure

I recently came across a project that very quickly caught my interest.

Its called ownCloud.

Its open source and gives you your own personal Drop Box like cloud.  It has a number of available features that could give one the ability to move off Google… If they work properly, which I cannot say at this time as I have yet to dive into those features.

If that all sounds interesting, I do encourage you to go take a look.

As the title says, getting my own ownCloud instance up and running has been an adventure.  As concerning as that may initially sound, I suppose I should clarify from the beginning that the adventure is ALL of my own doing.  Overall, the actual installation and configuration of my personal ownCloud instance has gone exceptionally smoothly… With only one, not so minor, issue.

The one “not so minor” issue is that the provided Gallery application does not work for me.  This may have something to do with the fact that I’m running ownCloud off a dedicated, but still resource limited, Raspberry Pi connected via NFS to a Synology NAS and (at this point) only have PHP configured to use 256MB of memory per script… But (without any evidence) I do believe there is an underlying issue with the gallery app.  I also believe it will be fixed in time.  So for me, patience is required…

Unless an alternative gallery app, such as Gallery2, fills the void.  Unfortunately, while it showed some initial promise by actually displaying my root picture folder, my inability to go below the root level found a bug…

I guess I’m just a natural at this software testing stuff.

Back to my adventure though…

I now have an ownCloud 5.x instance adequately running on a dedicated Raspberry Pi, using Raspbian for the OS and nginx as the webserver.  Its configured with SSL, PHP APC and MySQL.

(For apparently limited philosophical reasons I would have preferred to go with MariaDB, but at this time it is not available via the repositories, so my philosophical reasons appear to be limited as I preferred the easy install route rather than building MariaDB myself).

It seems I took a cue for many great adventures though, and given away the ending.  So I suppose its time to start the beginning…

I did not start with nginx.  My adventure actually started with Apache, as that’s what I’ve had the most experience using.  I also did not go from Apache straight to nginx.  I had a brief fling with lighttpd.

So for proper documentation purposes, I plan to detail my adventure across several “volumes”.

I did mention that I started with the ending, but I think I’ll continue following the popular adventure recipe and consider the ending more of a new beginning…