⼋、树莓派LNMP安装nextcloud云盘详细教程
⼋、树莓派安装nextcloud,部署⾃⼰的云盘
使⽤树莓派部署⼀个⾃⼰的云盘,来完成⼀些⼿机,电脑间的⽂件操作,同时,摒弃百度云盘的限速。由于是树莓派,不推荐LAMP⽅式,这⾥我们⽤LNMP⽅式。
基于LNMP安装。
先安装Nginx,php-fpm,MySQL。这些安装都⽐较简单,mysql对应是mariadb-server。
php手机版下载直接sudo apt-get install 就好。
我前⾯的⽂章⾥也有mysql 的安装,可以翻开看,下⾯详细步骤都会说到。
安装时需要注意⼀点,nextcloud要求php版本必要php7.0及以上
我这⾥⽤的是7.3。
更新并安装必要软件
更新系统并安装必要软件:
sudo apt update && sudo apt upgrade && sudo apt install -y libreoffice ffmpeg
sudo apt install -y nginx
sudo apt install -y redis
sudo apt install -y php7.3 php7.3-fpm php7.3-curl php7.3-gd php7.3-dom php7.3-iconv php7.3-openssl php-redis php-mysql php7.3-zip php7.3-bz2 php7.3 -intl php7.3-imagick
下载准备安装包⽂件
准备好了后,去
然后拷贝到树莓派上,可以使⽤FileZilla这个软件传输。
或者:
wget loud/server/releases/nextcloud-18.0.4.zip
解压并移动到/var/www/html内
unzip nextcloud-18.0.4.zip
sudo mv nextcloud /var/www/html
到对应⽬录下
cd /var/www/html
更改权限
sudo chown -R root:root nextcloud
创建data 数据⽂件夹
cd nextcloud; sudo mkdir data
更改⼦⽂件夹权限
sudo chown -R www-data:www-data data config apps
准备对应的数据库
安装mysql,并新建⼀个数据库,配置好⽤户和权限,
具体可参考我的这篇,⾥⾯有详细的mysql安装
挂接移动硬盘
接⼀个外接移动硬盘,挂载到树莓派上,具体参考我的
挂载后就可以访问硬盘,新建nextcloud⽂件夹。后⾯配置⽤得到。
配置
配置php:
编辑/etc/php/7.3/fpm/php.ini⽂件,做如下更改:
sudo nano /etc/php/7.3/fpm/php.ini
expose_php改成off
date.timezone 这⾥删掉前⾯的;号,值改成Asia/Shanghai
删掉able=1,opcache.validate_timestamps=1,validate_freq=2这三⾏前⾯的;号,将validate_freq的值改成30;
配置nginx
在/etc/nginx/sites-enabled⽬录下,创建⼀个nextcloud⽂件并编辑:
sudo nano /etc/nginx/sites-enabled/nextcloud
这⾥端⼝⾃⼰设置,
server_name ⾃⼰设置,⾃⼰的域名。
ssl不启⽤的话,就关掉。
其他的看着设置把,基本都不⽤动,这个是我已经运⾏的。
upstream php-handler {
server unix:/run/php/php7.3-fpm.sock;
}
server {
listen 80;
listen [::]:80;
server_loud;
# Path to the root of your installation
root /var/www/html/nextcloud;
ssl on;
ssl_certificate /etc/nginx/nextcloud_SSL/server.pem;
ssl_certificate_key /etc/nginx/nextcloud_SSL/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=15768000;
#(可选)添加如下header主要为了安全
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Referrer-Policy no-referrer;
#(可选)为了⽀持user_webfinger 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 = / {
allow all;
log_not_found off;
access_log off;
try_files $uri $uri/ =404;
}
#这⼉是为了⽀持⽇历和联系⼈,建议加上
location = /.well-known/carddav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
#设置上传⽂件的最⼤⼤⼩(还和php⾥的那个设置有关)
# set max upload size
client_max_body_size 512M;
fastcgi_buffers 64 128K;
send_timeout 60;
# 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$
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
location / {
rewrite ^ /index.php;
}
#安全设置,禁⽌访问部分敏感内容
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)(\/.*|)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
#fastcgi_param HTTPS on;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
# Enable pretty urls
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;" always;
#
# WARNING: Only add the preload option once you read about
# the consequences in /. 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 Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;
# Optional: Don't log access to assets
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
try_files $uri /index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
}
重启nginx:
sudo nginx -s reload
配置nextcloud
前⾯配置好后,就可以了访问了:
本地ip:192.168.1.2:8080
将出现nextcloud的设置页⾯,设置数据⽬录,这⾥就要⽤到移动硬盘:
/home/pi/mobiledisk/nextcloud
选择⽤户名和密码,以及输⼊数据库⽤户名和密码,完成设置。
这⾥如果报错⽂件权限问题;
可以打开配置⽂件,并修改配置:
sudo nano /var/www/html/nextcloud/config/config.php
'check_data_directory_permissions' => false,
配置 redis
sudo nano /var/www/html/nextcloud/config/config.php
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
],
配置APPs
去官⽹下载需要的app,对应⾃⼰的版本,
下载后,解压并上传到/var/www/html/nextcloud/apps下。就可以在设置⾥使⽤了。
部署Collabora Office
使⽤docker安装,由于不⽀持arm-32架构,这⾥就不详细叙述了。
docker运⾏
docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=docs\\.thingslink\\.top' -e "username=admin" -e "password=123456" --restart always --cap-add MKNOD  collabora/code

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。