22 February 2012

OwnCloud installeren

OwnCloud aims be the solution if you want to keep control over your data while being flexible. It is written in PHP and can optionally use a MySQL database. If you are using a recent version of Ubuntu you can install it from the universe repository. But I am not going to use the package, because it depends on the Apache2 webserver and I am using the nginx webserver.

My Installation

Download, extract and copy the PHP code

  • Create dir and change to it
    mkdir -p /var/www/owncloud/
    cd /var/www/owncloud/
  • Download and extract it
    wget http://owncloud.org/releases/owncloud-3.0.0.tar.bz2
    tar -xjvf owncloud-3.0.0.tar.bz2
  • Rename and hide directory and make a symbolic link named www
    mv owncloud .owncloud-3.0.0
    ln -s .owncloud-3.0.0/ www

Configure nginx

  • Create a configuration file
    sudo vi /etc/nginx/sites-available/owncloud
    • With this content
      server {
          server_name *.owncloud;
          rewrite ^ $scheme://owncloud$request_uri permanent;
      }
      server {
          server_name owncloud;
          access_log      /var/log/nginx/owncloud.access.log;
          root        /var/www/owncloud/www;
      
          location / {
              allow   all;
              dav_methods PUT DELETE MKCOL COPY MOVE;
              dav_access  user:rw group:rw;
              try_files $uri $uri/ $uri.php;
          }
      
          location ~ \.(tpl|inc)$ {
              deny    all;
          }
          location ~ /\.?(include|tpls|tpls_c)/ {
              deny    all;
          }
          location ~ /\. {
              deny    all;
          }
          location ~ \.(php|html)$ {
              include     /etc/nginx/fastcgi_params;
              fastcgi_pass    127.0.0.1:9000;
              fastcgi_index   index.html;
              fastcgi_split_path_info ^(.+\.php)(/.*)$;
              fastcgi_param   SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
              fastcgi_param PATH_INFO $fastcgi_path_info;
              fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
          }
      }
      
  • Create symbolic link and enable the site
    cd /etc/nginx/sites-enabled/
    sudo ln -s ../sites-available/owncloud
    sudo service nginx restart
    

Configure owncloud

  • owncloud is running at http://owncloud/ but complains about the rights on the data directory
    cd /var/www/owncloud/www/
    chmod 770 data/
    chgrp www-data data/
    
  • Now we have only to fill the credentials to finish the installation.
  • but I want create a MySQL database too. You can fill the MySQL credentials by clicking on Advanced.
    • Create a MySQL database
      sudo mysql --defaults-file=/etc/mysql/debian.cnf
      CREATE DATABASE owncloud;
      GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost' IDENTIFIED BY 'choose_password';
      QUIT
      
    • Fill out the webform with database user, database password, database name and localhost
  • After hitting Complete Setup it complains about the rights of the config directory
    cd /var/www/owncloud/www/
    chmod 770 config/
    chgrp www-data config/
    
  • Hitting the F5 key to refresh the web page and post the form data again, shows a working owncloud installation!