/etc/apt/sources.listvi /etc/apt/source..."/>
您好,登錄后才能下訂單哦!
install NextCloud 16 on Ubuntu 19.04
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錯(cuò)誤處理
?PHP 的安裝似乎不正確,無(wú)法訪問(wèn)系統(tǒng)環(huán)境變量。getenv("PATH") 函數(shù)測(cè)試返回了一個(gè)空值。 請(qǐng)參照安裝說(shuō)明文檔 ↗中的 PHP 配置說(shuō)明查閱您服務(wù)器的PHP配置信息,特別是在使用 php-fpm 時(shí)。
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
?此服務(wù)器沒(méi)有可用的互聯(lián)網(wǎng)連接:多個(gè)節(jié)點(diǎn)無(wú)法訪問(wèn)。這意味著某些功能比如掛載外部存儲(chǔ),更新通知以及安裝第三方應(yīng)用將無(wú)法工作。遠(yuǎn)程訪問(wèn)文件和發(fā)送通知郵件可能也不工作。啟用這臺(tái)服務(wù)器上的互聯(lián)網(wǎng)連接以享用所有功能。
? 主機(jī)開(kāi)啟上網(wǎng)權(quán)限即可
?PHP 內(nèi)存限制低于建議值 512MB。
vi /etc/php/7.2/fpm/php.ini
memory_limit = 1024M
?HTTP的請(qǐng)求頭 "Strict-Transport-Security" 未設(shè)置為至少 "15552000" 秒。為了提高安全性,建議參照security tips ↗中的說(shuō)明啟用HSTS。
vi /etc/nginx/sites-enabled/nextcloud? remove #
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
???? 內(nèi)存緩存未配置,為了提升使用體驗(yàn),請(qǐng)盡量配置內(nèi)存緩存。更多信息請(qǐng)參見(jiàn)文檔。
vi /var/www/nextcloud/config/config.php加入以下參數(shù)。
?? '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,
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。