SVN+Apache输出中文报错

问题描述

我们的代码管理采用的是SVN+Apache的方式,通过http协议访问。
当服务端输出中文信息时,客户端(乌龟)就会报错:output could not be translated from the native locale to UTF-8

原因排查

是因为SVN+Apache的方式,Apache必须要有mod_dav_svn.so这个模块,且需要设置SVNUseUTF8 on。
而我们内网的apache和svn是通过yum安装的,版本很低,其中的mod_dav_svn.so模块不支持SVNUseUTF8 on这个参数。

1
2
3
4
官方文档说明:
SVNUseUTF8 On|Off
When set to On, mod_dav_svn will communicate with hook scripts using repository root paths encoded in UTF-8, and will expect those scripts to likewise generate output (such as error messages) encoded in UTF-8. The default value of this option is Off, which means that mod_dav_svn assumes a 7-bit ASCII encoding for its hook script interactions. This option is available as of Subversion 1.8.
默认是7bit的ASCII编码,所以和UTF8转换就有问题;根据这个说明,确定SVN还必须升级到1.8才行。

解决方案

重新源码安装高版本的SVN和Apache。

安装Apache

./configure –prefix=/usr/local/apache –enable-dav –enable-so –enable-mods-shared=proxy –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –enable-maintainer-mode –enable-rewrite

安装svn

注意一定要加上–with-apxs=/usr/local/apache/bin/apxs,这个我理解的就是类似php安装模块的phpize,包含有apache的配置信息,可以简化你的安装。

./configure –prefix=/usr/local/subversion-1.8.16 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –with-apxs=/usr/local/apache/bin/apxs

安装成功后,so文件位于/usr/local/subversion-1.8.16/libexec/目录中

将so文件复制到Apache的modules目录下

在Apache的httpd.conf中开启dav模块

如果忘记了这一步,会报错:undefined symbol: dav_register_provider.

配置SVN的Apache项

测试并启动Apache