重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

installNextCloud16onUbuntuserver19.04

install NextCloud 16 on Ubuntu 19.04

创新互联公司从2013年创立,是专业互联网技术服务公司,拥有项目成都网站设计、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元汤旺做网站,已为上家服务,为汤旺各地企业和个人服务,联系电话:028-86922220


change sources.list
cp -p /etc/apt/sources.list /etc/apt/sources.list.bk
> /etc/apt/sources.list
vi /etc/apt/sources
#阿里云源
deb http://mirrors.aliyun.com/ubuntu/ disco main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ disco-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ disco-proposed main restricted universe multiverse
---------------------


apt install nginx
systemctl start nginx
systemctl enable nginx

Check status:
systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-07-01 12:35:57 UTC; 30s ago
     Docs: man:nginx(8)
Main PID: 15119 (nginx)
    Tasks: 5 (limit: 2276)
   Memory: 5.7M
   CGroup: /system.slice/nginx.service
           ├─15119 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           ├─15120 nginx: worker process
           ├─15121 nginx: worker process
           ├─15122 nginx: worker process
           └─15123 nginx: worker process


apt install php7.2 php7.2-bz2 php7.2-cli php7.2-common php7.2-curl php7.2-fpm php7.2-gd php7.2-imagick php7.2-intl php7.2-json php7.2-ldap php7.2-mbstring php7.2-MySQL php7.2-opcache php7.2-readline php7.2-xml php7.2-zip


sudo systemctl start php7.2-fpm

Enable auto-start at boot time.
sudo systemctl enable php7.2-fpm

Check status:

systemctl status php7.2-fpm

● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-07-01 12:38:13 UTC; 26s ago
     Docs: man:php-fpm7.2(8)
Main PID: 25832 (php-fpm7.2)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 2276)
   Memory: 8.7M
   CGroup: /system.slice/php7.2-fpm.service
           ├─25832 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
           ├─25841 php-fpm: pool www
           └─25842 php-fpm: pool www


Here are the commands to run to install MariaDB 10.4 from the MariaDB repository on your Ubuntu system:

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.4/ubuntu disco main'

Once the key is imported and the repository added you can install MariaDB 10.4 from the MariaDB repository with:

sudo apt update
sudo apt install mariadb-server

See Installing MariaDB .deb Files for more information and for instructions on installing MariaDB Galera Cluster.

You can also create a custom MariaDB sources.list file. To do so, after importing the signing key as outlined above, copy and paste the following into a file under /etc/apt/sources.list.d/(we suggest naming the file MariaDB.list or something similar), or add it to the bottom of your /etc/apt/sources.list file.

# MariaDB 10.4 repository list - created 2019-07-01 12:27 UTC
# http://downloads.mariadb.org/mariadb/repositories/
deb [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.4/ubuntu disco main
deb-src http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.4/ubuntu disco main

#apt-get install mariadb-server

check version

mysql --version
mysql  Ver 15.1 Distrib 10.4.6-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

 

$ mysql -u root -p
Now that you are in create a database:

CREATE DATABASE nextcloud;
Now you need to create the user that will be used to connect to the database:

CREATE USER 'ncadmin'@'localhost' IDENTIFIED BY 'F***@nextcloud';
The last step is to grant the privileges to the new user:

GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncadmin'@'localhost';
FLUSH PRIVILEGES;
When you’re done type Ctrl-D to exit.


Nginx configuration

https://docs.nextcloud.com/server/16/admin_manual/installation/nginx.html#

vi /etc/nginx/sites-available/nextcloud

upstream php-handler {
    #server 127.0.0.1:9000;
    server unix:/var/run/php/php7.2-fpm.sock;
}

server {
    listen 80;
    listen [::]:80;
    server_name pan.example.com;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name cloud.example.com;

    # Use Mozilla's guidelines for SSL/TLS settings
    # https://mozilla.github.io/server-side-tls/ssl-config-generator/
    # NOTE: some settings below might be redundant
    ssl_certificate /etc/ssl/nginx/pan.example.com.crt;
    ssl_certificate_key /etc/ssl/nginx/pan.example.com.key;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
     add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    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;

    # Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;

    # Path to the root of your installation
    root /var/www/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;

    # The following rule is only needed for the Social app.
    # Uncomment it if you're planning to use this app.
    # rewrite ^/.well-known/webfinger /public.php?service=webfinger 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 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;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;

    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 HTTPS on;
        #Avoid sending the security headers twice
        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;
    }

    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        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;

        # Optional: Don't log access to assets
        access_log off;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }
}


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


