自己的服務器到期,轉移自己博客內容至此。
seafile搭建企業、個人私有雲,並將站點配置為https。 點擊進入seafile官網
環境:Centos 7
一、安裝seafile准備
[root@xifeng tools]# wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.1.2_x86-64.tar.gz #下載seafile安裝包 [root@xifeng tools]# mkdir /var/html/seafile -p #創建seafile目錄 [root@xifeng tools]# mv seafile-server_6.1.2_x86-64.tar.gz /var/html/seafile/ #將下載的seafile移動到指定路徑 [root@xifeng tools]# cd /var/html/seafile/ [root@xifeng seafile]# mkdir installed [root@xifeng seafile]# tar xf seafile-server_6.1.2_x86-64.tar.gz [root@xifeng seafile]# mv seafile-server_6.1.2_x86-64.tar.gz installed/ [root@xifeng mycloud]# cd seafile-server-6.1.2/ #以上幾步為解壓安裝包,並將安裝包移至installed目錄里,進入解壓后的目錄。
二、seafile數據庫安裝(mysql或者mariadb)
seafile的官方腳本會默認安裝三個數據庫,默認庫名分別如下:
database create new ccnet database: ccnet-db seafile database: seafile-db seahub database: seahub-db
依照官方腳本,最后提示沒有權限在本機創建數據庫的表。刪掉創建的文件后,可自行授權數據庫:
#grant all privileges on `seafile-db`.* to ‘seafile’@’127.0.0.1’ identified by ‘yourpass’; #grant all privileges on `seahub-db`.* to ‘seafile’@’127.0.0.1’ identified by ‘yourpass’; #grant all privileges on `ccnet-db`.* to ‘seafile’@’127.0.0.1’ identified by ‘yourpass’;
就是對seafile數據庫用戶授權在本機管理以上三個數據庫。
做完數據庫授權后,再進行安裝:
[root@xifeng seafile-server-6.1.2]# ./setup-seafile-mysql.sh #安裝數據庫 Checking python on this machine … Checking python module: setuptools … Done. Checking python module: python-imaging … Done. Checking python module: python-mysqldb … Done. —————————————————————– This script will guide you to setup your seafile server using MySQL. Make sure you have read seafile server manual at https://github.com/haiwen/seafile/wiki Press ENTER to continue —————————————————————– [ server name ] mycloud What is the ip or domain of the server? For example: www.mycompany.com, 192.168.1.101 [ This server’s ip or domain ] cloud.liuanhuaming.top Where do you want to put your seafile data? Please use a volume with enough free space [ default “/var/html/mycloud/seafile-data” ] Which port do you want to use for the seafile fileserver? [ default “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 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 ] verifying password of user root … done Enter the name for mysql user of seafile. It would be created if not exists. [ default “seafile” ] mycloud Enter the password for mysql user “mycloud”: [ password for mycloud ] verifying password of user mycloud … done Enter the database name for ccnet-server: [ default “ccnet-db” ] Enter the database name for seafile-server: [ default “seafile-db” ] Enter the database name for seahub: [ default “seahub-db” ] ——————————— This is your configuration ——————————— server name: mycloud server ip/domain: cloud.liuanhuaming.top seafile data dir: /var/html/mycloud/seafile-data fileserver port: 8082 database: create new ccnet database: ccnet-db seafile database: seafile-db seahub database: seahub-db database user: mycloud ——————————— Press ENTER to continue, or Ctrl-C to abort ——————————— Generating ccnet configuration … done Successly create configuration dir /var/html/mycloud/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 <port> | stop | restart <port> } —————————————————————– 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@xifeng seafile-server-6.1.2]# ./seafile.sh start [12/01/17 13:27:36] ../common/session.c(132): using config file /var/html/mycloud/conf/ccnet.conf Starting seafile server, please wait … Seafile server started Done. [root@xifeng seafile-server-6.1.2]# ./seahub.sh start LC_ALL is not set in ENV, set to en_US.UTF-8 Starting seahub at port 8000 … —————————————- It’s the first time you start the seafile server. Now let’s create the admin account —————————————- What is the email for the admin account? [ admin email ] *****@gmail.com What is the password for the admin account? [ admin password ] Enter the password again: [ admin password again ] —————————————- Successfully created seafile admin —————————————- Seahub is started Done.
服務啟動、管理帳號創建完成!
四、配置nginx,讓seafile為https站點
直接上nginx配置:
server { listen 80; server_name cloud.liuanhuaming.top; rewrite ^ https://$http_host$request_uri? permanent; server_tokens off; } server { listen 443; ssl on; ssl_certificate /etc/letsencrypt/live/cloud.liuanhuaming.top/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/cloud.liuanhuaming.top/privkey.pem; server_name cloud.liuanhuaming.top; ssl_session_timeout 5m; ssl_session_cache shared:SSL:5m; ssl_prefer_server_ciphers on; proxy_set_header X-Forwarded-For $remote_addr; add_header Strict-Transport-Security “max-age=31536000; includeSubDomains”; server_tokens off; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Forwarded-Proto https; access_log /var/log/nginx/seahub.access.log; error_log /var/log/nginx/seahub.error.log; proxy_read_timeout 1200s; client_max_body_size 0; } location /seafhttp { rewrite ^/seafhttp(.*)$ $1 break; proxy_pass http://127.0.0.1:8082; client_max_body_size 0; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; proxy_send_timeout 36000s; send_timeout 36000s; } location /media { root /var/html/mycloud/seafile-server-latest/seahub; } }
重啟nginx,全部完成,瀏覽器測試成功!
五、添加開機自啟動
[root@xifeng seafile-server-latest]# vi /etc/rc.local /var/html/mycloud/seafile-server-latest/seafile.sh start /var/html/mycloud/seafile-server-latest/seahub.sh start 添加以上兩行,路徑改為自己的,完成!
六、遇到的問題
由於服務器搭建其他應用,或者重啟了服務器,某天發現seafile無法上傳和訪問。於是進到
服務器運行啟動seafile.sh和seahub.sh腳本,發現無法運行,提示使用www用戶運行,因為我把
seafile的所有目錄授權為www用戶,即nginx的運行用戶。導致無法運行腳本。
錯誤提示:
[root@liuanhuaming seafile-server-6.1.2]# ./seafile.sh start Error: the user running the script (“root”) is not the owner of “/var/html/mycloud/seafile-data” folder, you should use the user “www” to run the script.
通過翻譯,只要將/var/html/mycloud/seafile-data授權為root用戶所有,再用root運行腳本即可。
解決方法:
[root@liuanhuaming mycloud]# chown -R root.root seafile-data/ [root@liuanhuaming mycloud]# cd seafile-server-6.1.2/ [root@liuanhuaming seafile-server-6.1.2]# ./seafile.sh start [01/23/18 10:05:41] ../common/session.c(132): using config file /var/html/mycloud/conf/ccnet.conf Starting seafile server, please wait … Seafile server started Done. [root@liuanhuaming seafile-server-6.1.2]# ./seahub.sh start LC_ALL is not set in ENV, set to en_US.UTF-8 Starting seahub at port 8000 … Seahub is started Done.
