How to install ownCloud 9.1.4 on CentOS 7

ownCloud 9.1.4

Introduction

OwnCloud 9.1.4 is an open source software for file sharing and data synchronization that is very useful in the enterprise sector, with an easy to use front-end web format.

This tutorial is about installing ownCloud on CentOS 7 with Nginx as your web server.

Install Nginx and PHP

First, install Nginx. This web server is available on EPEL repository, so just add it like this:

# yum install epel-release

and then:

# yum install nginx

Next, install PHP-FPM (FastCGI Process Manager), using webtatic repository, which is added with the following command:

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Now it is possible to install PHP with other packages required by ownCloud:

# yum install php70w-fpm php70w-cli php70w-json  php70w-mcrypt  php70w-pear php70w-mysql php70w-xml php70w-gd php70w-mbstring php70w-pdo

Configure PHP-FPM for Nginx

PHP-FPM configuration is done by editing the php7-fpm configuration file:

# $EDITOR /etc/php-fpm.d/www.conf

Search lines containing “user” and “group” and change with:

user = nginx
group = nginx

Scroll down, looking for line “listen”, and change the content to:

listen = 127.0.0.1:9000

Next, uncomment the following lines about environment variables:

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

Save and exit.
Now, it’s time to create a new folder in /var/lib/, with the following command:

# mkdir -p /var/lib/php/session

Change its owner to nginx user:

# chown nginx:nginx -R /var/lib/php/session/

Start nginx and PHP-FPM:

# sudo systemctl start php-fpm
# sudo systemctl start nginx

Add to start at boot time (required for daily usage for the machine as server) :

# systemctl enable nginx
# systemctl enable php-fpm

Install MariaDB

MariaDB is available in the CentOS repository, so install it with:

# yum install mariadb mariadb-server

Configure the MariaDB root password:

# mysql_secure_installation

During the process, answer the following questions:

Set root password? [Y/n]
New password:
Re-enter new password:

Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

Login to the MariaDB shell to create a new database and user for ownCloud. In this example, my_owncloud_db is the database name and ocuser is its user. The password is: my_strong_password.
So, execute the command:

# mysql -u root -p

and then:

mysql> CREATE DATABASE my_owncloud_db;
mysql> CREATE USER [email protected] IDENTIFIED BY 'my_strong_password';
mysql> GRANT ALL PRIVILEGES ON my_owncloud_db.* to [email protected] IDENTIFIED BY 'my_strong_passowrd';
mysql> FLUSH PRIVILEGES;

Generate a SSL Certificate

If none exists, create a new directory for the SSL file:

# mkdir -p /etc/nginx/cert/

Next, generate a new SSL certificate file:

# openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/owncloud.crt -keyout /etc/nginx/cert/owncloud.key

Change the permissions with the following command:

# chmod 600 /etc/nginx/cert/*

Download ownCloud

Download ownCloud Server:

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

Extract the archive and move it to /usr/share/nginx/html/:

# unzip owncloud-9.1.2.zip
# mv owncloud/ /usr/share/nginx/html/

Go to the Nginx root directory; there, create a new data directory for ownCloud:

# cd /usr/share/nginx/html/
# mkdir -p owncloud/data/

Configure a Virtual Host in Nginx

Create a Virtual Host configuration file with the following command:

# $EDITOR /etc/nginx/conf.d/owncloud.conf

Paste the following text into the file:

 upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}
 
server {
    listen 80;
    server_name data.owncloud.co;
    # enforce https
    return 301 https://$server_name$request_uri;
}
 
server {
    listen 443 ssl;
    server_name storage.example.com;
 
    ssl_certificate /etc/nginx/cert/owncloud.crt;
    ssl_certificate_key /etc/nginx/cert/owncloud.key;
 
    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this topic first.
    add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
    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;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
 
    # Path to the root of your installation
    root /usr/share/nginx/html/owncloud/;
 
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
 
    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
 
    location = /.well-known/carddav {
        return 301 $scheme://$host/remote.php/dav;
    }
    location = /.well-known/caldav {
        return 301 $scheme://$host/remote.php/dav;
    }
 
    location /.well-known/acme-challenge { }
 
    # set max upload size
    client_max_body_size 512M;
    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;
 
    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;
 
    location / {
        rewrite ^ /index.php$uri;
    }
 
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        return 404;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        return 404;
    }
 
    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.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_param modHeadersAvailable true; #Avoid sending the security headers twice
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }
 
    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri $uri/ =404;
        index index.php;
    }
 
    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~* \.(?:css|js)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=7200";
        # Add headers to serve security related headers (It is intended to have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into this topic first.
        #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
        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;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don't log access to assets
        access_log off;
    }
 
    location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

