seafile搭建 2020-02-20 程序之旅,记录 暂无评论 1239 次阅读 ## seafile搭建 > 此次目的就是搭建私有云,由于之前搭建的nextcloud太过于庞大,小小的树莓派无法支撑nextcloud这艘巨轮,所以这次是换个轻量的云平台`seafile`,废话不多说,直接上教程 [TOC] ### 准备条件 - 树莓派 3B+ 250+ - 移动硬盘 2T 470+ - 笔记本一台 - 路由器一台 ### 搭建过程 #### 准备环境 ##### 安装系统 在官网中下载树莓派系统镜像`Raspbian Buster Lite`,使用`Win32DiskImager`烧入SD卡 [镜像地址](https://www.raspberrypi.org/downloads/raspbian/) ![image-20200219230601875.png](https://mufeng-blog.oss-cn-beijing.aliyuncs.com/typecho/2020/02/20/58256342206404/image-20200219230601875.png) 在boot盘中创建空`ssh`文件和` wpa_supplicant.conf ` ```config country=CN ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="Danke_1504" psk="wifi.danke.life" key_mgmt=WPA-PSK priority=1 } ``` ##### 配置环境 树莓派上电后,笔记本与树莓派连接到同一路由器或同一网段。win使用以下命令获取树莓派ip地址 ``` $ arp -a ``` ![image-20200219225924535.png](https://mufeng-blog.oss-cn-beijing.aliyuncs.com/typecho/2020/02/20/582554141874215/image-20200219225924535.png) > 一般树莓派的mac地址是b开头,我这里是有两个树莓派 初始化用户名和密码分别是pi和raspberry,使用ssh工具登录,之后是换源,有需要的同志可以考虑一下,不是必须的 ```shell $ nano /etc/apt/sources.list deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi $ nano /etc/apt/sources.list.d/raspi.list deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ buster main ui $ apt-get update ``` ##### 挂载移动硬盘 这里需要注意的是,刚买回来的移动硬盘是exfat格式,linux无法正常使用,需要借助其他工具来进行挂载,我这里图方便,所以索性格式化为ext4,这里使用绿色版的 DiskGenius ```sh $ sudo su # 查看移动硬盘格式 $ df -T $ sudo fdisk -l # 挂载硬盘 $ mkdir /data/wd $ mount /dev/sda /data/wd # 卸载硬盘 $ umount /data/wd # 开机自动挂载 $ blkid /dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="5203-DB74" TYPE="vfat" PARTUUID="6c586e13-01" /dev/mmcblk0p2: LABEL="rootfs" UUID="2ab3f8e1-7dc6-43f5-b0db-dd5759d51d4e" TYPE="ext4" PARTUUID="6c586e13-02" /dev/sda: UUID="f69f23ac-8617-4825-b8e5-9abc1da1e648" TYPE="ext4" /dev/mmcblk0: PTUUID="6c586e13" PTTYPE="dos" $ nano /etc/fstab UUID=f69f23ac-8617-4825-b8e5-9abc1da1e648 /data/wd ext4 defaults 0 0 ``` #### 开始安装 安装`seafile`所需要的工具和依赖 ```shell $ apt-get install libpython2.7 python-setuptools python-pil python-ldap python-urllib3 sqlite3 python-requests python-mysqldb mariadb-server -y $ mysql > use mysql; > UPDATE user SET password=password('password') WHERE user='root'; > flush privileges; > exit ``` 到`github`中获取专有的seafile压缩包,我这里下载的是最新 7.0.5,下载完之后,解压安装 [github地址](https://github.com/haiwen/seafile-rpi/releases) > 打不开github的小伙伴请自行想办法 ```shell $ mkdir /home/pi/seafile $ cp /home/pi/seafile-server_7.0.5_stable_pi.tar.gz /home/pi/seafile $ cd /home/pi/seafile $ tar -zxf seafile-server_7.0.5_stable_pi.tar.gz $ cd /seafile-server-7.0.5 ``` 这里需要注意一下,进入到目录后,会发现有两个安装脚本`setup-seafile.sh`和`setup-seafile-mysql.sh`,这里,也就是seafile提供了两个安装方法,一个是不需要数据库安装,另一个需要数据库安装。我这里选择的是数据库配置安装方法。 ```shell $ ./setup-seafile-mysql.sh What is the name of the server? It will be displayed on the client. 3 - 15 letters or digits [ server name ] seafile What is the ip or domain of the server? For example: www.mycompany.com, 192.168.1.101 [ This server's ip or domain ] 192.168.124.37 Where do you want to put your seafile data? Please use a volume with enough free space [ default "/home/pi/seafile/seafile-data" ] /data/wd/seafile [ default "/home/pi/seafile/seafile-data" ] /data/wd/seafile Which port do you want to use for the seafile fileserver? [ default "8082" ] ------------------------------------------------------- Please choose a way to initialize seafile databases: ------------------------------------------------------- [1] Create new ccnet/seafile/seahub databases [2] Use existing ccnet/seafile/seahub databases [ 1 or 2 ] 1 .... # 之后一直回车 port of seafile fileserver: 8082 port of seahub: 8000 When problems occur, Refer to https://github.com/haiwen/seafile/wiki for information. $ cd /home/pi/seafile/conf/ $ nano gunicorn.conf # 修改授权访问地址 bind = "0.0.0.0:8000" $ cd /home/pi/seafile/seafile-server-7.0.5/ $ ./seafile.sh start $ ./seahub.sh start # 按提示输入管理员邮箱和密码 # 如果需要管理端口的可以安装ufw工具 $ apt-get install ufw ``` ### 补充 #### 外网访问 由于我的是电信动态ip,自己也有个域名,这里使用了aliyun ddns,与光猫中设置端口映射到路由器中,路由器又DMZ虚拟主机映射,实现了可以通过外网来访内网seafile服务。 ![ddns.png](https://mufeng-blog.oss-cn-beijing.aliyuncs.com/typecho/2020/02/20/582533615389411/ddns.png) #### 自启动 ``` $ sudo su $ nano /etc/systemd/system/seafile.service [Unit] Description=Seafile After=network.target [Service] Type=oneshot ExecStart=/home/pi/seafile/seafile-server-latest/seafile.sh start ExecStop=/home/pi/seafile/seafile-server-latest/seafile.sh stop RemainAfterExit=yes [Install] WantedBy=multi-user.target $ nano /etc/systemd/system/seahub.service [Unit] Description=Seafile hub After=network.target seafile.service [Service] ExecStart=/home/pi/seafile/seafile-server-latest/seahub.sh start ExecStop=/home/pi/seafile/seafile-server-latest/seahub.sh stop Type=oneshot RemainAfterExit=yes [Install] WantedBy=multi-user.target $ sudo systemctl enable seafile.service $ sudo systemctl enable seahub.service ``` -------- ### 2020年3月12日 - 修改源 ``` $ nano /etc/apt/sources.list deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi $ nano /etc/apt/sources.list.d/raspi.list deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi $ apt-get update ``` - 查看当前树莓派的温度 ``` /opt/vc/bin/vcgencmd measure_temp ``` 打赏: 微信, 支付宝 标签: 树莓派, seafile, 电脑应用 本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。