在CentOS 6.4_64安装Seafile使用Apahce和SQLite。
1. 环境准备
1.1 centos6.4_64 最小化安装
yum -y install httpd ##部署在apache之后,参考https://github.com/haiwen/seafile/wiki/Deploy-Seafile-with-apache
yum -y install install Python python-setuptools python-simplejson python-imaging sqlite3 ##系统默认是python2.6
yum -y install apr apr-devel httpd-devel libtool ##安装fastcgi需要用到
yum update -y
chkconfig postfix off
/etc/ini t.d/postfix stop ##关闭邮件服务
reboot
1.2 防火墙配置
vi /etc/sysconfig/iptables
/etc/sysconfig/iptables增加三条内容开放80、10001、12001端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10001 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 12001 -j ACCEPT
防火墙重启配置生效。
/etc/init.d/iptables restart
1.3 安装fastcgi为httpd一个模块
seafile的apache部署使用到fastcgi,下载fastcgi,解压
curl -O
tar -xzvf mod_fastcgi-current.tar.gz
cd mod_fastcgi-2.4.6/
cp Makefile.AP2 Makefile
更改Makefile内文件top_dir
#top_dir = /usr/local/apache2
top_dir = /usr/lib64/httpd ##如32位机器应是/usr/lib/httpd
编译安装fastcgi,安装到/usr/lib64/httpd/modules/(32位机器/usr/lib/httpd/modules/)
make
make install
配置httpd.conf
添加FastCGIExternalServer
LoadModule fastcgi_module modules/mod_fastcgi.so
##
FastCGIExternalServer /var/www/html/seahub.fcgi -host 127.0.0.1:8000
添加/etc/httpd/conf.d/v.conf
NameVirtualHost *:80
ServerName sf.linuxidc.com ##对应dns要配置,如没有就修改自己机器的hosts
DocumentRoot /var/www/html
Alias /media /opt/haiwen/seafile-server-2.0.3/seahub/media/
RewriteEngine On
#
# seafile httpserver
#
ProxyPass /seafhttp :8082
ProxyPassReverse /seafhttp :8082
RewriteRule ^/seafhttp - [QSA,L]
# seahub
#
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
2. 安装seafile2.0
2.1 seafile下载、解压
seafile下载、解压到指定目录就行了,执行安装命令。
tar -xzvf seafile-server_2.0.3_x86-64.tar.gz
mkdir /opt/haiwen
mv seafile-server-2.0.3 /opt/haiwen
安装seafile,只需要按指定提示填写就行了,一般默认。可参考:https://github.com/haiwen/seafile/wiki/Download-and-setup-seafile-server。
./setup-seafile.sh
2.2 配置selinux
selinux在centos6下面默认是开启的。
setsebool -P httpd_can_network_connect 1 ##httpd可网络连接
chcon -R -h -u system_u -t httpd_sys_content_t /opt/haiwen/seafile-server-2.0.3/seahub/media/ ##httpd可访问
chcon -R -h -u system_u -t httpd_sys_content_t /opt/haiwen/seahub-data/avatars/ ##httpd可访问
3. 启动服务
seafile和seahub启动,httpd重启。
/opt/haiwen/seafile-server-2.0.3/seafile.sh start
/opt/haiwen/seafile-server-2.0.3/seahub.sh start-fastcgi
/etc/init.d/httpd restart
最后祝贺成功安装了,可直接访问
或下载客户端访问
4. 遇到问题
4.1 httpd出错apr_sockaddr_info_get() failed
Starting httpd: httpd: apr_sockaddr_info_get() failed for seafile.linuxidc.com
在/etc/hosts添加seafile.linuxidc.com,机器名称。
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 seafile.linuxidc.com
4.2 FastCGI: apr_dir_open()失败
出错信息如下
[Wed Nov 20 10:51:13 2013] [error] (13)Permission denied: FastCGI: apr_dir_open() failed
[Wed Nov 20 10:51:13 2013] [notice] Digest: generating secret for digest authentication ...
[Wed Nov 20 10:51:13 2013] [notice] Digest: done
[Wed Nov 20 10:51:13 2013] [error] (13)Permission denied: FastCGI: apr_dir_open() failed
[Wed Nov 20 10:51:13 2013] [notice] FastCGI: process manager initialized (pid 1823)
[Wed Nov 20 10:51:13 2013] [notice] Apache/2.2.15 (Unix) DAV/2 mod_fastcgi/2.4.6 configured -- resuming normal operations
是selinux问题,执行如下命令
chcon -R -t var_log_t /var/log/httpd/fastcgi/