Nextcloud 15 & OnlyOffice installation guide

Step 1 of 2

Nextcloud Installation

apt update

apt install nginx php7.0 php7.0-intl php7.0-gd php7.0-json php7.0-mysql php7.0-common php7.0-curl php7.0-mbstring php7.0-mcrypt php7.0-xml php-imagick php7.0-zip mysql-server -y

systemctl start nginx

systemctl enable nginx

netstat -plntu

curl -I localhost

OPTIONAL crypt

apt install letsencrypt -y

systemctl stop nginx

letsencrypt certonly --standalone -d nextcloud.hakase-labs.io

End of OPTIONAL crypt

cd /etc/nginx/sites-available/

nano nextcloud

Paste content below into nano:

upstream php-handler {

#server 127.0.0.1:9000;
server unix:/run/php/php7.0-fpm.sock;

}

server { listen 80; listen [::]:80; server_name localhost;

# enforce https
return 301 https://$server_name$request_uri;

}

server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name localhost; add_header X-Content-Type-Options nosniff; 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 /var/www/nextcloud/;

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

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 512M;
fastcgi_buffers 64 4K;

# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

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/.+)\.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;
    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/ =404;
    index index.php;
}

location ~ \.(?:css|js|woff|svg|gif)$ {
    try_files $uri /index.php$uri$is_args$args;
    add_header Cache-Control "public, max-age=15778463";
    add_header X-Content-Type-Options nosniff;
    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;
    access_log off;
}

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
    try_files $uri /index.php$uri$is_args$args;
    access_log off;
}

}

Press Control-X to exit, then y to save and Enter.

ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/

nano /etc/nginx/sites-enabled/default

Replace root /var/www/html with root /var/www/nextcloud

Uncomment listen 443 lines

Add index.php in the index line

Uncomment location ~ .php$ {} and everything below including }

nano /etc/php/7.0/fpm/php.ini

add in second line cgi.fix_pathinfo = 0

nano /etc/nginx/nginx.conf

Un-hash:

server_names_hash_bucket_size 64

nginx -t

systemctl restart nginx

Optional PHP

cd /etc/php/7.0/

Uncomment the 'date.timezone' line and change the value with your own timezone.

Uncomment the cgi.fix_pathinfo=0

nano fpm/php.ini

nano cli/php.ini

END of Optional PHP

systemctl restart php7.0-fpm

systemctl enable php7.0-fpm

systemctl start mysql

systemctl enable mysql

mysql -u root -p

CREATE DATABASE nextcloud_db;

Don’t forget to replace ‘PASSWORD’ with an actual strong password.

GRANT ALL PRIVILEGES ON nextcloud_db.* TO 'nextcloud_user'@'localhost' IDENTIFIED BY 'PASSWORD';

FLUSH PRIVILEGES;

exit;

cd /var/www

wget https://download.nextcloud.com/server/releases/latest-15.zip

unzip latest-15.zip

chown -R www-data:www-data nextcloud

rm latest-15.zip

OPTIONAL APACHE

apt install apache2 libapache2-mod-php7.0 -y

systemctl enable apache2

systemctl status apache2

nano /etc/apache2/sites-available/000-default.conf

Paste content below into nano:

<VirtualHost *:80>

ServerAdmin [email protected]

DocumentRoot /var/www/nextcloud

ServerName your-domain.com

ServerAlias www.your-domain.com

Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>

Options +FollowSymlinks

AllowOverride All

<IfModule mod_dav.c>

Dav off

</IfModule>

SetEnv HOME /var/www/nextcloud

SetEnv HTTP_HOME /var/www/nextcloud

</Directory>

ErrorLog /var/log/apache2/nextcloud-error_log

CustomLog /var/log/apache2/nextcloud-access_log common

</VirtualHost>

Press Control-X to exit, then y to save and Enter.

sudo ufw allow 80,443/tcp

ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf

a2enmod rewrite headers env dir mime

systemctl restart apache2

END OF OPTIONAL APACHE

Finally you can now access your Nextcloud server by clicking here: https://[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/

Using parameters: nextcloud_user , nextcloud_db and password provided in database configuration

nextcloud

For WebDAV connection in windows, map network drive in file explorer using following link , replacing USERNAME with your Nextcloud username:

https://[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/remote.php/dav/files/USERNAME/

For more details on WebDAV configuration please use following resources:

Windows: https://www2.le.ac.uk/offices/itservices/ithelp/my-computer/files-and-security/work-off-campus/webdav/webdav-on-windows-10

Linux: https://docs.nextcloud.com/server/14/user_manual/files/access_webdav.html