Monday, July 8, 2013

How to Setup ownCloud 5 on Ubuntu 12.10

What the Red Means

The lines that the user needs to enter or customize will be in red in this tutorial! 

The rest should mostly be copy-and-pastable.

About ownCloud

ownCloud is an open source Data Storage solution similar to Dropbox or Google Drive. One can grab its source code and install it anywhere he/she wants and thus gain much more control over his/her data.

The latest version of ownCloud as of this writing is 5.0.4 and that version will be installed in this tutorial.

LAMP Stack Setup

First off, we need a LAMP (Linux, Apache, MySQL and PHP) stack in order to run ownCloud 5. Before installing it, we should perform a few system updates and upgrades.
sudo apt-get update
sudo apt-get upgrade

Next, we install the actual LAMP stack with the following command:
sudo apt-get install lamp-server^

Note the "^" character at the end of the package name, it is important to type it for the LAMP stack to be installed properly. The setup will prompt you for the MySQL root password, be sure to enter something sensible and easy to remember.

That's it, now we have a fully working LAMP stack on our cloud server.

Setting Up MySQL and MySQL Database

Although ownCloud can use SQLite to store its data, in this tutorial, we will use MySQL database for ownCloud's internal data as MySQL is way faster than SQLite.

Type the following to run MySQL secure installation:
sudo mysql_secure_installation

It will prompt you for your MySQL root password. Enter the password you entered upon installation of LAMP stack.
It will ask you to change root password, type "n" for no.
It will ask you to remove anonymous users, type "y" for yes.
It will ask you to disallow remote root logins, type "y" for yes.
It will ask you to remove test database and access to it, type "y" for yes.
It will ask you to reload privilege tables, type "y" for yes.

Now we have a secure MySQL installation in place.

Installing Prerequisites For ownCloud

Before we can fully utilize ownCloud, we need to install additional libraries that will be used by ownCloud. Execute the following:
sudo apt-get install php5-gd php-xml-parser php5-intl smbclient curl libcurl3 php5-curl

Ubuntu will install additional libraries, and now we have fulfilled all system requirements for ownCloud to function.

ownCloud uses Apache's .htaccess files (you can find more information on .htaccess here) for security purposes. However, in order to use them, we need to enable two apache modules and edit the apache configuration to allow for the .htaccess file. 

Now we need to enable mod_rewrite and mod_headers, the Apache2 modules that are needed for ownCloud to function normally.

The mentioned two modules are used for URL rewrite rules, that is, they help Apache2 rewrite URLs of a certain web site in a proper way. mod_headers module is used for controlling HTTP request and response headers.

To enable mod_rewrite and mod_headers, type the following:
sudo a2enmod rewrite
sudo a2enmod headers

Additionally, we have to change Apache2 config file in order for ownCloud rewrite rules to work properly. Execute the following:
sudo nano /etc/apache2/sites-available/default

There, find "<Directory /var/www/>" section and change the following:
AllowOverride None
AllowOverride All

Hit Ctrl + X, then Y, and then Enter to save the changes.

Now we need to restart Apache2 for changes to take effect:
sudo service apache2 restart

That's it, proceed to the next step.

Downloading ownCloud Source Files and Installing ownCloud 5

Now we need to download the source files of ownCloud 5 and place them in the corresponding directory in order for a web server to be able to serve requests properly.

To download ownCloud 5.0.4 source files, execute the following:

It will download the latest version of ownCloud 5. Now we need to extract the archive. Execute the following:
tar -xjf owncloud-5.0.4.tar.bz2

Now we need to move ownCloud source files in the appropriate directory. Execute the following:
mv owncloud /var/www

Having ownCloud source files in the right place is nice, but we have to change a few folder permissions for ownCloud to function normally. Execute the following:
cd /var/www
sudo chown -R www-data:www-data owncloud

Setting Up a MySQL Database

We're almost done, there's only one thing left to do before we begin installation - setting up a proper MySQL database.

First, log in to MySQL with the following command:
mysql -u root -p

It will prompt you for root password, enter the one you entered upon installing LAMP stack.

Next, create a new database with the following command:

Then assign a new user with proper privileges to the new database:
GRANT ALL ON owncloud.* TO 'owncloud'@'localhost' IDENTIFIED BY 'some_password';

Be sure to replace "some_password" with the actual password you desire for your MySQL database.

Believe it or not, we're done! Type "quit" to exit MySQL interface and point your browser tohttp://fqdn-of-your-droplet.tld/owncloud to access ownCloud 5 installation.

Be sure to replace "fqdn-of-your-droplet.tld" with the actual FQDN of your droplet.

Then, after the installation dialog opens, fill in the details for the admin account. Next, enter the MySQL database details as you set them up in the previous step and click Finish Setup.

You've reached the end of the tutorial! Enjoy your new ownCloud 5 installation.

Artikel Terkait