Saturday, February 02, 2013

HOWTO : OwnCloud with Apache on Ubuntu Server 12.04 LTS

At the early beginning, I want to create an OwnCloud server (4.5.6) with Hiawatha (8.7) on Ubuntu Server (12.04). However, I encounted a lot of problems when making it working properly. The main problem is that I cannot make any changes through the OwnCloud web interface and the applications cannot be activated and deactivated.

However, OwnCloud with Apache on Ubuntu Server is not a bad idea indeed. Furthermore, OwnCloud is designed for Apache environment. So, let's go.

OwnCloud will use your whole hard drive capacity. Therefore, the server should be dedicated for the purpose. Consider to use hardware RAID 1, 5 or 6 if possible.

(A) Installation of Ubuntu Server

Install Ubuntu Server 12.04 LTS as usual. Make sure you choose OpenSSH server, LAMP server and Mail Server when ask. Make sure you write down the MySQL password and make it strong enough.

(B) Installation of OwnCloud

To make the work simple, I choose to install from the Ubuntu respository even it is an old version as I want it to install a lot of packages automatically. Later, I will install the latest version from OwnCloud respository.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install owncloud

sudo apt-key add - < Release.key

sudo -i
echo 'deb /' >> /etc/apt/sources.list.d/owncloud.list

Exit from root.

sudo apt-get update
sudo apt-get install owncloud

sudo chown -R www-data:www-data /var/www/owncloud/

(C) Configuration of Apache and .htaccess

sudo nano /etc/apache2/sites-enabled/000-default

Change all "AllowOverride" setting from "None" to "All".

And set "/var/www" or "/var/www/" to "/var/www/owncloud" or "/var/www/owncloud/" respectively.

sudo nano /var/www/owncloud/.htaccess

You can change the following values if necessary :

php_value upload_max_filesize 512M
php_value post_max_size 512M
php_value memory_limit 512M

Append "AcceptPathInto On" at the end of the file. Then save and exit.

sudo a2enmod rewrite
sudo a2enmod fcgid
sudo a2enmod headers

sudo /etc/init.d/apache2 restart

*** Please also to Official Manual and Administrators Manual for detail.

(D) Installation of OwnCloud via Broswer

Open Firefox and point the url to OwnCloud (e.g.

OwnCloud will create an Admin account when you first access the web interface.

Enter your Admin User Name (OwnCloud will create for you).
Enter your Admin Password (OwnCloud will crate for you).

Click "Advance" button to select MySQL.
Enter MySQL Admin User Name (e.g. root).
Enter MySQL Admin Password (The password when you install Ubuntu Server and MySQL that you have entered).
Enter Database Name that you want to use for this server (e.g. owncloud).

Press "Enter".

Then, you can configure your OwnCloud server via browser.

*** Make sure to backup the /var/www/owncloud/config/config.php

(E) Installation of OwnCloud client for desktop

Go to the Offical site to download (

If Ubuntu Desktop user, you can install it via the respository. The installation is similar to OwnCloud Server.

Make sure to add the "/usr/bin/owncloud" to the "Application Startup Preference" in order to make it to launch on every system boot up.

(F) Installation of Fail2ban

sudo apt-get install fail2ban

Make sure the ssh setting is set to "true".

sudo nano /etc/fail2ban/jail.conf

(G) Installation of Suricata (Optional)

You can refer to this link to install IPS on your Ubuntu Server.

(H) Tunning of MySQL (Optional)

You can refer to the MySQL section for tunning the performance of MySQL.

(I) Secure your Ubuntu Server in a passive way (Optional)

You can refer to this link for securing your Ubuntu server in a passive way.

(J) Send mail to GMail via Postfix (Optional)

You can configure your Postfix mail server to sent mail via GMail. You can refer to this link for detail.

(K) Logwatch (Optional)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install logwatch

Make changes to the logwatch configure file in order to tell her to send you a email report.

sudo nano /usr/share/logwatch/default.conf/logwatch.conf

Change the settings of the following lines.

Output = mail
Format = html
MailTo =

(L) Secure Apache (Optional)

You can refer to this link to make your Apache more secure.

Remarks : I just found out that mod-security may problem for operating the OwnCloud. It should be disabled.

(M) SSL for Apache (Optional)

You can secure your connection with SSL (HTTPS) in Apache. You can refer to this link.

sudo a2enmod ssl
sudo a2ensite default-ssl
sudo nano /etc/apache2/sites-enabled/default-ssl

Make some change on the file.

(N) Apparmor for Aapche (Optional)

sudo apt-get install apparmor-profiles apparmor-utils

Copy the following in a file namely "usr.lib.apache2.mpm-prefork.apache2" and placed it at "/etc/apparmor.d/" :

sudo aa-enforce usr.lib.apache2.mpm-prefork.apache2

Remarks :

At this writing, users cannot upload a file that is larger than 2GB to the OwnCloud via the web interface for 64-bit system. However, the client sync program can do it. The bug has been filed.

If your server is behind Cloudflare, your maximum file size upload via web interface should be limited to 50MB and you should disable the caching feature in the Cloudflare too.

Reference :

Apparmor manual for Ubuntu

That's all! See you.