centos7.2+mysql5.6.35+subversion1.9.7+apache+https+php5.6.20+manmanager1.10(二)

三、安装subversion

centos7默认安装的svn版本是1.7.14,但这个版本中有个关于UTF8的bug,这个bug一直到1.8版本后期才修复,所以需要装完后升级到新版本,切记不能直接安装新版本,否则会有权限问题。

安装subversion

yum install subversion mod_dav_svn mod_ssl openssl httpd*  -y

确认版本

svn --version

创建库

mkdir -p  /data/svndata
svnadmin create --fs-type fsfs /data/svndata/testrepo(注:默认存储方式为bdb,不过使用fsfs存储方式更有效)
cd /data/svndata/testrepo/conf
vim svnserve.conf 
    [general]  
    anon-access = none  
    auth-access = write  
    password-db = /etc/access/passwd  #httpd鉴权使用  
    authz-db = /etc/access/authz      #svn版本库权限文件  
    realm =   testrepo                #版本库  
 

mkdir  /etc/access    //创建权限文件
touch /etc/access/passwd  //文件加密
htpasswd -c /etc/access/passwd admin #添加第二个用户的时候,不要-c,否则会被覆盖  

cp /data/svndata/testrepo/conf/authz /etc/access/authz
# vim /etc/access/authz
    [groups]  
    admin= admin       
    [testrepo:/]  
    @admin=rw 
    [/]
     *  = r
vim /etc/httpd/conf.d/subversion.conf 
<Location /svn/>                                                                                                                                                                      
DAV svn                                                                                                                                                                                
SVNParentPath /data/svndata/                                                                                                                                                          
AuthType Basic                                                                                                                                                                        
AuthName "svn Repository"                                                                                                                                                              
AuthUserFile /etc/access/passwd                                                                                                                                                        
Require valid-user                                                                                                                                                                    
AuthzSVNAccessFile /etc/access/authz                                                                                                                                                  
SSLRequireSSL                                                                                                                                                                          
</Location> 
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

配置https,生成证书

cd  /etc/pki/tls/private   
openssl  genrsa  -out  svn_server.key  1024  
openssl  req  -new  -key  svn_server.key  -out svn_server.csr    
cd  /etc/pki/tls/certs    
openssl  x509  -req  -days  365  -in  /etc/pki/tls/private/svn_server.csr  -signkey  /etc/pki/tls/private/svn_server.key  -out  svn_server.crt

配置apache ssl

vim /etc/httpd/conf.d/ssl.conf  
  SSLCertificateFile /etc/pki/tls/certs/svn_server.crt  
  SSLCertificateKeyFile /etc/pki/tls/private/svn_server.key  
vim /etc/httpd/conf/httpd.conf 
   <IfModule dir_module>中添加
  Index.cgi index.php
  最下面加2行  
    LoadModule php5_module modules/libphp5.so
    AddType application/x-httpd-php .php
//libphp5.so是php安装后才会有

修改/etc/access访问权限

chown -R apache:apache /etc/access/
chmod -R a+x /etc/access/

修改/svndata及库访问权限

chown -R apache:apache /data/svndata/
chmod -R a+x /data/svndata/

重启apache,svnserve

systemctl restart httpd.service
pkill svnserve
svnserve -d -r /data/svndata/testrepo
//权限控制:允许httpd访问svn库
chcon -R -h -t httpd_sys_content_t /data/svndata

强制输入提交备注(以下内容需要带空格)

在conf下的hooks中新建pre-commit文件,文件内容如下

#!/bin/sh
                                                                                                                                            
REPOS="$1"                                                                                                                                                               

TXN="$2"                                                                                                                                                                     

SVNLOOK=/usr/bin/svnlook                                                                                                                                       

LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" |wc -c`                                                           

if [ "$LOGMSG" -lt 15 ];                                                                                                                                               

then                                                                                                                                                                              

   echo "提交失败【提交代码必须有注释,不可少于15个字符!】." 1>&2                                                                     

   exit 1                                                                                                                                                                           

fi

对于UTF-8字符集的修复

//创建一个新的YUM库文件 /etc/yum.repos.d/wandisco-svn.repo
vim /etc/yum.repos.d/wandisco-svn.repo
//内容如下
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/$releasever/svn-1.9/RPMS/$basearch/
enabled=1
gpgcheck=0
//安装最新版本SVN
yum remove subversion -y 
yum install subversion mod_dav_svn -y
确认版本
#svn --version
vim /etc/httpd/conf/httpd.conf
//增加
<IfModule mod_dav_fs.c>
# Location of the WebDAV lock database.
DAVLockDB /var/lib/dav/lockdb
SVNUseUTF8 On
</IfModule>

权限设置

chown apache:apache pre-commit
chmod 777 pre-commit
systemctl restart httpd.service

四、配置php

因为yum缺省安装的是PHP5.4,所以先要添加yum库