mkdir /etc/ssl/nginx

copy ssl file to /etc/ssl/nginx


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

unzip nextcloud-16.0.1.zip -d /var/www/
mkdir -p /data/nextcloud-data
chown -R www-data:www-data nextcloud /data/nextcloud-data

open

安装16.0.1 with Nginx错误处理

•PHP 的安装似乎不正确,无法访问系统环境变量。getenv("PATH") 函数测试返回了一个空值。 请参照安装说明文档 ↗中的 PHP 配置说明查阅您服务器的PHP配置信息,特别是在使用 php-fpm 时。
vi /etc/php/7.2/fpm/php-fpm.conf
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp


•此服务器没有可用的互联网连接:多个节点无法访问。这意味着某些功能比如挂载外部存储,更新通知以及安装第三方应用将无法工作。远程访问文件和发送通知邮件可能也不工作。启用这台服务器上的互联网连接以享用所有功能。
  主机开启上网权限即可
•PHP 内存限制低于建议值 512MB。
vi /etc/php/7.2/fpm/php.ini
memory_limit = 1024M
•HTTP的请求头 "Strict-Transport-Security" 未设置为至少 "15552000" 秒。为了提高安全性,建议参照security tips ↗中的说明启用HSTS。
vi /etc/nginx/sites-enabled/nextcloud  remove #
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";


•    内存缓存未配置,为了提升使用体验,请尽量配置内存缓存。更多信息请参见文档。
vi /var/www/nextcloud/config/config.php加入以下参数。
   'memcache.local' => '\OC\Memcache\APCu',
   'filelocking.enabled' => true,
   'memcache.locking' => '\OC\Memcache\redis',
   'redis' => [
           'host' => 'localhost',
           'port' => 6379,
           'timeout' => 3,
             ],

 

 


Memory caching
FYI:
https://docs.nextcloud.com/server/16/admin_manual/configuration_server/caching_configuration.html#


apt install php7.2-apcu redis-server php7.2-redis

systemctl start redis
systemctl enable redis

check status

1. systemctl status redis
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-07-01 12:42:36 UTC; 25s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
Main PID: 27127 (redis-server)
    Tasks: 4 (limit: 2276)
   Memory: 2.0M
   CGroup: /system.slice/redis-server.service
           └─27127 /usr/bin/redis-server 127.0.0.1:6379

Jul 01 12:42:36 u1904 systemd[1]: Starting Advanced key-value store...
Jul 01 12:42:36 u1904 systemd[1]: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after start: No such file or directory
Jul 01 12:42:36 u1904 systemd[1]: Started Advanced key-value store.

2. ps ax | grep redis
27127 ?        Ssl    0:00 /usr/bin/redis-server 127.0.0.1:6379
27421 pts/0    S+     0:00 grep --color=auto redis

apt install memcached php7.2-memcached

ps ax | grep memcached
27647 ?        Ssl    0:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcached.pid
28430 pts/0    R+     0:00 grep --color=auto memcached


vi /var/www/nextcloud/config/config.php

'memcache.locking' => '\OC\Memcache\Redis',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.local' => '\OC\Memcache\Redis',
    'redis' => [
      'host' => 'localhost',
      'port' => 6379,
      'timeout' => 3,


网页标题:installNextCloud16onUbuntuserver19.04
网站URL:http://cqcxhl.cn/article/jghpsp.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP