2019独角兽企业重金招聘Python工程师标准>>>

方案前文:建立一个家庭私有云盘方案系列教程+N2n+Nextcloud

前一篇:家庭私有云盘系列教程-建立公网服务器实现外网访问

在安装NextCloud之前,我们需要将物理硬盘挂载到linux上,供使Nextcloud存储数据。如果是物理机是linux,会更方便一些。

挂载物理磁盘

新硬盘直接进行分区挂载就行,这里对已经在window上分区过,甚至已经有文件的物理硬盘进行挂载说明。

查看硬盘号顺序。

使用cmd运行命令> Diskpart

接着输入 List disk

如图所示,如果我们挂载第一块硬盘,即是磁盘0。

这里的状态是脱机的,如果是联机的,需要将其更改为脱机,只允许一个系统将其挂载读写,那即是nas-linux。

更改硬盘为脱机状态后,windows物理机将无法访问到磁盘。

这里示例更改方法,恢复一样,右键将其更改为 联机 即可。需要在centos上将其卸载掉,否则会产生冲突。

VMware添加一块物理磁盘映射

虚拟机右键设置

选择第三个,使用物理磁盘。

这里的设备即是刚才cmd列出来的顺序,莫要搞错。而且一定要是脱机状态,否则这里会报占用错误。

单选项,1.使用整块硬盘,2.使用单个分区。选择第二项,单个分区。

勾选自己的分区,如果只有一个分区,那就勾选一个,然后继续下一步。

完成后,单击OK保存退出。

Centos进行挂载分区

查看磁盘情况

fdisk -l

由此看到,我们这块硬盘有两块硬盘,一块128M的小分区(Microsoft Reserved Partition),剩下的才是我们的主要数据分区。这是因为我们是在windows上使用GPT模式分区硬盘产生的。

这里也看不清具体的分区格式,需要使用parted -l 查看,遇到提示,输入OK回车即可。

这里可以清楚地看到两个分区,第一个是没有文件系统类别的,而第二个是ntfs。我们只需要挂载第二个即可,第一个挂载不上去。

编号1即 /dev/sda1

编号2即 /dev/sda2

安装ntfs-3g

折腾了半夜,没有将ntfs-3g编译安装成功,最终放弃,选择了yum方式安装。简单干脆。

#增加阿里云epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo#安装
yum install -y ntfs-3g

继续挂载硬盘

mount -t ntfs -o iocharset=cp936 /dev/sda2 /mnt/hd1

为避免windows上文件名乱码,这里指定磁盘字符,-o iocharset=cp936

注意:cp936是指简体中文,cp950是指繁体中文。

卸载分区

umount /dev/sda2

自动挂载分区

vi /etc/fstab
#追加内容
/dev/sda2 /mnt/hd1      ntfs    defaults,iocharset=cp936,rw   0 0

除此之外,自动挂载可以通过开机启动脚本实现。

在 /etc/rc.d/rc.local 文件尾部增加挂载分区mount命令即可。

安装Nextcloud

安装部署环境,PHP、Mariadb、Nginx

编译安装PHP

yum install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-develmkdir /usr/local/php/
cd /usr/local/php/wget http://cn2.php.net/distributions/php-7.2.2.tar.gz -O php-7.2.2.tar.gz
tar -xzf php-7.2.2.tar.gz -C ./
cd php-7.2.2
./configure --prefix=/usr/local/php/php7.2.2/\--with-config-file-path=/usr/local/php/php7.2.2/\--with-libdir=lib64\--enable-fpm\--with-fpm-user=php-fpm\--with-fpm-group=www\--enable-mysqlnd\--with-mysql=mysqlnd\--with-mysqli=mysqlnd\--with-pdo-mysql=mysqlnd\--enable-opcache\--enable-pcntl\--enable-mbstring\--enable-soap\--enable-zip\--enable-calendar\--enable-bcmath\--enable-exif\--enable-ftp\--enable-intl\--with-openssl\--with-zlib\--with-curl\--with-gd\--with-zlib-dir=/usr/lib\--with-png-dir=/usr/lib\--with-jpeg-dir=/usr/lib\--with-gettext\--with-mhash\--with-ldapmake && make install

创建配置文件

cd /usr/local/php/php-7.2.2/
cp php.ini-development /usr/local/php/php7.2.2/php.ini
cp /usr/local/php/php7.2.2/etc/php-fpm.conf.default /usr/local/php/php7.2.2/etc/php-fpm.conf#复制php-fpm管理器脚本
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmvi /usr/local/php/php7.2.2/php.ini#修改
cgi.fix_pathinfo=0cd /usr/local/php/php7.2.2/etc/php-fpm.d
cp www.conf.default www.conf

关闭selinux

vi /etc/selinux/config#将SELINUX=enforcing改为SELINUX=disabled,保存后退出
SELINUX=disabled#执行生效
getenforce

通过php-fpm脚本,启动php服务(停止、重启、重载)。

service php-fpm start
service php-fpm restart
service php-fpm stop
service php-fpm reload

创建网站目录

