实际官网及论坛的几种方法均可用,只是不是这里少了几个包就是那里少运行了几条命令。经过几天的反反复复编译安装,目前找到最合适的方法。于是写一个教程,详细记录配置过程,主要为留存,方便以后查找。基于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=OFF -DEVHTP_BUILD_SHARED=ON .
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.gzcd /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* seahubcd /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 #按提示输入
成功!
四、 设置开机启动vim /etc/init.d/seafile-server复制代码- #!/bin/bash
- ### BEGIN INIT INFO
- # Provides: seafile-server
- # Required-Start: $remote_fs $syslog
- # Required-Stop: $remote_fs $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Seafile server
- # Description: Start Seafile server
- ### END INIT INFO
- # 请将 user 改为你的Linux用户名
- user=root
- # 请将 script_dir 改为你的 Seafile 文件安装路径
- seafile_dir=/home/haiwen
- script_path=${seafile_dir}/seafile-server-latest
- seafile_init_log=${seafile_dir}/logs/seafile.init.log
- seahub_init_log=${seafile_dir}/logs/seahub.init.log
- # 若使用 Nginx/Apache, 请将其设置为true, 否者为 false
- fastcgi=flase
- # fastcgi 端口, 默认为 8000.
- fastcgi_port=8000
- case "$1" in
- start)
- sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
- if [ $fastcgi = true ];
- then
- sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
- else
- sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
- fi
- ;;
- restart)
- sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
- if [ $fastcgi = true ];
- then
- sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
- else
- sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
- fi
- ;;
- stop)
- sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
- sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
- ;;
- *)
- echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
- exit 1
- ;;
- 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添加
复制代码- CACHES = {
- 'default': {
- 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
- 'LOCATION': '127.0.0.1:11211',
- }
- }
|
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添加
复制代码- /dev/sda1 {
- write_cache = on
- spindown_time = 120
- }
|
如果不支持写缓存,去掉 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 添加
复制代码- /usr/bin/phddns -c /etc/phlinux.conf -d
|
⑩全九美,全部搞定。reboot!