Install and configure ownCloud 9.1.4 on openSUSE Leap 42.2

ownCloud 9.1.4

Introduction

ownCloud is an open source file syncing and sharing software, just like Dropbox. Just placing files in a local shared directory, those files will be immediately synchronized to the server and to other devices using the ownCloud Desktop Sync Client, Android app, or iOS app.

This tutorial explains how to install and configure the server side of ownCloud on openSUSE 42.2.

Getting started

First of all, install SuSEfirewall2. This is a script that generates iptables rules from configurations stored in /etc/sysconfig/SuSEfirewall2. Install it with zypper:

# zypper in SuSEfirewall2

There is also a YaST configuration module, but it doesn’t permit you to configure all firewall settings, so it’s necessary to manually edit the configuration file:

# $EDITOR /etc/sysconfig/SuSEfirewall2

In there, search for FW_SERVICES_EXT_TCP line and change as follow:

FW_SERVICES_EXT_TCP="22 80 443"

These are: ssh, http, and https ports.
Save and exit.

Next, start it and enable it to start at boot time:

# systemctl start SuSEfirewall2
# systemctl enable SuSEfirewall2

Restart sshd:

# systemctl restart sshd

Install NGINX

NGINX is also available on openSUSE repositories, so:

# zypper in nginx

Start and enable it:

# systemct start nginx
# systemctl enable nginx

Installing MariaDB

As for NGINX, MariaDB is also available as openSUSE package, so:

# zypper in mariadb mariadb-client

Next:

# systemctl start mysqld
# systemctl enable mysqld

Configure its root account:

# mysql_secure_installation
Enter current password for root (enter for none):
Set root password? [Y/n]
New password:
Re-enter new password:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Reload privilege tables now? [Y/n]

Now it’s possible to log in to the MariaDB shell and create a new database and user that will be used for ownCloud:

# mysql -u root -p

In the database system shell:

mysql> CREATE DATABASE myownclouddb;
mysql> CREATE USER 'ocuser'@'localhost' IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON 'myownclouddb.*' TO 'ocuser'@'localhost' IDENTIFIED BY 'user_strong_password';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Now MariaDB is correctly configured for ownCloud.

Install PHP-FPM

ownCloud requires PHP 5.4+. Install PHP-FPM, which is a FastCGI alternative useful when handling sites with a lot of visitors. In this guide we’ll be using PHP7.
Through zypper:

# zypper in php7-fpm php7-gd php7-mysql php7-mcrypt php7-curl php7-pear php7-zip php7-json php7-ldap

Next, copy the default php-fpm configuration file, executing the following commands:

# cd /etc/php7/fpm
# cp php-fpm.conf.default php-fpm.conf

Open that file with a text editor:

# $EDITOR php-fpm.conf

There, look for (and modify as follows) the following lines:

error_log = log/php-fpm.log
user = nginx
group = nginx
listen = /var/run/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Save and exit.
Now, modify php.ini:

# $EDITOR /etc/php7/cli/php.ini

Uncomment line 761 and change its value:

cgi.fix_pathinfo=0

Save, exit and copy this file to conf.d:

# cp php.ini /etc/php7/conf.d/

The PHP7 session directory is /var/lib/php7. Change its owner to nginx user:

# chown -R nginx:nginx /var/lib/php7/
Configure NGINX to work with PHP-FPM

Create a new NGINX configuration file, making a backup of the old one:

# cd /etc/nginx
# cp nginx.conf nginx.conf.bk
# $EDITOR nginx.conf

On line 65, add the following configuration:

 location ~ \.php$ {
                root /srv/www/htdocs;
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/run/php-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }

Save, exit and test nginx:

# nginx -t

You should read the following lines:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

At the end:

# systemctl start php-fpm
# systemctl enable php-fpm
# systemctl restart nginx

Install ownCloud

Go to the web root directory, which is /srv/www, and there download ownCloud:

# wget https://download.owncloud.org/community/owncloud-9.1.4.tar.bz2

Extract the archive:

# tar xf owncloud-9.1.4.tar.bz2

In the owncloud extracted folder, create a new data directory, and change its owner to nginx user:

# mkdir owncloud/data
# chown -R nginx:nginx owncloud/
Configure a Virtual Host for ownCloud

Next step is to configure a Virtual Host in NGINX for ownCloud.

# mkdir /etc/nginx/vhosts.d && cd /etc/nginx/vhosts.d

There, create a new file:

# $EDITOR owncloud.conf

Paste the following content in that file:

upstream php-handler {
  #server 127.0.0.1:9000;
  server unix:/var/run/php-fpm.sock;
}

server {
  listen 80; # If you have a SSL certificate (Recommended), change this line with "listen 443 ssl;" and add certificate lines;
  server_name storage.mydomain.com;

  # Path to the root of your installation
  root /srv/www/owncloud/;
  # set max upload size
  client_max_body_size 10G;
  fastcgi_buffers 64 4K;

  # Disable gzip to avoid the removal of the ETag header
  gzip off;

  # Uncomment if your server is build with the ngx_pagespeed module
  # This module is currently not supported.
  #pagespeed off;

  rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
  rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
  rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

  index index.php;
  error_page 403 /core/templates/403.php;
  error_page 404 /core/templates/404.php;

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
    deny all;
  }

  location / {
    # The following 2 rules are only needed with webfinger
    rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

    rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
    rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

    rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

    try_files $uri $uri/ =404;
  }

  location ~ \.php(?:$|/) {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param HTTPS on;
    fastcgi_pass php-handler;
    fastcgi_intercept_errors on;
  }

  # Adding the cache control header for js and css files
  # Make sure it is BELOW the location ~ \.php(?:$|/) { block
  location ~* \.(?:css|js)$ {
    add_header Cache-Control "public, max-age=7200";
    # Add headers to serve security related headers
    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    # Optional: Don't log access to assets
    access_log off;
  }

  # Optional: Don't log access to other assets
  location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
    access_log off;
  }
}

