測試平臺:VM10虛擬機 ,CentOS 7 64位,最小化安裝。
一、最小化安裝的CentOS部署Seafile前的準備工作
1、安裝虛機前將網絡類型設置為橋接方式。
2、安裝時手工配置網卡IP、子網掩碼、網關、DNS,并且打開網絡開關。如果忘記打開,reboot后網卡處于未激活狀態,無法SSH登錄,root 用戶本機登陸,使用 nmtui 命令,激活網卡。編輯網卡配置文件,實現開機激活網卡。
#選擇第二項激活網卡
[root@localhost ~]# nmtui
#最后的數字是激活的網卡號,修改配置文件參數 ?“ONBOOT=yes”
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno1677736
3、安裝完成后添加國內yum軟件源,我采用的是163的源。
#備份yum源配置文件
[root@localhost ~]# cp?/etc/yum.repos.d/CentOS-Base.repo??/etc/yum.repos.d/CentOS-Base.repo_backup
#編輯源配置文件
[root@localhost ~]#vi /etc/yum.repos.d/CentOS-Base.repo
#復制下面的文本,替換掉源文件內容:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#運行以下命令生成緩存
[root@localhost ~]#?yum clean all
[root@localhost ~]# yum?makecache
4、安裝wget下載程序
[root@localhost ~]# yum install wget
二、下載seafil社區版軟件包
[root@localhost ~]# wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.1.1_x86-64.tar.gz
三、按部署手冊指引建立目錄、解壓文件
[root@localhost ~]# cd /
#在根目錄下創建目錄 haiwen
[root@localhost /]# mkdir haiwen
#把下載的服務端軟件包移到 haiwen目錄下
[root@localhost /]# mv /root/seafile-server_6.1.1_x86-64.tar.gz /haiwen/
[root@localhost /]# cd /haiwen
#解壓軟件包
[root@localhost haiwen]# tar -xzf seafile-server_6.1.1_x86-64.tar.gz
[root@localhost haiwen]# mkdir installed
[root@localhost haiwen]# mv seafile-server_6.1.1_x86-64.tar.gz installed/
四、安裝MariaDB、python2.7
[root@localhost haiwen]# yum install mariadb-server
[root@localhost haiwen]# yum install python-setuptools python-imaging python-ldap MySQL-python python-memcached python-urllib3
五、啟動MariaDB服務并設置開機啟動,配置MariaDB初始根密碼
[root@localhost haiwen]# systemctl start mariadb.service
[root@localhost haiwen]# systemctl enable mariadb.service
[root@localhost haiwen]# mysql_ secure_installation
Enter current password for root (enter for none):??#初次運行直接回車
Set root password? [Y/n]??#是否設置root用戶密碼,輸入y并回車或直接回車
New password:??#設置root用戶的密碼
Re-enter new password:??#再輸入一次你設置的密碼
Remove anonymous users? [Y/n]??#是否刪除匿名用戶,生產環境建議刪除,所以直接回車
Disallow root login remotely? [Y/n]??#是否禁止root遠程登錄,根據自己的需求選擇Y/n并回車,建議禁止
Remove test database and access to it? [Y/n]??#是否刪除test數據庫,直接回車
Reload privilege tables now? [Y/n]??#是否重新加載權限表,直接回車
六、安裝Seafile
[root@localhost haiwen]# cd /haiwen/seafile-server-6.1.1/
[root@localhost seafile-server-6.1.1]# ./setup-seafile-mysql.sh
該腳本會依次詢問你一些問題,從而一步步引導你配置 Seafile 的各項參數:
What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ]? seatest
#服務器的名字,目前該配置已經不再使用,這里填seatest
What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] 10.0.0.6
?#服務器的 IP 地址或者域名,客戶端通過這個 IP 或者地址來訪問你的 Seafile 服務,這里填10.0.0.6
Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/haiwen/seafile-data" ]??
#數據存放的目錄,默認是 /data/haiwen/seafile-data,這里直接回車
Which port do you want to use for the seafile fileserver?
[ default "8082" ]??
#seafile fileserver 使用的 TCP 端口,該端口用于文件同步,請使用默認的 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??
#要求選擇一種創建 Seafile 數據庫的方式。選1,需要提供MariaDB初始根密碼,程序會創建數據庫和用戶。選2,系統采用已創建的數據庫。這里選1
What is the host of mysql server?
[ default "localhost" ]??
#數據庫主機名稱,默認即可,直接回車
What is the port of mysql server?
[ default "3306" ]??
#數據庫端口,默認即可,直接回車
what is the password of the mysql root user?
[ root password ]??
#數據庫根密碼,填寫MariaDB初始根密碼
verifying password of user root ...??done
Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ]??
#數據庫用戶名,默認即可,直接回車
Enter the password for mysql user "seafile":
[ password for seafile ]??
#數據庫對應用戶名的密碼,可填寫MariaDB初始根密碼
Enter the database name for ccnet-server:
[ default "ccnet-db" ]??
#ccnet-server數據庫名稱,默認即可,直接回車
Enter the database name for seafile-server:
[ default "seafile-db" ]??
#seafile-server數據庫名稱,默認即可,直接回車
Enter the database name for seahub:
[ default "seahub-db" ]??
#seahub數據庫名稱,默認即可,直接回車
--------------------------------
**This is your configuration**
server name:seatest
server ip/domain:???10.0.0.6
seafile data dir:???/haiwen/seafile-data
fileserver port:8082
database:???create new
ccnet database: ccnet-db
seafile database:???seafile-db
seahub database:seahub-db
database user:??seafile
---------------------------------
Press ENTER to continue, or Ctrl-C to abort
Generating ccnet configuration ...
done
Successly create configuration dir /haiwen/ccnet.
Generating seafile configuration ...
Done.
done
Generating seahub configuration ...
Now creating seahub database tables ...
creating seafile-server-latest symbolic link ...??done
Your seafile server configuration has been finished successfully.
run seafile server: ./seafile.sh { start | stop | restart }
run seahub??server: ./seahub.sh??{ start | stop | restart }
If you are behind a firewall, remember to allow input/output of these tcp ports:
port of seafile fileserver:???8082
port of seahub:???8000
When problems occur, Refer to
https://github.com/haiwen/seafile/wiki
for information.?
?#到這里安裝基本完成,進一步配置防火墻,啟動Seafile相關服務即可使用
七、配置防火墻,打開需要用的端口
[root@localhost seafile-server-6.1.1]#??firewall-cmd --zone=public --add-port=8000/tcp --permanent
[root@localhost seafile-server-6.1.1]#??firewall-cmd --zone=public --add-port=8082/tcp --permanent
[root@localhost seafile-server-6.1.1]#??firewall-cmd --reload
八、啟動Seafile、Seahub服務
[root@localhost seafile-server-6.1.1]#??./seafile.sh start
[root@localhost seafile-server-6.1.1]#??./seahub.sh start
在執行seahub.sh腳本執行過程中,設置seafile管理員帳號(郵箱注冊)、密碼。
腳本執行完成后,可以在瀏覽器地址欄中輸入服務器地址(帶端口號,本例為10.0.0.6:8000),測試基本功能。
九、設置Seafile開機啟動
這里采用seafile論壇neroxps的方法,官方手冊上的第一種方法沒成功。
#建立seafile服務
[root@localhost seafile-server-6.1.1]# vi /etc/systemd/system/seafile.service
輸入以下內容,注意修改“/haiwen”為你的seafile安裝目錄:
[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
# 如果沒有使用memcached則去掉memcached.service
After=network.target mariadb.service
[Service]
Type=oneshot
ExecStart=/haiwen/seafile-server-latest/seafile.sh start
# 如果seahub使用了nginx反代,請修改為 ExecStart=${seafile_dir}/seafile-server-latest/seahub.sh start-fastcgi
ExecStart=/haiwen/seafile-server-latest/seahub.sh start
ExecStop=/haiwen/seafile-server-latest/seafile.sh stop
ExecStop=/haiwen/seafile-server-latest/seahub.sh stop
RemainAfterExit=yes
# User 和 Group 如果未建立seafile用戶和用戶組,則修改為root,否則無法啟動.
User=root
Group=root
[Install]
WantedBy=multi-user.target
#運行systemctl daemon-reload使配置生效
[root@localhost seafile-server-6.1.1]# systemctl daemon-reload
按需要執行命令:
#啟動seafile
[root@localhost seafile-server-6.1.1]# systemctl start seafile
#停止seafile
[root@localhost seafile-server-6.1.1]# systemctl stop seafile
#設置seafile隨系統啟動
[root@localhost seafile-server-6.1.1]# systemctl enable seafile
#檢查seafile是否已經設置為自啟動
[root@localhost seafile-server-6.1.1]# systemctl is-enabled seafile
#關閉seafile隨系統啟動
[root@localhost seafile-server-6.1.1]# systemctl disable seafile