Install OwnCloud on CentOS 7

This guide is for installing OwnCloud on a fresh CentOS 7 server. OwnCloud is a FOSS (Free and Open Source Software) web-based data storing and sharing platform. In short, it's a free, self-hosted alternative to Dropbox, Google Drive, etc. I've known about OwnCloud for a few years now, but haven't used it since version 5.

This guide is now based OwnCloud version 8.2.3.

This install guide will guide you through installing Paperwork using Nginx, PHP-FPM, and MariaDB on CentOS 7.

For simplicity sake, I will be installing as root, running Nginx/PHP-FPM as nginx, disabling SELinux, and disabling the firewall (Firewalld). Obviously, it is not recommended to do this in a production environment, so tweak to your needs.

Let's Get Started!

0.) Disable SELinux and Disable FirewallD:
systemctl disable firewalld.service
sed -i /etc/selinux/config -r -e 's/^SELINUX=.*/SELINUX=disabled/g'
systemctl reboot
1.) Requisites:

Add repos:

yum -y install epel-release

Install stuff:

yum -y install bzip2 curl git mariadb mariadb-server nginx php php-fpm php-gd php-gmp php-intl php-ldap php-mbstring php-mcrypt php-mysqlnd php-xml samba-client wget

Start services:

systemctl stop httpd.service
systemctl disable httpd.service
systemctl restart nginx.service
systemctl restart php-fpm.service
systemctl restart mariadb.service
2.) Edit configs:

www.conf (ensure these fields are set)

vi /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx ; SOCKS permission = nginx ; SOCKS permission
listen.mode = 0660 ; SOCKS permission
user = nginx ; PHP-FPM running user
group = nginx ; PHP-FPM running group
php_value[session.save_path]    = /var/www/sessions


rm -rf /etc/nginx/nginx.conf
vi /etc/nginx/nginx.conf
user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log;

pid        /run/;

events {
    worker_connections  1024;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;

    keepalive_timeout  65;

    include /etc/nginx/conf.d/*.conf;

    index   index.html index.htm;


vi /etc/nginx/conf.d/default.conf
server {
  listen 80;
  server_name localhost;
  root /var/www/owncloud;

  # set max upload size
  client_max_body_size 10G;
  fastcgi_buffers 64 4K;

  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-jsonlast;

   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/ index.php;

   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_pass unix:/var/run/php-fpm/php-fpm.sock;

   # Optional: set long EXPIRES header on static assets
   location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
       expires 30d;
       # Optional: Don't log access to assets
         access_log off;

3.) MariaDB Config:
mysql_secure_installation # Set root password, and other settings as desired
4.) Install OwnCloud
mkdir -p /var/www/sessions && cd /var/www
tar -xjf owncloud-8.2.3.tar.bz2 -o owncloud
5.) Configure Database
mysql -u root -p # Enter root password
GRANT ALL PRIVILEGES ON ownclouddb.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'owncloudpass' WITH GRANT OPTION;
6.) Cleanup
rm -rf /var/www/{owncloud-8.2.3.tar.bz2,cgi-bin,html}
chown -R nginx:nginx /var/www/{owncloud,sessions}
systemctl enable nginx.service && systemctl enable php-fpm.service && systemctl enable mariadb.service
systemctl reboot

Install isn't too bad, and seems to work well on CentOS 7 with Nginx. Browse to http://(SERVER_IP) to create an account, configure the database (as MySQL), and sign in.

Hope you enjoyed, and please contact me if you have any feedback!

Related Posts

Share on: Twitter | Facebook | Google+ | Email

comments powered by Disqus