ownCloud on Shared Web Hosting

ownCloud logo

ownCloud is an open-source, self-hosted cloud service that can be installed on a local or remote server. For better performance and reliability it’s best to host it on a commercial hosting service. Both dedicated and shared web hosting packages will work assuming the service is reasonably feature rich. If reliability is not an issue it can be hosted on a local home server without issues as well.


Install ownCloud

It is recommended to use a dedicated domain as opposed to a path on an existing domain / website.This is the preferred method as it offers all the benefits of the Same-Origin-Policy. Log into cPanel and create a sub-domain. Doing this will automatically create a directory within the web root.

For a simpler but less secure setup, connect to the server with an ftp client or file manager in cPanel and create a sub-directory in the web root. Download the setup file and upload it to the previously created directory with an ftp client or file manager in cPanel. Alternatively setup SSH on the shared (or dedicated) hosting server before proceeding.


Secure HTTP should ideally be used, however private SSL certificates are somewhat impractical for personal use. Shared SSL certificates are often provided by web hosts but web browsers will show certificate errors which is inconvenient and unreliable if files are to be shared with other users or the general public. The choice whether to use SSL or not comes down to use case and the balance between simplicity, convenience and security.


Connect to the web server with SSH.

ssh [email protected] -p 22

Default port of 22 is used but any port value can be specified with the -p option.


Create a sub-directory if not using a sub-domain.

mkdir ~/public_html/owncloud


Change current directory to the previously created sub-domain directory.

cd ~/public_html/owncloud


Download the PHP installer file.

wget https://download.owncloud.com/download/community/setup-owncloud.php


Navigate to the php file in a browser for example localhost/owncloud/setup-owncloud.php


Follow on screen instructions making sure to enter the correct sub-domain directory which is defined as a . for the current directory. The installation can take a little while during which no UI elements should be interacted with to avoid a failed installation.


Configure ownCloud

Enter a new admin username and password. For security reasons it’s best to define the data directory outside of the web root. For example ~/owncloud-data instead of ~/public_html/owncloud/data. Default database is SQLite which very simple to setup and manage but is not recommended as it doesn’t handle multi user scenarios well. Create a new MariaDB, MySQL or postgreSQL database in cPanel along with a database user and add the user to the database. Enter the database details and the database tables will be created before the setup is complete.


To improve security ownCloud should have access to /dev/urandom. Explicitly defining access may be required depending on the configuration of the server. Test PHP configuration to verify if this is required.


Create a new php file in the document root.

nano ~/public_html/phpinfo.php


Add the phpinfo function and save the file.

<?php phpinfo(); ?>


Open the page in a web browser. For example localhost/phpinfo.php

If PHP version and other information is loaded then PHP is working otherwise it will just print the plain text contained in the file. Search for open_basedir option. If disabled, no value will be printed and the subsequent section on allowing access with open_basedir directive is not needed.


Append a directive to the web configuration file.

echo 'SuPHP_ConfigPath ~/public_html/owncloud' >> ~/public_html/owncloud/.htaccess

Replace ~ with the actual home directory path such as /home/username. This will make php.ini configuration file apply recursively to all sub directories.


Append the directive to the PHP configuration file.

echo 'open_basedir = "/var/urandom/"' >> ~/public_html/owncloud/php.ini


Set the permissions on the configuration file.

chmod 640 php.ini


ownCloud has it’s own .htaccess file with relevant configurations already present. These configurations include maximum upload size which is set to 1 GB by default but can be changed from the web interface or directly by editing the file.


Configure HTTPS Redirect

SSL certificates need to be created and installed on the server for the relevant domain or sub-domain. There is no additional configuration in ownCloud and SSL will just work but only when accessed via HTTPS. By default the domain can also be accessed with HTTP as well. To prevent this and to automatically redirect all HTTP requests to HTTPS the server needs to be configured.


Open htaccess configuration file.

nano ~/public_html/owncloud/.htaccess


Add the redirect directive and save the file.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]


Use ownCloud

Access via the web interface at the sub-domain or sub-path. Data can also be synced via the free desktop apps available for Linux, Windows and Mac. Mobile apps are also available for Android, iOS and Blackberry. On Arch Linux the desktop client can be installed from the official repository.