归档文章 (2011-2017)

date
2017/06/15
环境:ubuntu 16.04 (docker)

一、新建 Docker 容器(选做)

docker run -it --name seafile \ --restart=always \ -v /home/seafile:/opt/seafile \ -p 8082:8082 \ -p 10080:80 \ -p 10443:443 \ -d ubuntu:16.04 /bin/bash
更新源
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \ sed -i 's/deb http:\/\/security/#deb http:\/\/security/g' /etc/apt/sources.list && \ sed -i 's/deb-src http:\/\/security/#deb-src http:\/\/security/g' /etc/apt/sources.list && \ apt-get -y update
安装有用工具
apt install -y curl wget net-tools vim

二、安装 mariadb (二进制版)

参考文档1: CentOS 从二进制版安装配置 Mariadb
安装依赖
apt install -y libaio-dev
解压
cd /opt/seafile/ && \ tar -zxf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz && \ mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mysql
新建 mysql 用户
groupadd mysql && \ useradd -g mysql -M -s /sbin/nologin mysql
安装初始化
cd /usr/local/mysql && \ ./scripts/mysql_install_db --user=mysql chown -R root . && chown -R mysql data
支持命令行运行
export PATH=$PATH:/usr/local/mysql/bin/ && \ echo 'export PATH=$PATH:/usr/local/mysql/bin/' >> .bashrc
开机启动
cp support-files/mysql.server /etc/init.d/mysql && \ update-rc.d mysql defaults && \ service mysql start
密码及安全设置
/usr/local/mysql/bin/mysqladmin -u root password '123456' && \ /usr/local/mysql/bin/mysql_secure_installation
解决中文乱码
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf && \ vim /etc/my.cnf
vim /etc/mysql/conf.d/mariadb.cnf [client] ... default-character-set=utf8 ... [mysql] ... default-character-set=utf8 ... [mysqld] ... character-set-server = utf8 collation-server = utf8_general_ci character_set_server = utf8 collation_server = utf8_general_ci ...

三、安装 Seafile

3.1 安装依赖

python2.7
apt-get -y install python && \ apt-get -y install python2.7 libpython2.7 python-setuptools python-imaging \ python-ldap python-mysqldb python-memcache python-urllib3
安装 JRE
apt-get -y install openjdk-8-jre && \ ln -sf /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java /usr/bin/
安装 pdf 全文搜索依赖
apt-get -y install poppler-utils
安装 Python 库
easy_install pip && pip install boto requests

3.2 安装 seafile

准备 seafile
mkdir -p seafile mv seafile-pro-server_* seafile cd seafile tar -xzf seafile-pro-server_* mkdir installed mv seafile-pro-server_* installed
安装 seafile
cd seafile-pro-server-* && \ ./setup-seafile-mysql.sh Cloud cloud.youdomain.com /opt/seafile/seafile-data 8082 1 localhost 3306 seafile seafile_ccnet seafile_db seafile_seahub

3.3 配置 seafile

vim /opt/seafile/conf/ccnet.conf SERVICE_URL = https://cloud.youdomain.com
vim /opt/seafile/conf/seahub_settings.py FILE_SERVER_ROOT = 'https://cloud.youdomain.com/seafhttp'
vim /opt/seafile/conf/seafdav.conf [WEBDAV] enabled = true port = 8080 fastcgi = true share_name = /seafdav
运行
cd /opt/seafile/seafile-server-latest ./seafile.sh start && ./seahub.sh start-fastcgi

3.4 在线预览

apt-get -y install libreoffice libreoffice-script-provider-python apt-get -y install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy & \ apt-get -y install poppler-utils
/opt/seafile/seafile-server-latest/seafile.sh restart /opt/seafile/seafile-server-latest/seahub.sh stop /opt/seafile/seafile-server-latest/seahub.sh start-fastcgi

3.5 自定义CSS

mkdir /opt/seafile/seahub-data/custom ln -s /opt/seafile/seahub-data/custom /opt/seafile/seafile-server-latest/seahub/media/custom

3.6 时间同步

rm -rf /etc/localtime && \ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ echo "Asia/Shanghai" > /etc/timezone dpkg -l|grep ntp &>/dev/null || apt-get -y install ntpdate && \ [ "$PING" = 1 ] && ntpdate -d cn.pool.ntp.org
Seafile 参考文档:
对于本文内容有任何疑问, 可与我联系.