环境:Ubuntu18.04、Samba、Apache2.4、MySQL5.7

参考资料:https://cloud.seafile.com/published/seafile-manual-cn/deploy/using_mysql.md

# 更新源
sudo apt update && upgrade

# 安装必备软件包
sudo apt install -y python-dev libpython2.7 python-pip python-setuptools python-pil python-mysqldb python-ldap python-urllib3 python-memcache ffmpeg

# 如果提示安装失败,可尝试重新执行

# 新建文件夹名字自定义,案例中使用‘haiwen'这个名称,用来放置Seafile
# 假如放在当前用户下 '/home/demo/haiwen'

# 通过samba共享文件夹share,上传安装包到share

# 由于pipy下载不稳定,我预先下载了部分组件:pillow、numpy、moviepy-1.0.1

# 手动安装离线包
sudo -H pip install Pillow-6.2.0-cp27-cp27mu-manylinux1_x86_64.whl
sudo -H pip install numpy-1.16.5-cp27-cp27mu-manylinux1_x86_64.whl
demo@ubuntu:~/share/moviepy-1.0.1$ sudo python setup.py install

# 启用Apache反向代理模块
sudo a2enmod rewrite proxy_http

# 将Seafile安装包复制到/home/demo/haiwen下
# 新建'installed'文件夹,解压seafile安装包,解压完毕后将压缩包移动到’installed‘文件夹里。

# 进入seafile文件夹
# cd ./seafile-server-lastest

# 配置过程不需要用root权限
# 配置数据库,根据提示填写
./setup-seafile-mysql.sh

# 启动seafile
# ./seafile.sh { start | stop | restart }

# 启动seahub,首次启动需要设置管理员
# run seahub  server:     ./seahub.sh  { start  | stop | restart  }


启用Apache反向代理

# 启用代理功能
sudo a2enmod rewrite proxy_http

# 增加防火墙规则
sudo ufw allow 8000
sudo ufw allow 8082

# 修改代理配置
cd /etc/apache2/sites-enabled
sudo cp 000-default.conf 000-default.conf.bak
sudo vim 000-default.conf

# 修改如下:

		# ServerName www.myseafile.com	
		ServerAdmin webmaster@localhost
		DocumentRoot /var/www/html
		Alias /media  /home/demo/haiwen/seafile-server-latest/seahub/media
		RewriteEngine On

		
			Require all granted
		

		#
		# seafile fileserver
		#
		ProxyPass /seafhttp http://127.0.0.1:8082
		ProxyPassReverse /seafhttp http://127.0.0.1:8082
		RewriteRule ^/seafhttp - [QSA,L]

		#
		# seahub
		#
		SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
		ProxyPass / http://127.0.0.1:8000/
		ProxyPassReverse / http://127.0.0.1:8000/
		
		ErrorLog ${APACHE_LOG_DIR}/error.log
		CustomLog ${APACHE_LOG_DIR}/access.log combined
	


# 修改完毕后重启apache服务
sudo /etc/init.d/apache2 restart

# 至此,已经可以用web登陆Seafile。

添加自启动功能

# 新建seafile服务
sudo vim /etc/systemd/system/seafile.service

# 内容
[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target

[Service]
Type=oneshot
ExecStart=/home/demo/haiwen/seafile-server-latest/seafile.sh start
ExecStop=/home/demo/haiwen/seafile-server-latest/seafile.sh stop
RemainAfterExit=yes
User=demo
Group=demo

[Install]
WantedBy=multi-user.target


# 新建seahub服务
sudo vim /etc/systemd/system/seahub.service
[Unit]
Description=Seafile hub
After=network.target seafile.service

[Service]
# change start to start-fastcgi if you want to run fastcgi
ExecStart=/home/demo/haiwen/seafile-server-latest/seahub.sh start
ExecStop=/home/demo/haiwen/seafile-server-latest/seahub.sh stop
User=demo
Group=demo
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

# 启用服务
sudo systemctl enable seafile.service
sudo systemctl enable seahub.service
sudo systemctl daemon-reload
10-07 18:40