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.
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 http://software.opensuse.org/package/owncloud. 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
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-mbstringhandles character encoding conversion in these cases.
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.
wget http://download.owncloud.org/community/owncloud-5.0.7.tar.bz2 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.
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:
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.
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.
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.
Go to Start menu, and click on Control Panel. Select Programs and Features and click on Turn Windows features on or off.
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 Compression
IIS Management Console
IIS Manager Console
Now we need to go to the Start menu and click on IIS Manager. From here, we can restart the IIS web server.
Open the browser and go to
http://localhost. The splash screen for IIS will be displayed.
Installing PHP for IIS is very straightforward. We just need to download the latest installer from http://windows.php.net/download/ 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.
Download the latest source from http://owncloud.org/install/ and extract the bz2 archive.
Move the source to the IIS
wwwrootfolder. 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
wwwrootfolder and click on Properties.
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.
Now we just need to click on Apply, and we are all done.
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
http://example.com instead of
http://example.com is easy to remember and will get the work done faster. If your DNS provider allows, you can even have
http://owncloud.example.com 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
# cat owncloud-vhost NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/www/owncloud/" ServerName owncloud.example.com ServerAlias owncloud.example.com ErrorLog "logs/owncloud/error_log" CustomLog "logs/owncloud/access_log" </VirtualHost>
Once the virtual host setup is done, we need to restart the Apache web server. Now we will open our browser and go to
http://owncloud.example.com, and we'll see that ownCloud interface opens in this URL.
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
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_input_time to an appropriate value.
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.
apt-get install mysql-server php5-mysql
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.
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.