Getting Started with ownCloud

By Aditya Patawari
    Advance your knowledge in tech with a Packt subscription

  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies

About this book

Making your data easily accessible on multiple devices is the primary goal of ownCloud. It gives you control of your own data along with the flexibility to set it up the way you want it. Community backup to the project ensures high quality software and gives you the power to modify and create features.

Getting Started with ownCloud is a practical handbook that provides step-by-step installation and scaling instructions. It will also give you an excellent understanding into how ownCloud can be integrated with components such as LDAP and WebDAV.

This book starts with a basic setup of ownCloud for personal use and then clearly scales out various components of ownCloud with examples This book will also help provide you with the understanding to integrate existing systems such as LDAP with ownCloud.

Starting from the setup on both Linux and Windows using either SQLite or MySQL, we move ahead to show you how efficiently user management can be done using ownCloud. We also look into storage backends and how to enhance the functionality of ownCloud by using ownCloud apps.

You will learn everything you need to know about ownCloud setup and usage for small and corporate scale deployment.

Publication date:
July 2013


Chapter 1. Setting up ownCloud

Setting up ownCloud is not a very difficult task, especially on Linux, where building a LAMP stack is quite easy. ownCloud can be installed in less than 10 minutes for a small number of users. Being a web application, most of the components can be easily scaled to support thousands of users seamlessly. We are going to talk about some basic installation methods in this chapter, and then look into the scaling aspects in the subsequent chapters.


Installing ownCloud on Linux

There is more than one way to install ownCloud on Linux, depending upon the Linux distribution you run. We'll talk about two major Linux distributions, namely, Fedora and Ubuntu, but we can always find the most up to date, installable packages for various distributions at These packages are built and maintained by the people behind ownCloud themselves.


Let's do a source install in Fedora. First, we need to install all the dependencies for ownCloud. This includes a web server of our choice, and certain PHP dependencies. For the sake of this demo, we'll use Apache web server and PHP5.

yum install -y httpd php php-gd php-mbstring php-pdo php-dom

Let us see the use of each of these requirements:

  • php-gd: It is used to create and manipulate image files. It can also direct image streams to the browser.

  • php-mbstring: It handles multibyte string functions. Several languages have characters which are not representable using one-to-one mapping to a single byte (8 bits). php-mbstring handles character encoding conversion in these cases.

  • php-pdo: It provides an interface to communicate with the databases. It very light-weight, and enables database drivers to expose database specific features easily.

  • php-dom: It is required to work with XML documents using the DOM API.

Once we have installed the dependencies, download the latest release of ownCloud source from the following link:

This would be a bzip archive. Extract this to /var/www/html/, and set the owner as Apache user.

tar xzvf owncloud-5.0.7.tar.bz2 -C /var/www/html
chown -R /var/www/html/owncloud

If security is not a major concern, or if we have other means of securing our server, then we can stop SELinux, otherwise the Apache will keep on throwing an error with 401 return codes, or will complain that the ownCloud directory is not writable.

setenforce 0

In case disabling the SELinux is not an option, we have to add the files in the ownCloud directory to appropriate SELinux context. We can use chcon to add the entire directory recursively to read-write (rw) context.

chcon -R -t httpd_sys_rw_content_t /var/www/html/owncloud

Now, we will just open the browser on this computer and go to http://localhost/owncloud. A window will appear similar to the following screenshot:

ownCloud Setup Interface

We need to create the first admin user on this screen. So, fill in a username and a strong password, and click on the Finish setup button. We'll take care of the security warning being displayed later in this book. We can try to upload a small file to check. Upload of bigger files will fail at this point of time because of a limit in place by PHP.


You can use apt manager on Ubuntu and install ownCloud, but first install the dependencies for ownCloud. We'll need Apache web server, PHP, and some other libraries for it to function properly:

apt-get install apache2 php5 php5-json php-xml php-mbstring php5-zip curl
apt-get install php5-gd php5-sqlite libcurl3 libcurl3-dev php5-curl php-pdo
apt-get install owncloud

The previous command will install ownCloud on our computer.


Installing ownCloud on Windows Server 2008

Let us install ownCloud on a Windows Server 2008. The steps for other Windows versions would be similar. We'll need a web server for it, and Internet Information Services (IIS) is a natural choice when it comes to Windows. We also need to have PHP, since ownCloud will not work without it. Installing a database is optional, so we will not get into it right now.

Installing Internet Information Services (IIS)

The following are the steps to install IIS:

  1. Go to Start menu, and click on Control Panel. Select Programs and Features and click on Turn Windows features on or off.

  2. The Server Manager will appear. We need to click on Roles, and then select Web Server (IIS) role. We need to turn on a few features here. Usually the defaults are good enough, but here is a check-list for reference:

    • Static Content

    • Default Document

    • Directory Browsing

    • HTTP Errors

    • CGI

    • HTTP Logging

    • Request Monitor

    • Request Filtering

    • Static Content Compression

    • IIS Management Console

    • IIS Manager Console

  3. Now we need to go to the Start menu and click on IIS Manager. From here, we can restart the IIS web server.

  4. Open the browser and go to http://localhost. The splash screen for IIS will be displayed.

Installing PHP

