There are many good resources on how to install ownCloud on the Internet including the official ownCloud documentation, but I’ve never found a comprehensive guide on how to Install ownCloud in Ubuntu. In this tutorial I’ll try to do that. I have installed ownCloud many times in production and testing servers.
The latest release of ownCloud at the time of this writing is 9.0 and the latest Ubuntu LTS release is Ubuntu 14.04.3 so this tutorial will be based in these two.
In this tutorial I assume you are installing ownCloud in a new Ubuntu server, and no other application is currently running on that server yet.
Table of Contents
Update server and set it with a static IP address
Make sure the server is fully patched. Type sudo apt-get update && sudo apt-get upgrade on terminal, then type sudo apt-get dist-upgrade reboot the server after all patches have been installed. After the server comes back from the reboot, make sure its set with a static IP. To see the the server current IP configuration type this on terminal: sudo nano /etc/network/interfaces and you should get this:
In the screenshot above, the server is set to DHCP so it does not have a static IP, we need to change it to static. Change the last text line dhcp to static and enter your network information like this:
dns-nameservers 220.127.116.11 18.104.22.168
Save the file by pressing the Ctrl + X keys on your keyboard, and then restart the network service by typing this on terminal: sudo /etc/init.d/networking restart that should update your network configuration file, if it doesn’t, reboot the server: sudo reboot now
ownCloud installation requirements
- PHP 5.4+
- Apache 2.4
- GD library
Ubuntu Server 14.04 already has PHP 5.5 and Apache 2.4 in the repositories so you can easily install the whole stack using the apt-get command.
Installing Apache,PHP and MySQL
The easiest way to install the LAMP stack at once in Ubuntu is using the Tasksel script. On your terminal type : sudo apt-get install tasksel and then type sudo tasksel install lamp-server this will install the basic LAMP stack server for you. Enter a MySQL server password when prompted. After the installation is complete, type the IP address of your server in a browser and you should see this:
hoorah! your apache web server is working!
Change PHP max upload limit
PHP only allows 2MB files upload by default. I assume you will be uploading bigger files to your ownCloud server, so we need to increase the upload size in the php.ini file. To do that, type sudo nano /etc/php5/apache2/php.ini and search for upload_max_filesize and for post_max_size on the file and change both numbers to whatever you need.
Reload apache. Sudo service apache2 reload
Create the Database
login to MySQL and create the database. type mysql –u root –p to login to your MySQL server. and create the database using this command: create database owncloud ;
now you need to create a new user for the ownCloud database. to do that, type this command: CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;
for example, my command looked like this: CREATE USER ‘ocuser’@’localhost’ IDENTIFIED BY ‘ittutorials’;
grant this user full permissions to the database:
GRANT ALL PRIVILEGES ON databasename.* TO ‘user’@’localhost’;
for example my command was:
GRANT ALL PRIVILEGES ON owncloud.* TO ‘ocuser’@’localhost’;
type FLUSH PRIVILEGES; then exit.
Grab the latest release from the ownCloud website. At the time of this writing, version 9.0 is the latest release. To download it directly from the server, switch to the /opt/ directory, and type this command in terminal: sudo wget https://download.owncloud.org/community/owncloud-9.0.0.zip
- Unzip the archive with this command: sudo unzip owncloud-9.0.0.zip
- Move the ownCloud files to the the WWW web directory: sudo mv /opt/owncloud /var/www/
- Make apache the owner of this directory : sudo chown –R www-data:www-data /var/www/owncloud/
- Change your apache virtual host to point to this ownCloud directory: sudo nano /etc/apache2/sites-available/000-default.conf change the DocumentRoot to /var/www/owncloud/
Type in the IP address of your server in your preferred browser and you should get this:
GD and cURL modules are not installed. Install them by typing this on terminal sudo apt-get install php5-gd and sudo apt-get install php5-curl reload apache again: sudo service apache2 reload and the ownCloud wizard shouldn’t complain now:
Now fill out the information on the windows above and click on Finish setup. You should get the Welcome to ownCloud message:
You are finished installing ownCloud.
.htaccess file error
If when going to the admin panel you see the following error at the top:
Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root
Then there is a problem with your .htaccess file. most likely your web server does not have Mod_rewrite on. to enable it type this on terminal: sudo a2enmod rewrite then add this to your Virtual Host file:
<Directory />Options FollowSymLinks
allow from all
Restart Apache: sudo service apache2 restart check the admin panel again, and see if the error went away. if it didn’t try giving the web server full access to the data folder. sudo chown –R www-data:www-data /home/user/data/The problem should go away:
Free SSL certificate for ownCloud
If you notice in the admin panel ownCloud complains that is running in plain HTTP, and it recommends to run in HTTPS instead . In order to make that error go away, you need to install a valid certificate in your web server. Probably you would want to do this only if your server is accessible from the Internet, and it has a valid domain. The only two places I know of where you can get a free certificate is https://www.startssl.com/ and https://letsencrypt.org/ if you are running a personal ownCloud instance, I recommend getting a certificate from STARTSSL, and if you running ownCloud for a business then Letsencrypt will be better. STARTSSL does not issue free certificates to businesses. The downside of Letsencrypt is that you have to renew the certificate every 3 months.
To configure LDAP in your ownCloud server click on the “Apps” icon and then enable the LDAP script:
Once you have enabled the LDAP app, go to the admin panel, and click on LDAP, and fill up your server info: IP of the LDAP server, LDAP username, and the password for that LDAP account, and lastly enter your based DN. This is the OU where users will be pulled up from AD.
Remember to enter your based DN as “OU=users,DC=domain,DC=com. you can also add multiple strings here if you have multiple OUs. Then click on the Login Attributes tab and check “LDAP /AD Username LDAP/AD Email address and choose “distinguishedName” from the dropdown list on the Other Attributes” field.
You should be able to login to your ownCloud instance using an LDAP account now.