How to Set Up OwnCloud on Ubuntu 14.04 LTS Server (Part I)
09 Jan 2016Note: This blog was originally posted as one single entry. However, I feel that the installation and security setups are seperate issues, so please refer to How to Set Up OwnCloud on Ubuntu 14.04 LTS Server (Part II) for Hardening Security Practices.
Per suggested by ownCloud admin manual, the graphical Installation Wizard is the most convienent way of configuring ownCloud. However, I managed to connect to the server via SSH, thus I can only initialize and configure ownCloud from the command line. Here are the steps in a nutshell:
1. Install ownCloud from the command line
Download and install the ownCloud code via package manager, or download and unpack the tarball in the appropriate directories. Follow the official instructions will be the best practice. For example, to install owncloud-8.2.2-1.1 on the Ubuntu 14.04 using apt
, we can add the following repository key and install:
2. Complete installation
First change the ownership of the owncloud directory to your HTTP user:
Then change to the root ownCloud directory (/var/www/owncloud/
), and use the occ
command to complete the installation. This takes the place of running the graphical Installation Wizard:
Here, we use the mysql
as the database and you can choose one in mysql/sqlite/pgsql/oci
. We also created the admin user admin
and this name is UNCHANGEABLE in later time! Also pay attention to the passwords.
Caveat You should locate your ownCloud data directory outside of your Web root if you are using an HTTP server other than Apache, or you may wish to store your ownCloud data in a different location for other reasons (e.g. on a storage server). This data directory must already exist, and must be owned by your HTTP user. Use the --data-dir
in the installation commands instead:
3. Basic configurations
Edit /var/www/owncloud/config/config.php
and add your website domain to the trusted domains section, so that ownCloud will not give you a warning on its startup:
Basic configurations are stored in config.php
file where you can find detailed instructions from the ownCloud official manual.
4. Place data directory outside of the web root
Per suggested by ownCloud official manual, it is highly recommended to place your data directory outside of the Web root (i.e. outside of /var/www/
). It is easiest to do this on a new installation as explained in the previous section.
If you (unfortunately) decide to move the data directory to another place after the above configuration (like I did), it is achievable. First, stop your webserver, and you need to change or create the “datadirectory” entry in /var/www/owncloud/config/config.php
file, so that it points to wherever you want to have your data from now on. Assuming the directory you want to move the data folder to is ‘/path/to/oc-data’, your config.php
should look like this after the change:
Then, move the data directory to the desired place:
Make sure the permission/ownership of the new folder is set up correctly, by verifying that the webserver can read the directory
Then you can restart your webserver (e.g. sudo service apache2 restart
on Ubuntu).
5. Optimize ownCloud performance through caching
PHP 5.5 and up includes the Zend OPcache in core, and on most Linux distributions it is enabled by default. However, it does not bundle a data cache. APCu
is a data cache, and it is available in most Linux distributions. On Ubuntu we should install php5-apcu
.
Yet the trick is that ownCloud 8.0+ requires the version of APCu must be 4.0.6
and up. If you use sudo apt-get install php5-apcu
on Ubuntu 14.04 LTS, the installed APCu
version is 4.0.2
, so that the ownCloud still throws warning. After quite some time of research, I finally find the solution. Just as simple as invoke the following command will install APCu 4.0.7
found in Please backport php5-apcu version 4.0.6 to Ubuntu 14.04 LTS:
Of course if you are uisng Ubuntu 15.04 or later version, it is easier:
Then, configure the ownCloud in /var/www/owncloud/config/config.php
, adding
Also, enable APCu
in your PHP config file:
and restarting your web server, and refresh your ownCloud admin page, and the cache warning should disappear.