Thursday, November 3, 2011

Installing OwnCloud on Openshift Express PaaS

Updated Friday May 25th to cover OwnCloud 4!

OpenShift Express is a free Platform as a Service (PaaS) solution provided by Red Hat. It allows developers to quickly and easily deploy their applications on cloud servers while Red Hat handles the management overhead.

Currently OpenShift Express supports applications created in a number of languages including PHP, Java, Ruby and Perl. As well as allowing developers to quickly and easily deploy their own applications OpenShift provides an easily accessible test bed for off the shelf open source web applications.

I am going to demonstrate quickly setting up OwnCloud. OwnCloud is a project aimed at providing users with the same abilities as many commercially backed personal clouds but with the ability to deploy it anywhere you choose.

Today our infrastructure of choice is provided by OpenShift but an OwnCloud installation can just as easily exist or be moved to a virtual private server, or the machine in your basement.

Register and Obtain Client Tools

Register With OpenShift Express, the registration page is available from  https://openshift.redhat.com/app/login. As part of the sign-up process you will also be prompted to create a key and install the client tools for OpenShift Express.

Create a Domain

If you did not do so during registration then you need to create an OpenShift domain. At the time of writing each user is permitted one domain name and five applications. The URLs for your applications will take the form:

http://<application_name>-<domain_name>.rhcloud.com/

The rhc-create-domain tool is used to create a domain, providing a name for the domain and your OpenShift login credentials:

$ rhc-create-domain -n <domain_name> -l <login>

The tool prompts you for your password and, assuming it isn't already taken, creates the domain.

Create the Application
Before you can deploy OwnCloud you must create a stub application in the format that OpenShift understands. OpenShift adds application support for programming languages, frameworks, and even databases based on 'cartridges'.

Because OwnCloud is written in PHP we will be using the php-5.3 cartridge to create the application. Then to provide MySQL support we will also add the mysql-5.1 cartridge.

Use the rhc-create-app tool to create the application, providing a name for the application and your OpenShift login credentials. You will also need to provide the password associated with your key, created during registration, to complete application creation.

Note that by default the local copy of the application is created in your current working directory. This is where you will update and deploy your application from.

$ rhc-create-app -a <application_name> -l <login> -t php-5.3

Now use the rhc-ctl-app to add MySQL support.

$ rhc-ctl-app -a <application_name> -l <login> -e add-mysql-5.1

Be sure to take note of the Root User, Root Password, Database Name, and Connection URL of the database.

Install OwnCloud

Change into the directory that was created when you ran rhc-create-app. This directory contains a number of files and directories:
  • .openshift/
  • deplist.txt
  • libs/
  • misc/
  • php/
  • README
Check the README file for a full explanation of what each of these is for. For now we will be concentrating on deploying OwnCloud into the php/ subdirectory.

Change into the php/ subdirectory, download and extract the OwnCloud2 source tarball.

$ wget http://owncloud.org/owncloud-download-4-0-0 -O owncloud-4.0.0.tar.bz2
$ tar -xf owncloud-4.0.0.tar.bz2 --strip-components=1
$ rm owncloud-4.0.0.tar.bz2

Now our local copy is ready to deploy to the OpenShift Express servers. OpenShift Express uses git to facilitate version control and deployment. To deploy we must:
  • Add the new files to our commit, ensuring the .htaccess file is also added:
    • $ git add * .htaccess
  • Commit the new files, entering a commit message when prompted:
    • $ git commit
  • Push the commit to the remote server:
    • $ git push
Now, access your application in a web browser at the address of the form:

http://<application_name>-<domain_name>.rhcloud.com/

The OwnCloud setup wizard will appear.





Enter a Username and Password for your OwnCloud administration account. Remember that this application is running on the public internet and therefore must have a secure password.

Click Advanced and select MySQL as the storage engine. This enables a number of additional options.




These options should be set as follows:
  • The Data folder should be set to '../../data'. This folder is the location of the persistent data storage for an OpenShift Express application.
  • The Database user must be set to the database username as returned when adding the MySQL cartridge.
  • The Database password must be set to the database password as returned when adding the MySQL cartridge.
  • The Database name must be set to the database name as returned when adding the MySQL cartridge.
  • The localhost value must be replaced with the appropriate host as returned when adding the MySQL cartridge. This will be in the form of an IP address, the protocol and port information can safely be discarded.
Once you are satisfied with the values entered, click Finish Setup.

Finished!
Assuming all has gone well you will be logged into your newly created OwnCloud installation running on OpenShift Express!

For some hints on what you can actually do with it, see:

http://owncloudtest.blogspot.com/2011/06/what-you-can-do-with-owncoud-today.html




8 comments:

  1. Hello Steve. Thanks for this writeup on installing Owncloud on OpenShift. I'm a Developer Evangelist for the platform, and our team would love to get your direct feedback on things you liked and did not like about Express. Please email me directly at . Thanks!

    ReplyDelete
  2. Successful installation Steve!!! Great instructions..

    ReplyDelete
  3. Thanks, I have my own instance of OwnCloud 4.0 running now. One thing which needs to emphasized IMHO is that the tarball should be extraced to php/ subdirectory not to the root of the OpenShift repo directly.

    Thanks a lot.

    ReplyDelete
    Replies
    1. how did you manage to get it to work with owncloud 4? i got the old version 2 here up fine, but both upgrading to 4 and trying to clean install 4 I couldn't get anywhere--it would hang on the "create admin account" page and never actually install

      did you do anything special or different?

      Delete
    2. Thanks for the feedback matej, the need to use the php/ sub-directory is mentioned in the post but I can see how it is easily missed!

      Delete
    3. capitao: I haven't tried with owncloud 4 yet, I am going to try and deploy it now. If I find anything different I will post an update!

      Delete
    4. capitao: I have now updated the post to reflect the way I installed OwnCloud 4 on OpenShift.

      The one thing I added, other than the new paths to the release tarball, is that you need to explicitly git add the .htaccess file. Otherwise the install seemed to be pretty much the same as I had previously documented. Perhaps it is worth checking whether or not you have added and pushed this file?

      Delete
    5. Wow thanks Steve! That was it, I totally didn't look for the htaccess file... made sure to push it and everything's dandy now!

      I was scratching my head there for a while, I couldn't see what was wrong. Much appreciated!

      Delete