NanoPI NEO2上Seafile源码安装详细步骤,可用版

转载自:http://www.arm9home.net/read.php?tid-273164.html

衷心感谢原创人的心血!

  实际官网及论坛的几种方法均可用,只是不是这里少了几个包就是那里少运行了几条命令。经过几天的反反复复编译安装,目前找到最合适的方法。于是写一个教程,详细记录配置过程,主要为留存,方便以后查找。基于nanopi-neo2_ubuntu-core-xenial_4.11.2_20170630.img版本上安装Seafile。

一、    修改用户名密码
passwd #按提示输入
passwd pi #按提示输入

二、    修改IP地址(该版本改用了NetworkManager管理网络,害的我搞了半天才配起IP,先配IP免得后面设置seafile服务器地址麻烦)
sudo nmcli connection modify ‘Wired connection 1’ connection.autoconnect yes ipv4.method manual ipv4.address 192.168.1.5/24 ipv4.gateway 192.168.1.1 ipv4.dns 114.114.114.114
sudo reboot

三、    编译seafile源码并安装
①更新系统
apt-get update -y
apt-get upgrade -y

②安装相关开发包等(由于原作者的环境不一样,有些没有安,但是不安后面就会出现一些列问题,还不找找原因)
apt-get install -y libevent-dev libcurl4-openssl-dev libglib2.0-dev uuid-dev intltool libsqlite3-dev libmysqlclient-dev libarchive-dev libtool libjansson-dev valac libfuse-dev libssl-dev python-pip cmake sqlite3

③安装python插件(也是由于环境原因,request就是编译一直成功,但一直Internal Server Error的主要原因,试出来了)
pip install Django==1.8
pip install pytz django-statici18n djangorestframework django_compressor django-post_office https://github.com/haiwen/django-constance/archive/bde7f7c.zip gunicorn flup chardet python-dateutil six openpyxl Pillow django-picklefield requests

④建立目录
cd /home
mkdir haiwen
cd haiwen
mkdir downloads
mkdir seafile-server
mkdir seafile-server/src

⑤必须源码编译libevhtp
cd /home/haiwen/downloads
git clone https://github.com/haiwen/libevhtp.git
cd libevhtp/
cmake -DEVHTP_DISABLE_SSL=ON -DEVHTP_BUILD_SHARED=OFF .
make
sudo make install

⑥下载解压源码
cd /home/haiwen/downloads
wget -O libsearpc.tar.gz https://github.com/haiwen/libsearpc/archive/v3.1-latest.tar.gz
wget -O ccnet-server.tar.gz https://github.com/haiwen/ccnet-server/archive/v6.1.1-server.tar.gz
wget -O seafile-server.tar.gz https://github.com/haiwen/seafile-server/archive/v6.1.1-server.tar.gz
wget -O seahub.tar.gz https://github.com/haiwen/seahub/archive/v6.1.1-server.tar.gz

cd /home/haiwen/seafile-server/src
tar xf /home/haiwen/downloads/libsearpc.tar.gz
tar xf /home/haiwen/downloads/ccnet-server.tar.gz
tar xf /home/haiwen/downloads/seafile-server.tar.gz

⑦编译源码
cd /home/haiwen/seafile-server/
tar xf /home/haiwen/downloads/seahub.tar.gz
mv seahub* seahub

cd /home/haiwen/seafile-server/src/libsearpc*
./autogen.sh
./configure
make
make install

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
cd /home/haiwen/seafile-server/src/ccnet*
./autogen.sh
./configure –without-mysql –without-postgresql
make
make install
ldconfig

export C_INCLUDE_PATH=”$C_INCLUDE_PATH:/home/haiwen/downloads/libevhtp/oniguruma:” #需要oniguruma.h源码,原作者没有设置path
cd /home/haiwen/seafile-server/src/seafile*
./autogen.sh
./configure
make
make install
ldconfig

⑧安装seafile for Raspberry Pi版(实际上按照官网的步骤,通过seafile-admin start已经可以正常运行了,但为了和官网管理方式一直,所以又安装了树莓派的发行版。也搞不懂官网几种编译方式,出来几种配置方法,实质上编译出来的东西都一样,为啥搞出几种文件夹结构,搞得头都要晕,特别是只知道用不起而不知道到底哪里出错的时候。PS:直接编译版,seahub的界面即网页是英文版,怎么都调不出中文,需要把seahub下的locale文件夹用发行版的覆盖一下就行,也是恼火的事情,哎!)
cd /home/haiwen
wget https://github.com/haiwen/seafile-rpi/releases/download/v6.1.1/seafile-server_6.1.1_stable_pi.tar.gz
tar zxf seafile-server_6.1.1_stable_pi.tar.gz
mkdir installed
mv seafile-server_* installed

⑨重要步骤,将编译的文件拷贝到Raspberry Pi的安装目录下
cd seafile-server-6.1.1
cp -f /usr/local/bin/ccnet-init seafile/bin/.
cp -f /usr/local/bin/ccnet-server seafile/bin/.
cp -f /usr/local/bin/seaf-fsck seafile/bin/.
cp -f /usr/local/bin/seaf-fuse seafile/bin/.
cp -f /usr/local/bin/seafile-controller seafile/bin/.
cp -f /usr/local/bin/seaf-migrate seafile/bin/.
cp -f /usr/local/bin/seaf-server seafile/bin/.
cp -f /usr/local/bin/seaf-server-init seafile/bin/.
cp -f /usr/local/bin/seafserv-gc seafile/bin/.

