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.
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.
1c. Log into your OMV homepage, and go to Share Folders tab, and create a share folder call: www
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/
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:
clear_env = no
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
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.
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:
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;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
location = /robots.txt {
log_not_found off;
allow all;
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;
}
# set max upload size
client_max_body_size 50G;
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)/ {
deny all;
}
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
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;
#Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass $socket;
fastcgi_intercept_errors on;
}
location ~ ^/(?:updater|ocs-provider)(?:$|/) {
try_files $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|woff|svg|gif)$ {
try_files $uri /index.php$uri$is_args$args;
add_header Cache-Control "public, max-age=7200";
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;
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 ~* \.(?:png|html|ttf|ico|jpg|jpeg)$ {
try_files $uri /index.php$uri$is_args$args;
# Optional: Don't log access to other assets
access_log off;
}
Alles anzeigen
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.
https://nextcloud.com/install/#instructions-server
Update: NC v11.0.2
Note: You can use the this script for this step if you like: http://forum.openmediavault.or…?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:
or
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
),
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:
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.
#!/bin/bash
ocpath='/var/www/nextcloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'
printf "Creating possible missing Directories\n"
mkdir -p $ocpath/data
mkdir -p $ocpath/updater
printf "chmod Files and Directories\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/
chmod +x ${ocpath}/occ
printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
then
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi
Alles anzeigen
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