Installing PHP for IIS is very straightforward. We just need to download the latest installer from and run it. At the time of writing this book, PHP 5.3 VC9 x86 was the latest installer available. Select the IIS FastCGI radio button when prompted, and install keeping the rest as default.

PHP Setup

Installing ownCloud

The following are the steps to install ownCloud on your machine:

  1. Download the latest source from and extract the bz2 archive.

  2. Move the source to the IIS wwwroot folder. By default it is located at the location C:\inetpub\wwwroot. Now we need to give the write access to the folder containing the ownCloud source. To do so we need to right click on the wwwroot folder and click on Properties.

  3. Now from the security tab, click on the Edit button. Select Users from Group or usernames list, and then click on the checkbox next to the Write option.

  4. Now we just need to click on Apply, and we are all done.

    Giving Write Permissions to Users in Windows Server 2008

  5. Open http://localhost and you will see the regular ownCloud setup page. Just fill in the details and use SQLite for a quick setup.


Giving ownCloud a friendly URL

Now that we have setup our ownCloud instance, we should give it a friendly and short URL for access. This can be done by using virtual hosts' configuration. Virtual host is a web server configuration with which we can give it a name of our choice, provided that we own the domain, and do not reveal the real name of the server. Ideally, we would want to put it under a hostname like instead of The is easy to remember and will get the work done faster. If your DNS provider allows, you can even have to make it more intuitive and relevant. For this, we need to do appropriate virtual host configuration for the web server. So now we get into the Apache config directory and create the vhost.conf file:

# cat owncloud-vhost
NameVirtualHost *:80
<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/var/www/owncloud/" 
  ErrorLog "logs/owncloud/error_log"
  CustomLog "logs/owncloud/access_log"

Once the virtual host setup is done, we need to restart the Apache web server. Now we will open our browser and go to, and we'll see that ownCloud interface opens in this URL.


Coping with large data sets and other PHP fixes

If we try to upload larger files, it will fail. PHP, by default, doesn't allow uploads beyond 2M. This value is defined in the php.ini file. The location of this file varies depending upon the operating system you are using. For Ubuntu, it will be /etc/php5/apache2/php.ini, while for Fedora it is /etc/php.ini. We can always use find command to locate php.ini on our computer.

find / -name php.ini

We need to find the variable upload_max_filesize and post_max_size, and increase the limit to a desired value. Ideally, these values should be almost same, with post_max_size being slightly higher than upload_max_filesize, because there is header information in the posted files. Also if we see a lot of execution time outs, then we should increase max_execution_time and max_input_time to an appropriate value.


MySQL versus SQLite usage

The choice between MySQL and SQLite depends upon the scale of our deployment. We need to have an estimate of how many users are going to use the instance. For personal deployments with about 15 to 20 users, using SQLite is recommended, because it is easy to install and is inaccessible over the network. It is very lightweight and fast, because there is much less overhead in the terms of connectivity and database driver calls. Usually, the entire database is just a small file of less than 1 MB. If the idea is to deploy ownCloud for a larger scale, like for a large organization or an educational institute, MySQL should be used. MySQL is more scalable, and comes with a lot of features suitable for an enterprise. We can isolate MySQL entirely from the server running ownCloud, reducing load on the server. It is also possible to create MySQL replication and clusters which ensures high-availability and load-balancing of the database. It is also possible to use PostgreSQL which has similar benefits as MySQL. Choosing between MySQL and PostgreSQL is a matter of taste. We will use MySQL for a demo in this book.

Setting up ownCloud with MySQL

Setting up ownCloud with MySQL is very easy. First we need to install MySQL server and php-mysql libraries.

  • For Ubuntu:

    apt-get install mysql-server php5-mysql
  • For Fedora:

    yum install mysql-server php-mysql

We can enter the root password if the setup prompts for one or we can use mysqladmin tool to setup the root password. Now, we need to create the database and the user for ownCloud to use:

mysql -uroot -p
mysql> create database owncloud;
 mysql> grant all privileges on owncloud.* to "oc-user"@"localhost" identified by "myrandompassword";
mysql> flush privileges;

MySQL is now ready to use. We just need to open ownCloud URL in a browser, and click on the Advanced link. Here we'll get an option to choose MySQL instead of SQLite. Fill in the required details and ownCloud will be ready to use.

ownCloud Setup with MySQL Configuration



Installing ownCloud is quite easy. It supports all the major operating systems without any hassle. All we need to have is a web server which can process PHP and a database. ownCloud provides an option to use SQLite or MySQL, both of which are easy to configure, and serve a distinct purpose. Now that our ownCloud instance is up and running, we can move forward and check out some features of ownCloud.

About the Author

  • Aditya Patawari

    Aditya Patawari is a Systems Engineer by profession, and just loves to play around with Linux and other open source technologies. He works on various parts of system lifecycles, and handles infrastructure automation and scaling of applications. He is also a contributor at Fedora project, and can be heard talking about the same along with the Linux systems automation at several conferences and events. He has worked on Ansible both at where he leads a team of systems engineers and at Fedora Project.

    I would like to thank my family with being patient with me. I would also appreciate my colleagues at BrowserStack for their support and my fellow contributors at Fedora Project who taught me so much. Lastly, a big thanks to all my friends for being there for me when I just could not manage it all.

    Browse publications by this author
Getting Started with ownCloud
Unlock this book and the full library for FREE
Start free trial