Tag Archives: ownCloud

Installing ownCloud and Lighttpd in FreeNAS (FreeBSD) Jail

I have been using ownCloud as a plugin in my FreeNAS server for about 6 months. I use it to sync the codes that I have been writing on my work desktop with the FreeNAS server at home so I can work on them wherever I go. There are a large amount of data that I am processing, using public services such as DropBox and Google Drive are not very practical and can be quite expensive. To be honest, it has served me well and I really liked it. The version I originally installed was probably version 8.0.

Unfortunately, I have this habit of hitting the upgrade link whenever the app prompted me. So far so good, until this Sunday! After upgraded to version 8.2.1, then the mapped folders on my FreeNAS server stopped showing, when I logged into my ownCloud server, even though I can see them correctly mounted when I ssh’ed into the server. When deleting and adding the jail storage for those folder again were of no avail, I ended up deleting the plugin jail and went on and install ownCloud 8.2.1 again in a brand new jail from scratch. Because I am doing it from scratch, I have done a bit of research before I started. This guide and video by Dr.KK have been extremely helpful. I followed his advice and chose the Lighttpd + sqlite of webserver/database combination. Because I am following his tutorials, the steps below are going to be same or very similar, nevertheless, I reproduce them here because some steps in the guides were not so clear to me and I’ve had hard time Googling for the answers I wanted.

1. Create a new FreeNAS jail for ownCloud
When you install ownCloud using the turnkey built-in FreeNAS plugin, it comes with Apache server and MySQL database. These are great packages but at the same time they are also resources hungry. For very few users and relatively few files, they are way overkill. On the other hand, we have very limited control over plugin jails – it can very messy trying to customizing them.

To create a FreeNAS jail, just click the Jails icon from the menu and then Add Jails. Choose Advanced Mode and give your jail a name – I use owncloud here, but obviously it can be anything you like.
Near the bottom of the advanced mode window, uncheck the box next to VIMAGE then click OKto continue. This will take a while if you have not set up a jail using the standard template before. Otherwise it finishes in only a few ten seconds.

2. Compile and install ownCloud
There are a couple of ways to log into the jail that you have just created. Either ways, if you are using Windows, you need to download putty or Bitvise ssh client. Once you are connected to your FreeNAS server via ssh, use jls command to find out the JID of your ownCloud jail then jexec [JID] /bin/csh to log in to your jail as root.
jlsYou can also enable sshd for the jail itself and ssh in directly. To do this, copy the ssh directory in etc/ to your jail in the main FreeNAS command line:

Now go back to your FreeNAS GUI, access the command line of your owncloud jail and perform the following steps:

Now log in your ownCloud jail through whatever route you prefer and:

Update the installed packages then fetch updated list of ports. This will take a while. Once it’s done:

You now have the option to disable MySQL and enable sqlite. Click OK and start the building and installing process with:

This process will take a LONG time, make yourself a coffee sit back and relax until it finishes.

3. Install and configure Lighttpd web server
Lighttpd, pronounced “lighty”, is pretty bad ass, it is very fast and lightweight. Youtube and Wikipedia used to use Lighttpd as their web server.

To install:

Run the following command to clean up the unused installation files at this point.

Configure server:
Open the Lighttpd configuration file:

Make changes to the following lines, save and exit nano:

Enable CGI support:

Uncomment out the line below “plain old CGI (mod_cgi):

In the Youtube video DrKK explained why you should choose plain old CGI over other modules.

Start your Lighttpd server to see if it works.

If everything was setup correctly, you should be able to see the log in window when point your browser to the ip address of your ownCloud server.

4. Configure ownCloud
Setup and log into your admin account following the simple steps of the initial ownCloud setup interface. These steps are relatively intuitive and straight forward. It’s not necessary to repeat them here. Once you are logged in, head to the drop down menu at the top right corner to access all the admin tasks.

Unlike previous versions, after this update (8.2.1), to enable mapping your existing Freenas drives/volumes/directories (whatever you call them), you need to install a third party app called External Storage Support. Detailed configuration steps can be found in the ownCloud Admin Manual.

5. Configuring PHP
In the Admin page of ownCloud, you may notice that your upload file size is limited to 513MB. To change this setting you need to edit the file .user.ini resides in /usr/local/www/owncloud, not the php.ini that you are told by many installation guides in the Google search results. They are probably talking about Apache/Nginx servers. For Lighttpd, this file is what you MUST modify to change the limit. Unfortunately, it appears that every time you use a pkg upgrade command to upgrade the installed packages, this file may get overwritten. You then have to change the settings again.

6. Create SSL certificate and Enable SSL support
Follow Steps 12 and 13 in DrKK’s guide create and enable SSL for your ownCloud server.
Restart your Lighttpd to test the new settings:

If everything works well:

Congratulations! Finally you have a running ownCloud that is fast and takes up very few resources.