NextCloud Installation

    • OMV 3.x
    • 3rd-party

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • NextCloud Installation

      General Information

      This guide will work with OMV3 (PHP 5.6).
      Not sure with OMV2 (PHP 5.4).

      This is for NextCloud 11 and newer.

      PHP7 is a little different, and it may break OMV system.

      This guide contain more details than any other guide that I created so far in this forum.




      -----------------------------------------------------------------------------------------------------------------------------------------------------
      Note: the NextCloud users are not sync with OMV users unless you use NextCloud external user support or something similar.

      External user.jpg

      Note 2: You can create a self-sign certificate for your NextCloud in OMV homepage or use Let's Encrypt to generate one (you must currently own a domain).


      Pre-Installation Steps

      1a. Ensure you have the following programs installed and other stuffs:
      MySQL, Nginx, Putty, basic knowledge of Linux, an internet connection,
      apt-get install php5-curl
      apt-get install php5-gd.

      apt-get install zip unzip
      apt-get install wget

      I chose Redis for cache performance, refer to step 8 for more details.

      apt-get install redis-server php5-redis


      Configuration and Installation

      1b. go to your MySQL database, and ensure you can login with it.
      So you can use it for the setup later.

      mysql.jpg





      1c. Log into your OMV homepage, and go to Share Folders tab, and create a share folder call: www

      NC_www.jpg




      1d. Next, create a folder name nextcloud under www, and give nextcloud ACL with Read/Write for www-data user and group.
      Then click "Apply".
      www/nextcloud/



      NC_ACL.jpg





      1e. Go to Nginx (web sites) tab to create a NextCloud pool.

      In the pool config of your NC fpm-pool (nginx/pools) add these lines in the extra options field:

      Source Code

      1. clear_env = no
      2. env[HOSTNAME] = $HOSTNAME
      3. env[PATH] = /usr/local/bin:/usr/bin:/bin
      4. env[TMP] = /tmp
      5. env[TMPDIR] = /tmp
      6. env[TEMP] = /tmp


      NC_pool.jpg




      1f. Use Port 90 for HTTP and port 91 for HTTPS or whatever you desire, but ensure they don't conflict with other web servers.
      Note: It would easier to begin the setup with HTTP than HTTPS. After the installation is done, you can change it to HTTPS, and use Let's Encrypt for your encryption if you want.

      NC_server_p1.jpg





      2. Un-check the "default config' option in the PHP section. (Credit to @Zocker1996)
      Leave the rest default.
      NC_server_p2.jpg







      3. Add this to your Nginx extra options:

      Display Spoiler

      Source Code

      1. add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
      2. add_header X-Content-Type-Options nosniff;
      3. add_header X-Frame-Options "SAMEORIGIN";
      4. add_header X-XSS-Protection "1; mode=block";
      5. add_header X-Robots-Tag none;
      6. add_header X-Download-Options noopen;
      7. add_header X-Permitted-Cross-Domain-Policies none;
      8. location = /robots.txt {
      9. log_not_found off;
      10. allow all;
      11. access_log off;
      12. }
      13. # The following 2 rules are only needed for the user_webfinger app.
      14. # Uncomment it if you're planning to use this app.
      15. #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
      16. #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
      17. # last;
      18. location = /.well-known/carddav {
      19. return 301 $scheme://$host/remote.php/dav;
      20. }
      21. location = /.well-known/caldav {
      22. return 301 $scheme://$host/remote.php/dav;
      23. }
      24. # set max upload size
      25. client_max_body_size 50G;
      26. fastcgi_buffers 64 4K;
      27. # Disable gzip to avoid the removal of the ETag header
      28. gzip off;
      29. # Uncomment if your server is build with the ngx_pagespeed module
      30. # This module is currently not supported.
      31. #pagespeed off;
      32. error_page 403 /core/templates/403.php;
      33. error_page 404 /core/templates/404.php;
      34. location / {
      35. rewrite ^ /index.php$uri;
      36. }
      37. location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
      38. deny all;
      39. }
      40. location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
      41. deny all;
      42. }
      43. location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
      44. fastcgi_split_path_info ^(.+\.php)(/.*)$;
      45. include fastcgi_params;
      46. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      47. fastcgi_param PATH_INFO $fastcgi_path_info;
      48. fastcgi_param HTTPS on;
      49. #Avoid sending the security headers twice
      50. fastcgi_param modHeadersAvailable true;
      51. fastcgi_param front_controller_active true;
      52. fastcgi_pass $socket;
      53. fastcgi_intercept_errors on;
      54. }
      55. location ~ ^/(?:updater|ocs-provider)(?:$|/) {
      56. try_files $uri/ =404;
      57. index index.php;
      58. }
      59. # Adding the cache control header for js and css files
      60. # Make sure it is BELOW the PHP block
      61. location ~* \.(?:css|js|woff|svg|gif)$ {
      62. try_files $uri /index.php$uri$is_args$args;
      63. add_header Cache-Control "public, max-age=7200";
      64. add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
      65. add_header X-Content-Type-Options nosniff;
      66. add_header X-Frame-Options "SAMEORIGIN";
      67. add_header X-XSS-Protection "1; mode=block";
      68. add_header X-Robots-Tag none;
      69. add_header X-Download-Options noopen;
      70. add_header X-Permitted-Cross-Domain-Policies none;
      71. # Optional: Don't log access to assets
      72. access_log off;
      73. }
      74. location ~* \.(?:png|html|ttf|ico|jpg|jpeg)$ {
      75. try_files $uri /index.php$uri$is_args$args;
      76. # Optional: Don't log access to other assets
      77. access_log off;
      78. }
      Display All



      4. Open your Putty, and go to your share drive. ie. /media/UUID/....
      UUID is a long characters such as 54321abcdfgh977.....

      The version may change from time to time.
      You might want to check there before do the installation.

      nextcloud.com/install/#instructions-server


      Update: NC v11.0.2

      Note: You can use the this script for this step if you like: forum.openmediavault.org/index…?postID=138230#post138230 or else follow below steps>>

      Enter the below command in Putty:
      wget https://download.nextcloud.com/server/releases/nextcloud-11.0.2.zip


      Unzip nextcloud archive:
      5. unzip nextcloud-11.0.2.zip

      copy all its files to your nextcloud folder (the one you created earlier):
      cp -r nextcloud/. /media/UUID/www/nextcloud


      6. cd /media/UUID/www/
      chown -R www-data:www-data nextcloud

      7. open your browser and enter your local ip such as: http://192.168.1.10:90 to begin the installation.

      7a. Enter a "." to install in the current directory (/media/UUID/www/nextcloud).

      7b. NextCloud will ask you to create an admin account, and put in your MySQL password to create the database.
      i.e: If you install NC in the OS drive, then it would be like: /var/www/nextcloud
      Otherwise, it would be like: /media/UUID/www/nextcloud




      7c. Follow the rest of the configuration process.



      8. Memory caching:

      Redis is recommended or you can use APCu for low-power CPU such as dual-core or RPI.

      APCu: apt-get install php5-apcu
      Config.php: 'memcache.local' => '\OC\Memcache\APCu',

      Redis: apt-get install redis-server php5-redis
      Config.php: 'memcache.locking' => '\OC\Memcache\Redis',


      Whatever method you choose, it should look like this in the config.php:

      1. Source Code

        1. 'memcache.local' => '\OC\Memcache\Redis',
        2. 'memcache.locking' => '\OC\Memcache\Redis',
        3. 'redis' => array(
        4. 'host' => 'localhost',
        5. 'port' => 6379,
        6. ),
      or

      Source Code

      1. 'memcache.local' => '\OC\Memcache\APCu',
      2. 'memcache.locking' => '\OC\Memcache\Redis',
      3. 'redis' => array(
      4. 'host' => 'localhost',
      5. 'port' => 6379,
      6. ),




      9. Setup Trusted Domains:
      9a. cd /media/UUID/www/nextcloud/config/
      9b. nano config.php

      Ensure you enter your domain & NC IP are correct in here:

      Source Code

      1. 'trusted_domains' =>
      2. array (
      3. 0 => 'localhost',
      4. 1 => 'abc.mycloud.com',
      5. 2 => '192.168.1.10',
      6. ),


      9c. Press Ctrl + O to save.

      9d. Restart Nginx service:
      service nginx restart


      10. After you have NextCloud running like it should be, then remove the NC zip folder.
      cd /media/UUID/
      rm -r nextcloud-11.0.1.zip nextcloud

      11. (Optional). Set strong permission for NextCloud:

      Save the following codes as a script, and execute.
      ./your-script-name

      Change ocpath variable to your appropriate NC path, before execute it.
      Display Spoiler


      Shell-Script

      1. #!/bin/bash
      2. ocpath='/var/www/nextcloud'
      3. htuser='www-data'
      4. htgroup='www-data'
      5. rootuser='root'
      6. printf "Creating possible missing Directories\n"
      7. mkdir -p $ocpath/data
      8. mkdir -p $ocpath/updater
      9. printf "chmod Files and Directories\n"
      10. find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
      11. find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
      12. printf "chown Directories\n"
      13. chown -R ${rootuser}:${htgroup} ${ocpath}/
      14. chown -R ${htuser}:${htgroup} ${ocpath}/apps/
      15. chown -R ${htuser}:${htgroup} ${ocpath}/config/
      16. chown -R ${htuser}:${htgroup} ${ocpath}/data/
      17. chown -R ${htuser}:${htgroup} ${ocpath}/themes/
      18. chown -R ${htuser}:${htgroup} ${ocpath}/updater/
      19. chmod +x ${ocpath}/occ
      20. printf "chmod/chown .htaccess\n"
      21. if [ -f ${ocpath}/.htaccess ]
      22. then
      23. chmod 0644 ${ocpath}/.htaccess
      24. chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
      25. fi
      26. if [ -f ${ocpath}/data/.htaccess ]
      27. then
      28. chmod 0644 ${ocpath}/data/.htaccess
      29. chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
      30. fi
      Display All





      Questions / Problems / Discussions

      If you encounter an error or the setup can't be done, then re-read the tutorial or ask in that thread:
      NextCloud Installation Q & A
      Files
      • NC_DL.PNG

        (34.73 kB, downloaded 650 times, last: )
      OMV v3.0
      Asus Z97-A/3.1; i3-4370
      32GB RAM Corsair Vengeance Pro
      4x3TB RAID10

      The post was edited 76 times, last by ryecoaaron: formatting ().