Skip to content

OwnCloud Install Script

Nostalgist92 edited this page Jan 21, 2016 · 6 revisions

Owncloud Setup

This how-to is just a revised version of the one over here: http://forums.nas4free.org/viewtopic.php?f=79&t=1565

The instructions are essentially the exact same for 10.x but some people have been asking for a new thread so, here it is, updated, a bit cleaner and easier to read for the beginners.
I've also updated the script again today to grab the newest OwnCloud at the time of posting, 8.2.2. It works for both Embedded and Full releases.
Using a jail for OwnCloud helps prevent unwanted problems when you upgrade NAS4Free as upgrading N4F generally breaks OwnCloud.
Installing packages such as OwnCloud is better off in a jail as it also reduces the risk of breaking your NAS4Free system and if something goes severely wrong with a package in a jail, just delete the jail and try again with a fresh one rather than reinstalling the entire N4F system.

Requirements:

  • You need to have a fully working jail
    It is best to do this in a completely fresh jail. This guide will not tell you how to set one up, i may post a new guide with how to do so at a later date but for now you can visit TheBrig jail manager thread over here: view topic

  • You must now how to access your jails ssh
    I highly recommend PuTTY or KiTTY for this, just google one or the other, they are both easy to find or use the links below.

  • You will need the 'owncloud_injail.sh' script
    For method 1 you can download the script by right clicking the link in step 1 and choose "save link as"
    Method 2 doesn't require you to do this as the commands will grab it.
    Thanks to fsbruva for the original script. I've just modified it to work with the new pkg install system. If, for some reason, you are using an older version of NAS4Free which still uses pkg_add, head over to the original OwnCloud topic.

Optional, but recommended:

A few other notes as posted by fsbruva:
  • Will use lighttpd
  • Will use HTTPS only
  • Will only serve Owncloud (no other virtual servers)
  • Will use mysql (better)
  • Will use mysql sockets (much more secure)
  • Will utilize fast-cgi (as per owncloud's recommendation)
  • Will utilize fast-cgi sockets (much more efficient)

*** This script must be run at the command line, because it is interactive. There is no way to make it not so.
*** You will need to supply some info during the install:

  1. A new SQL database root password
  2. A private key password (you will enter it, confirm it, then enter it a last time to remove it)
  3. The necessary data for your self-signed cert to use for HTTPS. This is up to you, and doesn't really matter.

I will update this post with screenshots at some point, for now use raulfg3's ones as a temporary reference in the original thread which is linked above. Now that stuff is out of the way, let's get on with installing.


Installing:

There are 2 methods to get the script and run it. Using a mix of WinSCP+PuTTY or just solely using PuTTY
Pick only one of the methods. (I strongly recommend Method 2 - PuTTY only)
NOTE 1: You MUST make sure you edit the script BEFORE running it and modify the IP in the script to match your jails IP.
NOTE 2: When you are asked to define a password for MySQL, BE SURE TO REMEMBER IT. You will need this later.

WinSCP+PuTTY Method:

Run INSIDE A Jail

  1. Firstly, download the script. (Right click > save link as)
  2. Modify the file, editing the "server_ip" to match your jails IP.
  3. Log in to the jail with WinSCP and copy the script to /tmp
  4. Set execute permissions on the file
  5. SSH in to your jail and run:
    /tmp/owncloud_injail.sh
  6. Follow any prompts
  7. After everything is complete head to https://192.168.1.200:81 (changing the IP to your own)
  8. Finish the owncloud setup.

PuTTY Only Method:

  1. Log in to your jail (substitute "1" with your own jails id or name):
    jexec 1 csh

  2. Install nano (If you are asked about updating the package management system at this point, choose yes)
    pkg install nano

  3. Get the script:
    fetch -o /tmp/owncloud_injail.sh http://vengefulsyndicate.com/download/12097/
    If the above link fails, here are alternatives: (The above link is preferred as it will most likely be the only one that gets updating if needed)
    fetch -o /tmp/owncloud_injail.sh "https://raw.githubusercontent.com/Nostalgist92/misc-code/master/NAS4Free/OwnCloud/owncloud_injail.sh"

  4. Make it executable
    chmod a+x /tmp/owncloud_injail.sh

  5. Edit the script (Press Ctrl+X then Y then Enter to save your changes)
    nano /tmp/owncloud_injail.sh

  6. Run it
    /tmp/owncloud_injail.sh

  7. Follow any prompts

  8. After everything is complete head to https://192.168.1.200:81 (changing the IP to your own)

  9. Finish the owncloud setup.


Finishing Up:

Your owncloud can be accessed via a web browser using the following address:
**https://**192.168.1.200:81 obviously changing the ip above to reflect your jail IP.
Heading to this address you should be greeted with an OwnCloud page
Here you create the new user account and password to complete the installation.
Click on "Advanced", and click on "MySQL".
Type in root for the username, whatever root password you set during the database setup,
Pick a name for a database (doesn't matter), and leave the localhost part.
Click Finish Setup, and ENJOY!!!.


If you didn't pay attention to the installation note above, owncloud will not work and will be inaccessible.
You will have to modify lighttpd.conf which is located in /usr/local/etc/lighttpd.
Find the lines with 192.168.1.200 and modify it to reflect your jails IP.

If it's done right you should be able to run the following command and find that lighttpd starts and in turn, OwnCloud will be accessible.
/usr/local/etc/rc.d/lighttpd start
You "shouldn't" get any errors about write access during the OwnCloud setup but if you do for some reason you can remedy this using the following command in your jails shell:
chown -R www:www /usr/local/www/owncloud

While I do like to consider myself fairly knowledgeable, I am by no means an expert when it comes to this stuff but if you have any questions or problems feel free to post a reply and I, or someone else, will help wherever possible.
That should be it!
Happy uhh, Ownclouding? :D


Fixes for various problems if you encounter them:

Lighttpd startup error due to SSL:

Starting lighttpd.
(network.c.542) SSL: couldn't read X509 certificate from '/root/server.pem'
/usr/local/etc/rc.d/lighttpd: WARNING: failed to start lighttpd

See this post - http://forums.nas4free.org/viewtopic.php?f=79&t=1565&start=150#p61620

MySQL failing to startup because mysql user/group is lost:
http://forums.nas4free.org/viewtopic.php?f=79&t=1565&start=125#p57989