Save and exit. Next, test Nginx:

# nginx -t

This should display a “Syntax OK” message.

Restart Nginx:

# systemctl restart nginx

Conclusion

The server side configuration is complete. The last thing to do is to go to your ownCloud server URL (storage.example.com in this example) with a web browser and finish the configuration with the graphical front-end. Do this by creating a new admin account, and entering database credentials created in the previous steps. Your cloud storage service is now ready for a daily usage!

  • [email protected]

    I’ve earned 104000 dollars previous year by freelancing on-line a­n­d I manage to accomplish that by w­orking part-time for few hours /daily. I’m using work opportunity I stumbled upon from this website i found online and I am so thrilled that i made so much extra income. It’s really user-friendly a­­n­­d I’m so blessed that i learned about it. Here is what i do… http://www­.­wzurl­.­me/R58CMA

  • [email protected]

    I was paid $104k previous year by doing an online job a­­n­­d I did it by w­o­r­k­i­n­g part time for 3 or sometimes more hours daily. I’m using an earning opportunity I stumbled upon from this website i found online and I am so amazed that I was able to earn such great money. It’s really user-friendly a­­n­­d I’m so blessed that i discovered it. Check out what I do… http://tny­.­im/8Ai

  • I’ve earned 104000 dollars previous year by freelancing online and I was able to do it by work­ing in my own time for 3 or sometimes more h on daily basis. I followed work model I stumbled upon from company that i found online and I am amazed that i earned so much money on the side. It’s so user friendly and I’m just so grateful that i found this. Here is what i did… http://www.wzurl­.­me/tEXzrw

  • alice.masterson

    I was paid $104k previous year by freelancing on-line a­n­d I did it by w­o­r­k­i­n­g part time f­­o­­r several hrs daily. I was following a money making model I came across from company that i found online and I am so excited that i was able to make so much money on the side. It’s so beginner-friendly a­n­d I am just so blessed that I found out about it. This is what i did… http://www.wzurl­.­me/m7IQvg

  • bell_raymond

    I got paid 104 thousand bucks previous year by working on-line a­­n­­d I was able to do it by w­orking part time f­o­r few hrs /daily. I was following a money making opportunity I found online and I am amazed that i earned so much extra income. It’s user-friendly and I’m so thankful that i learned about it. This is what i did… http://urlof­.­site/nTOpe

  • [email protected]

    I was paid 104000 bucks previous 12 month period by doing an on-line work while I was able to do it by w­orking in my own time f­o­r several hours regularly. I applied work opportunity I stumbled upon online and so I am excited that I was in the position to earn such decent earnings. It is undoubtedly newbie-friendly and therefore I am so pleased that I found out about it. Have a look at what I do… I was without work for 6 months when my early Fellow worker at last suggested me to get into freelancing at home… It was really after I received $5000 in my very first thirty days when I seriously believed I could do this for a living! Now a days I am delightful than ever… I work-at-home and I am my own boss now like I always wanted… I see a lot of unsatisfied people around me, working the same old boring job that’s sucking the everyday life from all of them day by day… Whenever I notice anyone similar to that I say START FREELANCING MAN! This is how I started >>>> www­.­cat­.­org­.­uk/snip/78276

  • jacqueline.burton

    I was paid 104000 dollars past year by doing an online job as well as I was able to do it by w­orking in my own time f­o­r several hours regularly. I utilized work opportunity I found online and I am delighted that I was capable of to make such decent money. It’s undoubtedly newbie-friendly and I am so delighted that I discovered out regarding it. Check out what I do… http://secure10­.­weebly­.­com