#创建网站目录及网站产生的日志存放目录
mkdir /mnt/web/cloud/wwwroot -p
mkdir /mnt/web/cloud/log -p#创建nginx加载的虚拟主机配置存放目录
mkdir /usr/local/nginx/vhost#创建默认文件
echo "<?php phpinfo();?>" > /mnt/web/cloud/wwwroot/index.php
echo "hi example.com" > /mnt/web/cloud/wwwroot/index.html#设置权限
chown -R php-fpm:www /mnt/web
chmod -R 775 /mnt/web

配置Nginx

此前nginx已经安装了, 这里只需要配置下即可。

vi /usr/local/nginx/nginx.conf

在 http  段尾部增加

include /usr/local/nginx/vhost/*.conf;

新增一个虚拟主机配置

vi /usr/local/nginx/vhost/cloud.conf

以下内容摘自官方文档部门,为HTTP访问。为避免HTTPS测试麻烦,如果后期需要部署HTTPS,参照官方配置即可。另外,配置HTTPS需要在公网入口配置,这台机器可以保持当前配置。

查看官方Nginx部署配置,点击这里。

upstream php-handler {server 127.0.0.1:9000;#server unix:/var/run/php5-fpm.sock;
}log_format cloud.log.format '$remote_addr - $remote_user [$time_local] $request''$status $body_bytes_sent $http_referer ''$http_user_agent $http_x_forwarded_for';
server {listen       80;server_name cloud.cn.n2n.ee;index index.html index.htm index.php;root  /mnt/web/cloud/wwwroot;# 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;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 sizeclient_max_body_size 512M;fastcgi_buffers 64 4K;# Enable gzip but do not remove ETag headersgzip 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$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;#Avoid sending the security headers twicefastcgi_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;}# Adding the cache control header for js and css files# Make sure it is BELOW the PHP blocklocation ~ \.(?:css|js|woff|svg|gif)$ {try_files $uri /index.php$uri$is_args$args;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;# Optional: Don't log access to assetsaccess_log off;}location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {try_files $uri /index.php$uri$is_args$args;# Optional: Don't log access to other assetsaccess_log off;}access_log  /mnt/web/cloud/log/access.log cloud.log.format;error_log  /mnt/web/cloud/log/error.log;
}

运行nginx

/usr/local/nginx/nginx

尝试访问,http://公网IP:10252/index.php,成功即可!

安装Mariadb

避免麻烦,直接使用yum安装,并启动设置自动运行。

yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb

初始化数据库

>mysql_secure_installationSet root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..... Success!Remove anonymous users? [Y/n] y... Success!Remove test database and access to it? [Y/n] y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reload privilege tables now? [Y/n] y... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!

开放root远程权限,方便操作,不需要的可以忽略。

mysql -u root -pMariaDB [mysql]> update mysql.user set host='%' where user='root' and host='localhost';
MariaDB [mysql]> flush privileges;

为NextCloud创建一个用户名及所属数据库。

CREATE DATABASE IF NOT EXISTS db_cloud DEFAULT CHARSET utf8 COLLATE utf8_bin;CREATE USER 'user_cloud'@'%' IDENTIFIED BY 'vuu01z4ztsdl0rmu';GRANT SELECT, INSERT, UPDATE, REFERENCES, DELETE, CREATE, DROP, ALTER, INDEX, TRIGGER, CREATE VIEW, SHOW VIEW, EXECUTE, ALTER ROUTINE, CREATE ROUTINE, CREATE TEMPORARY TABLES, LOCK TABLES, EVENT ON `db\_cloud`.* TO 'user_cloud'@'%';GRANT GRANT OPTION ON `db\_cloud`.* TO 'user_cloud'@'%';

安装NextCloud

获取最新 nextcloud

https://download.nextcloud.com/server/releases/

下载并解压到网站目录

cd /mnt/web/cloud/wwwroot/
wget https://download.nextcloud.com/server/releases/nextcloud-13.0.0.tar.bz2
tar -xjf nextcloud-13.0.0.tar.bz2rm -f index.html
rm -f index.php
mv  nextcloud/* ./
rm -rf nextcloudchown -R php-fpm:www /mnt/web
chmod -R 775 /mnt/web

至此,nextcloud基本就能使用了,至于后台的提醒错误,可以参照错误后面的链接去解决。

nextcloud项目的优化配置也可以参照官方的文档。

nextcloud外部存储

作为一个扩展插件,可以在后台应用中 搜索 External storage support,然后启用即可。

目录名称即是在文件管理界面展示的目录名,配置即是linux的目录路径,设置完毕后,保存即可。

另外设置下目录的权限,就可以正常使用了。

chown -R php-fpm:www /mnt/hd1
chmod -R 775 /mnt/hd1

(完)

转载于:https://my.oschina.net/u/2366984/blog/1622334

家庭私有云盘系列教程-安装使用NextCloud个人云存储系统相关推荐

  1. 个人家用nas_家庭私有云盘系列教程-本地搭建家庭NAS方案

    目前第三方云盘存在速度慢.限制多.取回难.费用高等各方面问题,这里进行本地搭建NAS方案,配置个人私有云盘前置基础,存储个人大量数据及共享分享给朋友使用. 硬件选配 这里不做多余阐述,参见知乎大佬答案 ...

  2. [折腾日记]NextCloud 私人云盘部署教程

    NextCloud 私人云盘部署教程 你是否还在使用微信来分享文件?微信虽然可以传输文件,却无法帮你存储文件,更无法整理你的诸多文件.一个月以前发给某个同事的文件,你要找很久才找到,而且可能会发现&q ...

  3. linux免费私人云盘软件,私人云盘搭建教程 如何自己搭建云盘

    私人云盘搭建教程使用的是Linux的CentOS 6系统,首先登录ssh安装宝塔,根据购买的账号密码登录ssh. 然后安装宝塔面板,宝塔面板类似于虚拟主机,直接绑定域名上传就可以使用了.好处在于一个服 ...

  4. 微软云盘配合服务器,『原创』开源5T微软云盘搭建教程onedrive index

    前言 为什么搭建一个微软共享云盘?百度云.蓝奏云不好吗?百度云有会员限制功能,各种限制更是不少,蓝奏云速度超快,但是貌似不支持大文件.微软毕竟是大厂,可用的5T教育邮箱现在也很好搞到,之所以采用是因为 ...

  5. python云盘搭建教程_超简单!基于Python搭建个人“云盘”,目前最好用的个人云盘...

    超简单!基于Python搭建个人"云盘",目前最好用的个人云盘 1. 简介 当我们想要从本地向云服务器上传文件时,比较常用的有pscp等工具,但避免不了每次上传都要写若干重复的代码 ...

  6. 网络云盘系列初步介绍

    网络云盘系列初步介绍 鉴于小伙伴们对网盘的好奇,加上自己对网盘的一些总结,做了一个简报! 主要是针对百度云盘,腾讯云盘,360云盘,新浪云盘,163网盘,115网盘的介绍. 不足之处,还望欢迎大家指出 ...

  7. 阿里云IOT入门教程(三)阿里云IOT Studio自建手机App控制Wemos D1 Mini( ESP8266 )板载灯亮灭

    阿里云IOT入门教程(一)阿里云IOT Studio自建手机App控制Wemos D1 Mini( ESP8266 )板载灯亮灭 概述 所需材料 Mqtt预备知识 hacklab端开发 * 硬件端上报 ...

  8. 云盘哪个好?请问国内哪个云盘比较好?

    云盘哪个好?请问国内哪个云盘比较好? 云盘哪个好?请问国内哪个云盘比较好?随着互联网的发展越来越强大,很多的人都开始使用互联网络来办公,越来越多的人开始注重文件的安全了,那么有什么更好的方法来保护我们 ...

  9. AIR724 4G模块云平台接入教程(2)- 阿里云物联网平台

    AIR724 4G模块云平台接入教程(2)- 阿里云物联网平台 Aliyun IOT 设备配置和接入 自动注册 一型一密 一机一密 消息通信 通信主题 通信流程 使用实战 属性上报 异步服务调用 同步 ...

最新文章

  1. pandas基于dataframe字符串数据列包含(contains)特定字符串来筛选dataframe中的数据行(rows where values contain substring)
  2. SQL中的in与not in、exists与not exists的区别以及性能分析
  3. win32com python_python模块:win32com用法详解
  4. MVC设计模式深入理解
  5. cocos2d-x初探学习笔记(7)--CCProgressTimer
  6. 通过异常捕获判断字符串是不是数字格式
  7. maven profile实现多环境构建 (单项目多套配置)
  8. jQuery对Ajax的封装应用(三)
  9. kubernetes1.9管中窥豹-CRD概念、使用场景及实例
  10. python的应用领域和常用函数模块有哪些_Python模块导入区别与常用函数案例
  11. angular 字符串转换成数字_3种方法搞定Excel中数字大小写转换? 123...变为壹贰叁......
  12. DRBD安装配置、工作原理及故障恢复
  13. 操作系统文件管理_计算机民科笔记-操作系统week1
  14. 每日学习笔记(17)
  15. QQ产品界面变更之路
  16. Inpaint破解版 - 图片去水印神器
  17. LFS 11.1 arm64 meson编译失败,libffi路径错误
  18. ping 不通百度问题的解决
  19. 【Halcon视觉】中心线提取
  20. 奇想大白话之《羊了个羊》为何火,技术很厉害吗?

热门文章

  1. MySQL——约束(constraint)详解
  2. C# 获取本机连接的所有 串口设备名称 与 串口号
  3. 实时系统vxWorks - 虚拟机环境搭建
  4. 小小的登陆包括哪些测试点
  5. 线性调频Z变换 CZT
  6. JAVA中简单的MD5算法——MD5Utils
  7. 长期跑步需要买个运动耳机吗、最好用的5款跑步耳机推荐
  8. XTU,C语言,连分数
  9. 阿里巴巴Java开发命名规范
  10. 给大家推荐10个适合大学生的学习网站(所有专业都可)-冲冲冲!