⑩按照安装说明完成系统配置
./setup-seafile.sh #按提示输入
./seafile.sh start #按提示输入
./seahub.sh start #按提示输入

成功!

如果出现如下提示:

./seahub.sh start

LANG is not set in ENV, set to en_US.UTF-8

LC_ALL is not set in ENV, set to en_US.UTF-8

可这样解决:

  1. export LANG="en_US.UTF-8"
  2. export LC_ALL="en_US.UTF-8"

四、    设置开机启动
vim /etc/init.d/seafile-server

  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides:          seafile-server
  4. # Required-Start:    $remote_fs $syslog
  5. # Required-Stop:     $remote_fs $syslog
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: Seafile server
  9. # Description:       Start Seafile server
  10. ### END INIT INFO
  11. # 请将 user 改为你的Linux用户名
  12. user=root
  13. # 请将 script_dir 改为你的 Seafile 文件安装路径
  14. seafile_dir=/home/haiwen
  15. script_path=${seafile_dir}/seafile-server-latest
  16. seafile_init_log=${seafile_dir}/logs/seafile.init.log
  17. seahub_init_log=${seafile_dir}/logs/seahub.init.log
  18. # 若使用 Nginx/Apache, 请将其设置为true, 否者为 false
  19. fastcgi=flase
  20. # fastcgi 端口, 默认为 8000.
  21. fastcgi_port=8000
  22. case “$1” in
  23.         start)
  24.                 sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
  25.                 if [  $fastcgi = true ];
  26.                 then
  27.                         sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
  28.                 else
  29.                         sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
  30.                 fi
  31.         ;;
  32.         restart)
  33.                 sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
  34.                 if [  $fastcgi = true ];
  35.                 then
  36.                         sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
  37.                 else
  38.                         sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
  39.                 fi
  40.         ;;
  41.         stop)
  42.                 sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
  43.                 sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
  44.         ;;
  45.         *)
  46.                 echo “Usage: /etc/init.d/seafile-server {start|stop|restart}”
  47.                 exit 1
  48.         ;;
  49. esac

sudo chmod +x /etc/init.d/seafile-server
sudo update-rc.d seafile-server defaults
五、使用memcached缓存技术
apt-get install python-memcache
vi /home/haiwen/conf/seahub_settings.py
添加

  1. CACHES = {
  2.     ‘default’: {
  3.         ‘BACKEND’: ‘django.core.cache.backends.memcached.MemcachedCache’,
  4.         ‘LOCATION’: ‘127.0.0.1:11211’,
  5.     }
  6. }

cd /home/haiwen/seafile-server-latest
./seahub.sh restart

六、    挂载硬盘(我只挂到了seafile-data上,这个看自己)
查看硬盘分区
fdisk -l
查看我的硬盘是/dev/sda1
挂载
mount /dev/sda1 data
永久挂载
vi /etc/fstab
添加
/dev/sda1 /home/haiwen/seafile-data ext4 defaults 1 2
保存退出验证
mount -a
如果有错,以后起不起来,neopi没有显示器,只有重来,一定注意
重新mount
mount -n -o remount,rw /
重启
reboot

七、    设置硬盘休眠,节能
安装hdparm
sudo apt-get install hdparm -y
确保你的硬盘支持hdparm,
sudo hdparm -y /dev/sda1
如果输出如下结果,就表明支持,
/dev/sda1:
issuing standby command
如果看到类似如下输出,就表明不支持,可以跳到 hd-idle 或者 sdparm,
/dev/sda2:
issuing standby command
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

检查硬盘是否支持写缓存功能,
sudo hdparm -I /dev/sda1 | grep ‘Write cache’
如果看到 * (星号),表示支持,
* Write cache
如果没有看到 * (星号),表示不支持,
Write cache

编辑配置文件,
sudo vim /etc/hdparm.conf
添加

  1. /dev/sda1 {
  2. write_cache = on
  3. spindown_time = 120
  4. }

如果不支持写缓存,去掉 write_cache = on。
重启 hdparm 服务,
sudo service hdparm restart

八、    安装防火墙并开启相应端口

apt-get install ufw -y
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 8000
sudo ufw allow 8082
sudo ufw allow 6060/tcp
sudo ufw allow 6060/udp
sudo ufw enable

九、    安装花生壳

首先安装g++
sudo apt-get install g++
wget http://download.oray.com/peanuthull/phddns-2.0.2.16556.tar.gz
tar zxvf phddns-2.0.2.16556.tar.gz
cd phddns-2.0.2.16556/
./configure
make
cd src
sudo ./phddns
cp phddns /usr/bin/
vi /etc/rc.local
添加

  1. /usr/bin/phddns -c /etc/phlinux.conf -d

⑩全九美,全部搞定。reboot!

Add a Comment

电子邮件地址不会被公开。 必填项已用*标注