Save, exit and restart services:

# systemctl restart nginx
# systemctl restart php-fpm
# systemctl restart mysql

Conclusions

The server side is now well configured. The last step is to go with a web browser to: http://storage.mydomain.com and finish a graphical configuration. At the end of this process your ownCloud Dashboard will be fully available!

  • Chairman of Yahoo and Google!, is telling folks to start off “Work at home” method, that Marketers have been doing for more than a year now. This season only, I made about $36k up till now with no more than my desktop as well as some extra time, although i have a fulltime nine to five job. Even everyone not used to this, can make $50/per h undoubtedly and the gains can be much higher in the long run… This is how i started >> http://adultadda­.­net/2Y4

  • M­a­n­y p­e­o­ple wish t­o ha­v­e a go­o­d in­com­e at their, bu­t t­he­y do­n’t kno­w ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a many w­ays t­o ea­rn am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a fraud, So Now I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 every month since 12 months.Its an online work and also quite easy to do, Even a little boy or girl can do this work and make online money. If you want a happy and rich life then you need to copy and paste this site in web browser and then follow instructions to get started today and earn Thousands Using the internet……….. http://ipt­.­pw/ihWRiH

  • M­a­n­y p­e­o­ple wish t­o ha­v­e a passive in­com­e at h­o­me, bu­t t­he­y don’t have much idea ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a a number of w­ays t­o ea­rn big am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a s­cam, And so Now I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 every month since a year.Its an internet job and easy to do, Even a little child can do this work and make money. If you want a happy and wealthy life then you should copy and paste this website in browser and then follow instructions to get started today and earn Thousands Using the internet……….. http://b1z­.­org/38N

  • I have been on a number of systems but nothing worked for me in the right manner. And finally in 2012 I discovered a system which is crazy. It is extremely simple and easy to setup and I started advertising it within few mins.This system works and is ideal for anyone regardless of age group,educational background or occupational skills.You can get instant results even if you feel like you have sup-par computer skills.I have earned $1000 during my initial week and after that I am making $10000 or more per thirty days.Thank you for creating this amazing system that is perfect for the average person >>>> http://deliciousurl­.­com//1h

  • If you are in search of good online home based business venture and you are sick and tired with internet fraudsters then this is actually what you need. I started out doing this gig 2 years now and I am getting $7000 or higher each and every mnth effortlessly. Make income same as me… Have a look at the site >>>>>>>>>>> http://v15­.­uk/dngk8

  • Creating wealth over the net is often as hassle-free (or just as complex) as making money off-line. Though thousands upon thousands of Marketing and advertising industry professionals guarantee to possess a secret procedure to generate fast money, the fact is, you do not have any system you are able to turn out to be wealthy person quickly by way of clicking a key or perhaps finding quite a few e book. Making money over the internet ought to have intense work as well as persistence. For anyone who is wanting to input the amount of time and consequently energy involved with it, there are a lot techniques for making high earning potential over the web.I am earning $10000 and even much more month to month using this gig.Here is the secret to generate a profit although the others are longer term ideas to make money >>>>> OUOURL.COM/4rfp

  • Have you ever acquired large sums of money without trying to sell anything and also left out taking part in any mlm marketing sort of work without the need to invest anything at all. Let me discuss a work wherein all software is certainly given to you and consequently its a relatively easy moreover relatively simple task. Without requiring to startup your personal domain names and etc., almost all is certainly provided to you free of cost. Visitors definitely will log in a site so you will get remunerated for that. Its as easy as that. Now I am making a ton of cash from a home office from this project exactly like 20 thousand bucks once per month and more and if you might prefer to take home money like this so therefore follow these particular effortless details by seeing this page >>>>> URL4.UK/WAoxc

  • jaume

    I do not speak English but your tutorial has been very useful.
    however, I have a problem with the start of “systemctl start php-fpm”:
    “Job for php-fpm.service failed because the control process exited with error code. See” systemctl status php-fpm.service “and” journalctl -xe “for details”.

    if I try to start the service with yast I get:

    p, li { white-space: pre-wrap; } : [/etc/php7/fpm/php-fpm.conf:25] unknown entry ‘user’

    Oct 12 15:29:58 linux-qeat php-fpm[5828]: [12-Oct-2017 15:29:58] ERROR: failed to load configuration file ‘/etc/php7/fpm/php-fpm.conf’

    Oct 12 15:29:58 linux-qeat php-fpm[5828]: [12-Oct-2017 15:29:58] ERROR: FPM initialization failed

    apparently the nginx server and the database are properly.
    you would be very kind if you could give me some idea.
    work with opensuse 42.2 I do not know if I can give you another data that is useful to you ..