[root@svnhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
[root@svnhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装PHP5.6.20

[root@svnhost ~]# yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
[root@svnhost log]# yum install php-pear        //安装SVNMANAGER需要的包
[root@svnhost ~]# yum install php-mysqli        //安装svnmanage需要的包

配置PHP

vim /etc/php.ini
date.timezone = PRC //把前面的分号去掉,改为date.timezone = PRC
expose_php = Off //禁止显示php版本的信息
short_open_tag = ON //支持php短标签,一定要打开,否则不能解析PHP文件
//测试PHP安装是否成功
#systemctl restart httpd.service
#systemctl start mysqld.service

vim /var/www/html/index.php
<?php
phpinfo();
?>

从客户端访问http://ip, 显示PHP版本信息,说明PHP安装成功。

测试php连接mysql是否成功

<?php                                                                                                                                                                                  
$connect=mysqli_connect("127.0.0.1","admin","admin");                                                                                                                               
if(!$connect) echo "Mysql Connect Error";                                                                                                                                              
else echo "Mysql Connect Success";                                                                                                                                                     
mysqli_close();                                                                                                                                                                        
?>

从客户端访问http://ip/test.php, 显示"Mysql Connect Success",说明连接mysql成功。

 

五、SVNmanager安装

cd  /usr/local
wget -c https://sourceforge.net/projects/svnmanager/files/svnmanager/1.10/svnmanager-1.10.tar.gz
wget -c http://download.pear.php.net/package/VersionControl_SVN-0.5.2.tgz

将svnmanager解压至/var/www/html下

tar zxvf  svnmanager-1.10.tar.gz
mv svnmanager-1.10    svnmanager
cp -R svnmanager /var/www/html/
//pear安装VersionControl_SVN-0.5.2 (与之前的版本不同,不需要再安装XML_Parser包)
pear install VersionControl_SVN-0.5.2.tgz

配置svnmanager中的config.php文件

svnmanager的配置文件在/var/www/html/svnmanager目录下,有一个config.php.linux和config.php.win,分别针对Linux和Windows操作系统下的配置模板.Copy config.php.linux 到config.php

$htpassword_cmd = "/usr/bin/htpasswd";
$svn_cmd = "/usr/bin/svn";
$svnadmin_cmd = "/usr/bin/svnadmin";
$svn_config_dir    = “/etc/access/";
$svn_repos_loc = "/data/svndata/";
$svn_passwd_file = " /etc/access/passwd";
$svn_access_file = " /etc/access/authz";
$smtp_server = "smtp.domain.org";
$dsn = "mysqli://admin:admin@127.0.0.1/svnmanager";               (请注意这里使用的是mysqli)
//Administrator account
$admin_name = "admin";
$admin_temp_password = "admin”;

配置访问权限

chown -R apache:apache /var/www/html/svnmanager/
chmod -R a+x /var/www/html/svnmanager/
systemctl restart httpd

通过浏览器访问http://ip/svnmanager会提示创建SVNManager数据表,刷新页面,出现登录页面,使用admin admin登录,这个密码是一次性的,所以要新建一个管理员用户。

 

会出现的问题

1、svnmanager1.10安装完毕后,选择“Repository Admin"-->"Group Privileges",会出现repository的列表,选择其中一个”Select"后,会出现如下错误:

VersionControl_SVN_Exception: "svn_path" is not a valid option

#0 /usr/local/php/lib/php/VersionControl/SVN.php(267): VersionControl_SVN_Command->setOptions(Array)

#1 /usr/local/php/lib/php/VersionControl/SVN.php(226): VersionControl_SVN::init('list', Array)

#2 /opt/apps/web/php/svnmanager/svnmanager/RepositoryModule/GroupPrivilegesEditPage.php(214): VersionControl_SVN::factory(Array, Array)

#3 /opt/apps/web/php/svnmanager/prado-2.0.3/framework/Web/UI/TControl.php(419): GroupPrivilegesEditPage->onLoad(Object(TEventParameter))

#4 /opt/apps/web/php/svnmanager/prado-2.0.3/framework/Web/UI/TPage.php(1079): TControl->onLoadRecursive(Object(TEventParameter))

#5 /opt/apps/web/php/svnmanager/prado-2.0.3/framework/Web/UI/TPage.php(955): TPage->onLoadRecursive(Object(TEventParameter))

#6 /opt/apps/web/php/svnmanager/prado-2.0.3/framework/TApplication.php(483): TPage->execute()

#7 /opt/apps/web/php/svnmanager/index.php(5): TApplication->run()

#8 {main}

解决方法是编辑/var/www/html/svnmanager/svnmanager/RepositoryModule目录下的
UserPrivilegesEditPage.php 和 GroupPrivilegesEditPage.php 文件 :
$options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ARRAY, 'svn_path' => $svn_cmd);
改成:
$options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ARRAY);

 2、解决中文目录问题(转自:http://www.jiazi.cn/blog/?id=46

早期的版本,svnmanager连中文目录都无法显示,主要是在权限分配时。但svnmanager-1.10已经支持显示中文目录了,但也仅仅是能在下拉列表中显示而已,当你想进一步查看该中文目录下的子目录时,就会报类似如下的错误:

VersionControl_SVN_Exception: Execution of command failed returning: 1
svn: E000022: Can't convert string from native encoding to 'UTF-8':
svn: E000022: file:///data/svn/repositories/developer///doc/?\228?\184?\147?\229?\136?\169

解决方法:

修改/usr/share/pear/VersionControl/SVN/Command.php文件,在run()方法中找到如下代码:

if (!$this->passthru) {
  exec("{$this->prependCmd}$cmd 2>&1", $out, $returnVar);
} else {
  passthru("{$this->prependCmd}$cmd 2>&1", $returnVar);
}

改为:

if (!$this->passthru) {
 exec("export LC_CTYPE=en_US.UTF-8 && {$this->prependCmd}$cmd 2>&1", $out, $returnVar);
} else {
 passthru("export LC_CTYPE=en_US.UTF-8 && {$this->prependCmd}$cmd 2>&1", $returnVar);
}

 

 

posted @ 2018-03-08 13:05  转圈又是原点  阅读(983)  评论(0编辑  收藏  举报