Installing private network disk service NextCloud under Ubuntu18.04

1. Description

NextCloud is an open source and free private cloud storage network disk project that allows you to quickly and easily build a set of cloud synchronization network disks for yourself or your team, thereby achieving cross-platform and cross-device file synchronization, sharing, version control, team collaboration, etc. Function.

Different from public cloud disks, private cloud disks need to be deployed on your own ECS or lightweight application server and accessed through the public network. The file transfer speed and storage capacity depend on the hardware configuration of your cloud server. The transmission speed is not limited and is safe. Guaranteed.

There are many well-known personal cloud storages at home and abroad, and NextCloud is one of them. This article uses NextCloud as an example to help you build a personal cloud disk from scratch.

2. Installation preparation

NextCloud is an open source project written in php:

  • You need to install the php operating environment and php-mysq extension
  • A web server is required, such as apache or nginx, here we use nginx
3. Download NextCloud project
mkdir /data
cd /data
wget https://download.nextcloud.com/server/releases/nextcloud-16.0.4.zip
unzip nextcloud-16.0.4.zip
cd nextcloud-16.0.4 

Download official website: https://nextcloud.com/install/#icon-default.png?t=N7T8https://nextcloud.com/install/

4. Start nginx server
upstream php-handler {
    server 127.0.0.1:9000;
}

server {
    listen 80;
    server_name 0.0.0.0;
    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;
    add_header Referrer-Policy no-referrer;
    fastcgi_hide_header X-Powered-By;
  
    root /data/nextcloud;
    index index.php;
  
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
 
    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }

    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }

    client_max_body_size 512M;
    fastcgi_buffers 64 4K;
    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$request_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\/. + |oc[ms]- 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 modHeadersAvailable true;
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
    }

    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        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;
        add_header Referrer-Policy no-referrer;
        access_log off;
    }

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

The official website recommends Nginx configuration: Nginx configuration – Nextcloud latest Administration Manual latest documentationicon-default.png?t=N7T8https://docs.nextcloud.com/server/16/ admin_manual/installation/nginx.html

5. Configure NextCloud online

Browser access: http://oss.mlxxlm.cn, follow the prompts to install step by step (mainly configuring the database and initializing the super management account). After successful installation, you can see the following interface

Six: Possible problems

Problem: When configuring a database account online, the prompt fails. Some directories do not have permission to operate.

Solution: According to the error message, adjust the permissions of the corresponding directory without permission so that PHP can operate the corresponding directory.

If the NextCloud request reports an error, you can check the nginx and php error logs to locate the problem. The default logs of nextcloud are in the configured data root directory.

NextCloud Operation Manualicon-default.png?t=N7T8https://docs.nextcloud.com/server/16/admin_manual/index.html

NextCloud client downloadicon-default.png?t=N7T8http://dzzoffice.mlxxlm.cn/index.php?mod=shares & amp;sid=RWpMSzNMc1ZyMjNDTERGUHVKS1A1V04zME1lU3F0NFFNZ0hh

Install the private network disk service NextCloud plug-in under Ubuntu18.04 icon-default.png?t=N7T8http://t.csdn.cn/4z983