最近私有云比较火,因为政策原因已经关闭了很多家。不如搭建个自己的私有云平台,正好有多余的硬盘,可以用树莓派打造一个廉价而且低能耗的NAS。
1. 硬件清单
- 树莓派 X 1 (本文使用的是2代,如果购买推荐买3代)
- USB电源 X 1 (树莓派USB供电)
- 网线 or USB无线网卡 X 1
- SD卡 X 1 (用来装系统)
- 读卡器 X 1
- 机械硬盘 (电脑拆下的,推荐固态硬盘)
2. 树莓派安装配置
2.1. 系统下载
推荐系统下载:RASPBIAN JESSIE LITE
其他系统:点击查看
百度安装教程:点击查看
制作步骤
- 解压出压缩包,会出现img文件
- 插入SD读卡器
- 格式化SD卡
- 用专门的工具将映像文件写入到SD卡。
默认账号: pi 密码:raspberry
具体的请大家自行百度。
2.2. 系统配置
wifi连接:为了方便移动可以通过wifi进行上网
1 |
<span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">1.</span>lsusb <span class="hljs-preprocessor" style="line-height: 1.6;"># 查看USB是否识别硬件</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">2.</span>ifconfig <span class="hljs-preprocessor" style="line-height: 1.6;"># 查看wlan0信息</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">3.</span>vi /etc/network/interfaces <span class="hljs-preprocessor" style="line-height: 1.6;"># 修改wifi配置信息</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">4.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">5.</span><span class="hljs-keyword" style="line-height: 1.6; color: #f92672;">auto</span> lo <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">6.</span>iface lo inet loopback <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">7.</span>iface eth0 inet dhcp <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">8.</span>allow-hotplug wlan0 <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">9.</span>iface wlan0 inet <span class="hljs-keyword" style="line-height: 1.6; color: #f92672;">static</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">10.</span>wpa-ssid wifi-name <span class="hljs-preprocessor" style="line-height: 1.6;"># 你要连接的wifi ssid</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">11.</span>wpa-psk password <span class="hljs-preprocessor" style="line-height: 1.6;"># 你的wpa连接密码 </span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">12.</span>address <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">192.168</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.1</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.110</span> <span class="hljs-preprocessor" style="line-height: 1.6;"># 设定的静态IP地址</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">13.</span>netmask <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">255.255</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.255</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.0</span> <span class="hljs-preprocessor" style="line-height: 1.6;"># 网络掩码</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">14.</span>gateway <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">192.168</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.1</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.1</span> <span class="hljs-preprocessor" style="line-height: 1.6;"># 网关</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">15.</span>network <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">192.168</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.1</span><span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">.1</span> <span class="hljs-preprocessor" style="line-height: 1.6;"># 网络地址</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">16.</span>iface <span class="hljs-keyword" style="line-height: 1.6; color: #f92672;">default</span> inet dhcp <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">17.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">18.</span><span class="hljs-preprocessor" style="line-height: 1.6;"># 保存后,请重启树莓派</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">19.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">20.</span>sudo reboot |
连上网后请输入以下命令
更新系统: sudo apt-get update && sudo apt-get upgrade
树莓派添加USB外接硬盘
1、显示系统的硬盘设备以及分区
1 |
<span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">1.</span>sudo fdisk -l # 显示设备名,例如<span class="hljs-regexp" style="line-height: 1.6; color: #ae81ff;">/dev/</span>sda1 |
2、树莓派默认不支持NTFS文件系统,如果需要支持则要安装相应的软件包
1 |
<span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">1.</span>sudo apt-<span class="hljs-keyword" style="line-height: 1.6; color: #f92672;">get</span> install ntfs-<span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">3</span>g <span class="hljs-comment" style="line-height: 1.6; color: #75715e;"># 安装支持NTFS文件系统的软件包</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">2.</span>sudo reboot <span class="hljs-comment" style="line-height: 1.6; color: #75715e;"># 重新启动后才有效</span> |
3、在树莓派上建立挂载点
1 |
<span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">1.</span>sudo mkdir /media/usbhdd <span class="hljs-comment" style="line-height: 1.6; color: #75715e;"># 建立挂载目录</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">2.</span>sudo chown <span class="hljs-constant" style="line-height: 1.6; color: #66d9ef;">pi</span>:<span class="hljs-constant" style="line-height: 1.6; color: #66d9ef;">pi</span> /media/usbhdd <span class="hljs-comment" style="line-height: 1.6; color: #75715e;"># 设置目录的所有人和所有组</span> |
4、挂载/dev/sda1设备硬盘
1 |
<span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">1.</span>sudo mount -t auto -o uid=<span class="hljs-constant" style="line-height: 1.6; color: #66d9ef;">pi</span>,gid=<span class="hljs-constant" style="line-height: 1.6; color: #66d9ef;">pi</span> /dev/sda1 /media/usbhdd |
5、卸载
1 |
<span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">1.</span>sudo umount <span class="hljs-regexp" style="line-height: 1.6; color: #ae81ff;">/media/u</span>sbhdd |
6、实现开机自动挂接
1 |
<span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">1.</span><span class="hljs-preprocessor" style="line-height: 1.6;">#修改/etc/fstab文件,增加如下的内容</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">2.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">3.</span>/dev/sda1 /media/usbhdd vfat rw,defaults <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">0</span> <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">0</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">4.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">5.</span><span class="hljs-preprocessor" style="line-height: 1.6;"># 存盘后,重新启动。</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">6.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">7.</span><span class="hljs-preprocessor" style="line-height: 1.6;"># 也可以使用硬盘的UUID的值表示硬盘设备</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">8.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">9.</span><span class="hljs-preprocessor" style="line-height: 1.6;"># 获取硬盘的UUID值 </span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">10.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">11.</span> sudo blkid <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">12.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">13.</span><span class="hljs-preprocessor" style="line-height: 1.6;"># 在/etc/fstab文件中,添加如下内容:</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">14.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">15.</span>UUID=<span class="hljs-string" style="line-height: 1.6; color: #e6db74;">"1599-28FA"</span> /media/usbhdd <span class="hljs-keyword" style="line-height: 1.6; color: #f92672;">auto</span> rw,defaults <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">0</span> <span class="hljs-number" style="line-height: 1.6; color: #ae81ff;">0</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">16.</span> <span class="hljs-comment line-number" style="line-height: 1.6; color: #75715e;">17.</span>sudo reboot |
3. 私有云配置
3.1. PHP环境配置
推荐lnmp: 安装说明
3.2. 安装私有云
先通过lnmp创建站点,在把压缩包里的文件复制到站点根目录下安装即可。
功能很棒,支持PC ,IOS , Android 而且可以自动同步。
如果想对外访问,去路由器开启端口转发 or DMZ 即可
最新评论
老铁,来我这里吧,教你编程,让你不再迷茫
噢,这活动还有吗,这么划算
大神年薪7位数了吧………羡慕呀
请问大佬用的是啥主题、、、
有源码吗,老哥
哈哈,可以友链
为什么要把headers做成类属性啊。然后还要写一个类方法,而不是实例方法。望大大解释。
老哥,我迷茫困顿,专业是工商管理,但是从没有学过,我现在想学计算机,但是从没有完整学过,现在是什么都不会,只是晚上熬夜看黄片,打飞机。迷茫,困顿,老哥,你是怎么度过21岁的青春岁月的。
好文,学习学习外挂
人脸识别技术。厉害博主。。。我也学习一下