sudo su
su
mysql -uroot -p
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'strong_password';
FLUSH PRIVILEGES;
\q
nano /etc/mysql/mariadb.conf.d/50-server.cnf
log-bin = /var/log/mysql/mariadb-bin
log-bin-index = /var/log/mysql/mariadb-bin.index
binlog_format = mixed
systemctl reload mysql
uncomment following environment variables from /etc/php/7.0/fpm/pool.d/www.conf
nano /etc/php/7.0/fpm/pool.d/www.conf
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
service php7.0-fpm restart
wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip -d /usr/share/nginx/
chown -R www-data:www-data /usr/share/nginx/
nano /etc/nginx/conf.d/nextcloud.conf
server {
listen 80;
server_name <IP> OR DOMAIN <IP>;
# Add headers to serve security related headers
add_header X-Content-Type-Options nosniff;
#uncomment following line. looks like its now standard in nginx
# 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/nextcloud/;
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 {
allow all;
}
# 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)/ {
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(?:$|/) {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
#Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
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)$ {
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)
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;
}
}
nginx -t
systemctl reload nginx
rm -r /etc/nginx/sites-enabled
rm /etc/nginx/conf.d/default.conf
nginx -t
systemctl reload nginx
apt install php7.0-zip php7.0-intl php7.0-mcrypt php-imagick
flavoured by https://bayton.org/docs/nextcloud/installing-nextcloud-on-ubuntu-16-04-lts-with-redis-apcu-ssl-apache/
apt install php-apcu redis-server php-redis
service php7.0-fpm restart
nano /etc/redis/redis.conf
port 6379 -> port 0
unixsocket /var/run/redis/redis.sock
unixsocketperm 770
sudo usermod -a -G redis www-data
now you can visit your nextcloud landing page via browser at <IP> OR DOMAIN <IP>
admin account
alf_admin1337
really_strong_password
Data folder
/usr/share/nginx/nextcloud/data/
Configure the database
nextcloud
strong_password
nextcloud
localhost
nano /usr/share/nginx/nextcloud/config/config.php
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'timeout' => 0.0,
),
nano /etc/php/7.0/fpm/php.ini
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=1
opcache.save_comments=1
systemctl reload php7.0-fpm
#use Cron instead Ajax
flavoured by https://docs.nextcloud.com/server/12/admin_manual/configuration_server/background_jobs_configuration.html
crontab -u www-data -e
*/15 * * * * php -f /usr/share/nginx/nextcloud/cron.php
crontab -u www-data -l
mkdir /home/Nextcloud_extern
lsblk
mount -t auto /dev/sda1 /home/Nextcloud_extern
chown -R www-data:www-data /home/Nextcloud_extern
nano /etc/fstab
/dev/sda1 /home/Nextcloud_extern auto noatime 0 0
apt install smbclient
systemctl reload php7.0-fpm
systemctl reload nginx
activate External storage support
External storage
nano /usr/share/nginx/nextcloud/data/nextcloud.log
reach me via derbarti gmail com