SVN是个版本库控制器,通过SVNmanager管理SVN账号可以更加高效
前置工作:关闭防火墙和selinux,或防火墙放行对应端口都可。
//永久关闭防火墙 # systemctl disable --now firewalld //永久关闭selinux # sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config # setenforce 0
下载配置mysql5.7,请参考我上一篇博客中安装mysql的部分
//如果启动mysql报错提示日志或pid文件不存在,就把/etc/my.cnf中的内容进行修改后重新启动 ....... [mysqld_safe] #log-error=/var/log/mariadb/mariadb.log //把这个注释 #pid-file=/var/run/mariadb/mariadb.pid //把这个注释 //此文件中不要有重复内容
//安装完mysql后创建一个SVN库 # create database svn charset=utf8;
安装svn,apache
//安装svn apache # yum -y install subversion httpd //安装svn的httpd扩展模块 # yum -y install mod_dav_svn // 安装php和相关扩展 # yum -y install php php-pear php-mbstring php-mysqlnd //安装pear库的svn操作扩展,出现下方表示成功 //install ok: channel://pear.php.net/XML_Parser-1.3.8 //install ok: channel://pear.php.net/VersionControl_SVN-0.3.4 # pear install VersionControl_SVN-0.3.4 // 设置apache开机启动 # systemctl enable httpd //创建存放仓库和配置文件的文件夹和文件并授权给apache # mkdir -p /var/svn/repos # mkdir -p /var/svn/conf # mkdir -p /var/svn/trash # touch /var/svn/conf/passwdfile # touch /var/svn/conf/accessfile # chown -R apache:apache /var/svn //配置apache //此文件默认不存在,自行编写 # vim /etc/httpd/conf.d/subversion.conf <Location /svn> DAV svn SVNParentPath /var/svn/repos SVNListParentPath On AuthType Basic AuthName "Authorization DTF SVN" AuthUserFile /var/svn/conf/passwdfile AuthzSVNAccessFile /var/svn/conf/accessfile Require valid-user </Location>
安装svnmanager
# wget https://sourceforge.net/projects/svnmanager/files/svnmanager/1.10/svnmanager-1.10.tar.gz # tar zxvf svnmanager-1.10.tar.gz # mv svnmanager-1.10 /var/www/html/svnmanager
配置svnmanager
//此文件默认不存在,可cpsvnmanager目录下config.php.linux进行修改,也可直接新建此文件进行编辑 # vim /var/www/html/svnmanager/config.php <?php $lang = "zh_CN.UTF-8"; $htpassword_cmd = "/usr/bin/htpasswd"; $svn_cmd = "/usr/bin/svn"; $svnadmin_cmd = "/usr/bin/svnadmin"; //Subversion locations $svn_config_dir="/var/svn/conf"; $svn_repos_loc = "/var/svn/repos"; $svn_passwd_file = "/var/svn/conf/passwdfile"; $svn_access_file = "/var/svn/conf/accessfile"; //If the following is set, removing a repository will cause it to be //moved to this location rather than being deleted. $svn_trash_loc = "/var/svn/trash"; //$svnserve_user_file = "/var/www/repos/svnserve_passwd_file"; $svnserve_user_file=""; //SMTP Server for outgoing mail $smtp_server = "smtp.mailserver.net"; $dsn = "mysqli://root:123456@localhost/svn"; #指定mysql连接地址 $admin_name = "admin"; #默认登录svnmanager用户,可修改 $admin_temp_password = "admin"; #默认登陆svnmanager密码,可修改 ?> //上面指定mysql连接地址的那行写自己的mysql的root和密码,如果想指定IP为连接地址的话,需要在mysql中对root用户进行远程连接授权,将其用户的localhost改为% # use mysql; # update user set host = '%' where host = 'localhost' and user = 'root';
# flush privileges;
重启mysql和启动apache
# systemctl restart mysqld # apachectl start # ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 80 [::]:3306 [::]:* LISTEN 0 128 [::]:80 [::]:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 100 [::1]:25 [::]:*
输入网址测试
# http://192.168.XX.XX/svnmanager/
登录使用admin用户和admin密码
配置完成
创建SVN存储目录
//创建SVN存储目录 # mkdir /svn //仓库中新建一个bbs目录 # svnadmin create /svn/bbs/ # ll /svn/bbs/ 总用量 8 drwxr-xr-x. 2 root root 54 4月 22 10:21 conf drwxr-sr-x. 6 root root 233 4月 22 10:21 db -r--r--r--. 1 root root 2 4月 22 10:21 format drwxr-xr-x. 2 root root 231 4月 22 10:21 hooks drwxr-xr-x. 2 root root 41 4月 22 10:21 locks -rw-r--r--. 1 root root 229 4月 22 10:21 README.txt //conf为配置这个仓库的配置文件,passwd设定访问这个仓库的用户与密码,authz为认证。 vim /svn/bbs/conf/passwd [users] # harry = harryssecret # sally = sallyssecret tanghulu = tanghulu123 //取消注释验证行,注意前面不能留空格 # vim /svn/bbs/conf/svnserve.conf ...... password-db = passwd ...... authz-db = authz
//加上权限 # vim /svn/bbs/conf/authz ...... [/] tanghulu=rw
客户端访问:
windows可以使用TortoiseSVN工具。安装这个工具后,右击鼠标
可以SVN Checkout
首先进行检出,检出的用户名和密码就是/svn/bbs/conf/passwd文件中的设置的用户和密码,然后即可登录到版本库浏览器进行文件的上传和下载等。