Dropbox is great. But, you are putting your private, personal data in a corporations hands. That is a bit scary if you stop and think about it. The good news is that you can run your own Dropbox, using an Open Source software package called ownCloud. It’s amazing and works very well. In this guide, we’ll be installing ownCloud on Ubuntu 14.04 LTS. It’s not very hard, and when it’s all said and done you have your own personal cloud storage platform that you control. You can even enable server-side encryption so that if you server is compromised, your data is still safe. Lets get started.
How to install ownCloud on Ubuntu 14.04 LTS
This tutorial assumes you have installed Ubuntu 14.04 and have updated it to the latest and greatest using the commands below. Just FYI, I’m installing it on a virtual machine on ESXi 5.5. So, make sure everything is updated using these two commands.
# sudo apt-get update # sudo apt-get upgrade
Next, we need to install a webserver (Apache), a database server (mysql) and PHP. This is commonly called the LAMP stack. Fortunately, this only requires two simple commands now, thanks to taskel.
# sudo apt-get install taskel # sudo taskel install lamp-server
During installation, you will be prompted to set a root password for mysql. Make sure to set this as a secure password, and do not forget it!
Now that we have the basics installed, lets go ahead and tweak a couple PHP settings to make things run a bit smoother. We are going to increase the maximum file upload size PHP allows, so that you aren’t limited to 2MB files when uploading through ownCloud’s web interface. To do that, type in the following command.
# sudo nano /etc/php5/apache2/php.ini
There are two variables we need to locate and change. The first is max_file_uploads. Locate this variable and change it from 20 to 200 (this correlates to Megabytes).
The next variable is post_max_filesize. Change this from 2 to 200 as well (also correlates to Megabytes).
Now, lets create a mysql database for owncloud. Open the mysql command line utility using the following command.
# mysql -u root -p
You will be prompted for a password. This is the password you set on the pink screen when you ran the taskel command earlier.
Next, you will need to run a few commands to create the database, create a user for that database and give that user permissions to write to the database. Yourpassword should be changed to a secure password of your choosing. You will need this later on so remember it. Here are the commands you need to run.
# create database owncloud; # create user 'ocdbuser'@'localhost' identified by 'yourpassword'; # grant all privileges on owncloud.* to 'ocdbuser'@'localhost'; # flush privileges; # exit
Be sure to include the trailing semicolon “;” as that will “execute” the command entered. If you get a new line with a >, it means you forgot to include the “;”, so just enter a semicolon and hit enter and you should be good to go. If you mess up, you can delete the database using the drop database owncloud command, and start over.
Now it’s time to download and install ownCloud. Currently, the most up-to-date version of ownCloud is 8.2.2. You can click here to find out if 8.2.2 is still the latest version. Or, you can copy and past the command below to download 8.2.2.
# cd /opt/ # sudo wget https://download.owncloud.org/community/owncloud-8.2.2.zip
Before we extract the zipped file we just downloaded, we need to install unzip. Then we can go ahead and unzip ownCloud.
# sudo apt-get install unzip # sudo unzip owncloud-8.2.2.zip
The root of our webserver’s html folder is in /var/www/html. We are going to move ownCloud to /var/www/owncloud and then change the default directory to the same. So, lets go ahead and move ownCloud to /var/www/owncloud. Then we will change the owner and group of that folder to www-data, which will give the webserver, apache2, access to that folder and files.
# sudo mv /opt/owncloud /var/www/ # sudo chown -R www-data:www-data /var/www/owncloud/
Now we need to edit the Apache configuration file to tell it to look in that folder for anyone that accesses the web server. Run the following command and change the DocumentRoot variable to /var/www/owncloud. Afterwards, save and exit (CTRL-X, Y).
# sudo nano /etc/apache2/sites-available/000-default.conf # sudo service apache2 reload
If you browse to your web server now, you will see the following errors.
This is because we need to install PHP module GD and cURL. To install these modules, run the following commands, followed by reloading Apache.
# sudo apt-get install php5-gd # sudo apt-get install php5-curl # sudo service apache2 reload
OwnCloud documentation recommends, for security purposes, to locate the data directory (where user files are stored) outside of the public html directory. So, we’re going to create a data folder one level up, in the /var/www folder and make the web server owner of this folder.
# sudo mkdir /var/www/data # sudo chown -R www-data:www-data /var/www/data/
Now it’s time to browse to your ownCloud install by going to http://youripaddress or http://yourdomainname.com. You will see the following page, which you will need to fill in with the appropriate information. Your data directory will be /var/www/data and your database username will be ocdbuser if you used the same username when we created the database. The database password will be whatever you set for yourdatabasepassword when we created the database. You’re probably looks very similar to this.
Now, just click Finish setup, and you should see this.
Now, you’re all done. Stay tuned for more tutorials on how to enable LDAP / Active Directory authentication on your ownCloud site, or how to encrypt all of your files. They will be coming soon! If you have any problems or need a hand, please feel free to post in the comments below! Thanks!