系统环境:CentOS 6.6 x86_64
系统IP:172.16.6.100
1、关闭SELinux
[root@Legion100 ~]# sed -i 's/^SELINUX=.*/#&/;s/^SELINUXTYPE=.*/#&/;/SELINUX=.*/a SELINUX=disabled' /etc/sysconfig/selinux && /usr/sbin/setenforce 0
2、关闭防火墙
[root@Legion100 ~]# service iptables stop
3、配置编译环境
[root@Legion100 ~]# [ -f /etc/yum.repos.d/epel.repo ] && mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup [root@Legion100 ~]# [ -f /etc/yum.repos.d/epel-testing.repo ] && mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup [root@Legion100 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo [root@Legion100 ~]# yum clean all && yum makecache [root@Legion100 ~]# yum groupinstall "Development tools" "Server Platform Development" -y [root@Legion100 ~]# yum install apr-devel apr-util-devel apr-util-mysql apr-util-odbc apr-util-pgsql apr-util-sqlite \ compat-dapl compat-dapl-devel compat-dapl-static compat-dapl-utils compat-db compat-db42 compat-db43 \ compat-expat1 compat-gcc-34 compat-gcc-34-c++ compat-gcc-34-g77 compat-glibc compat-glibc-headers \ compat-libcap1 compat-libf2c-34 compat-libgfortran-41 compat-libstdc++-296 compat-libstdc++-33 \ compat-libtermcap compat-openldap compat-openmpi compat-openmpi-devel compat-openmpi-psm compat-openmpi-psm-devel \ compat-opensm-libs compat-readline5 compat-readline5-devel compat-readline5-static fontconfig-devel freetype-demos \ freetype-devel gd gtk+-devel kernel libX11-devel libXScrnSaver-devel libXau-devel libXaw-devel libXaw3dXft \ libXaw3dXft-devel libXcm libXcm-devel libXcomp libXcomp-devel libXcompext libXcompext-devel libXcomposite-devel \ libXcompshad libXcompshad-devel libXcursor-devel libXdamage-devel libXdmcp-devel libXevie libXevie-devel \ libXext-devel libXfixes-devel libXfont-devel libXft-devel libXi-devel libXinerama-devel libXmu-devel libXp \ libXp-devel libXpm-devel libXrandr-devel libXrender-devel libXres-devel libXt-devel libXtst-devel libXv-devel \ libXvMC-devel libXxf86dga-devel libXxf86misc-devel libXxf86vm-devel libcurl-devel libjpeg-turbo-devel \ libjpeg-turbo-static libpng-devel libpng-static libpng10 libpng10-devel libtiff-devel libtiff-static \ libtool-ltdl-devel libxml2-devel nasm nasm-doc nasm-rdoff ncurses-static ncurses-term pcre-devel \ php-common php-gd t1lib t1lib-apps t1lib-devel t1lib-static -y
4、删除系统中原有的svn及依赖包
[root@Legion100 ~]# yum remove apr apr-util subversion subversion-libs -y
5、下载编译SVN需要的依赖包
[root@Legion100 ~]# mkdir /tmp/src && cd /tmp/src [root@Legion100 ~]# echo "http://mirrors.aliyun.com/apache/apr/apr-1.5.2.tar.gz http://mirrors.aliyun.com/apache/apr/apr-util-1.5.4.tar.gz http://prdownloads.sourceforge.net/scons/scons-2.3.5.tar.gz http://www.openssl.org/source/openssl-1.0.1o.tar.gz http://fossies.org/linux/www/serf-1.3.8.tar.gz http://mirrors.dwhd.org/Apache/subversion/subversion-1.8.13.zip http://www.sqlite.org/snapshot/sqlite-amalgamation-201506201411.zip" > downloadlist [root@Legion100 ~]# wget -i downloadlist
6、安装SVN
[root@Legion100 /tmp/src]# tar xf apr-1.5.2.tar.gz [root@Legion100 /tmp/src]# cd apr-1.5.2 [root@Legion100 /tmp/src/apr-1.5.2]# ./configure --with-apr=/usr/local/apr/ [root@Legion100 /tmp/src/apr-1.5.2]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd ../ [root@Legion100 /tmp/src]# [root@Legion100 /tmp/src]# tar xf apr-util-1.5.4.tar.gz [root@Legion100 /tmp/src]# cd apr-util-1.5.4 [root@Legion100 /tmp/src/apr-util-1.5.4]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config [root@Legion100 /tmp/src/apr-util-1.5.4]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd ../ [root@Legion100 /tmp/src]# [root@Legion100 /tmp/src]# tar xf scons-2.3.5.tar.gz [root@Legion100 /tmp/src]# cd scons-2.3.5 [root@Legion100 /tmp/src/scons-2.3.5]# python setup.py install && cd .. [root@Legion100 /tmp/src]# [root@Legion100 /tmp/src]# tar xf openssl-1.0.1o.tar.gz [root@Legion100 /tmp/src]# cd openssl-1.0.1o [root@Legion100 /tmp/src/openssl-1.0.1o]# CFLAGS=-fPIC ./config --prefix=/usr/local/openssl enable-shared [root@Legion100 /tmp/src/openssl-1.0.1o]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd ../ [root@Legion100 /tmp/src]# echo "export PATH=/usr/local/openssl/bin:\$PATH" > /etc/profile.d/openssl.sh [root@Legion100 /tmp/src]# . /etc/profile.d/openssl.sh [root@Legion100 /tmp/src]# sed -i "$(awk '/^MANPATH[[:space:]]/{i=NR}END{print i}' /etc/man.config)a \MANPATH\tMANPATH /usr/local/openssl/ssl/man/" /etc/man.config [root@Legion100 /tmp/src]# which openssl /usr/local/openssl/bin/openssl [root@Legion100 /tmp/src]# ln -vs /usr/local/openssl/include/openssl /usr/include/openssl && cd .. "/usr/include/openssl/openssl" -> "/usr/local/openssl/include/openssl" [root@Legion100 /tmp/src]# [root@Legion100 /tmp/src]# tar xf serf-1.3.8.tar.gz [root@Legion100 /tmp/src]# cd serf-1.3.8 [root@Legion100 /tmp/src/serf-1.3.8]# scons PREFIX=/usr/local/serf APR=/usr/local/apr/bin/apr-1-config APU=/usr/local/apr/bin/apu-1-config OPENSSL=/usr/local/openssl [root@Legion100 /tmp/src/serf-1.3.8]# scons install [root@Legion100 /tmp/src/serf-1.3.8]# cp -a /usr/local/serf/lib/libserf-1.so* /usr/local/lib/ [root@Legion100 /tmp/src/serf-1.3.8]# scons -c [root@Legion100 /tmp/src/serf-1.3.8]# cd .. [root@Legion100 /tmp/src]# tar xf subversion-1.8.13.tar.gz [root@Legion100 /tmp/src]# cd subversion-1.8.13 [root@Legion100 /tmp/src/subversion-1.8.13]# mkdir sqlite-amalgamation [root@Legion100 /tmp/src/subversion-1.8.13]# cd .. [root@Legion100 /tmp/src]# unzip sqlite-amalgamation-201506201411.zip -d /tmp/src/subversion-1.8.13/sqlite-amalgamation/ #解压sqlite-amalgamation软件包到sqlite-amalgamation目录 Archive: sqlite-amalgamation-201506201411.zip inflating: /tmp/src/subversion-1.8.13/sqlite-amalgamation/sqlite3.c inflating: /tmp/src/subversion-1.8.13/sqlite-amalgamation/sqlite3.h inflating: /tmp/src/subversion-1.8.13/sqlite-amalgamation/sqlite3ext.h inflating: /tmp/src/subversion-1.8.13/sqlite-amalgamation/shell.c [root@Legion100 /tmp/src]# cd subversion-1.8.13 [root@Legion100 /tmp/src/subversion-1.8.13]# ./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr/bin/apr-1-config \ --with-apr-util=/usr/local/apr/bin/apu-1-config --with-serf=/usr/local/serf \ --with-openssl=/usr/local/openssl --enable-mod-activation [root@Legion100 /tmp/src/subversion-1.8.13]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd ../ [root@Legion100 /tmp/src]# echo "export PATH=\$PATH:/usr/local/svn/bin" > /etc/profile.d/svn.sh [root@Legion100 /tmp/src]# . /etc/profile.d/svn.sh [root@Legion100 /tmp/src]# sed -i "$(awk '/^MANPATH[[:space:]]/{i=NR}END{print i}' /etc/man.config)a \MANPATH\tMANPATH /usr/local/svn/share/man/" /etc/man.config [root@Legion100 /tmp/src]# which svn /usr/local/svn/bin/svn [root@Legion100 /tmp/src/subversion-1.8.13]# whereis libexpat.so.1 libexpat.so: /lib64/libexpat.so.1 /usr/lib64/libexpat.so.0 /usr/lib64/libexpat.so [root@Legion100 /tmp/src/subversion-1.8.13]# ls -l /lib64/libexpat.so.1 lrwxrwxrwx. 1 root root 17 5月 31 04:28 /lib64/libexpat.so.1 -> libexpat.so.1.5.2 [root@Legion100 /tmp/src/subversion-1.8.13]# ln -sv /lib64/libexpat.so.1.5.2 /usr/local/lib/libexpat.so.1 "/usr/local/lib/libexpat.so.1" -> "/lib64/libexpat.so.1.5.2" [root@Legion100 /tmp/src/subversion-1.8.13]# echo "/usr/local/lib/" >> /etc/ld.so.conf [root@Legion100 /tmp/src/subversion-1.8.13]# ldconfig [root@Legion100 /tmp/src/subversion-1.8.13]# svn help | head 用法: svn <subcommand> [options] [args] Subversion 命令行客户端,版本 1.8.13。 使用“svn help <subcommand>” 显示子命令的帮助信息。 使用“svn --version”查看程序的版本号和版本库访问模块,或者 使用“svn --version --quiet”只查看程序的版本号。 大多数的子命令可接受文件或目录参数,对目录进行递归处理。 如果没有指定参数,默认对当前目录(包含当前目录)递归处理。 可用的子命令: [root@Legion100 /tmp/src/subversion-1.8.13]# svn --version | head -2 svn,版本 1.8.13 (r1667537) 编译于 Jul 5 2015,01:32:57 在 x86_64-unknown-linux-gnu [root@Legion100 /tmp/src/subversion-1.8.13]# svnserve --version | head -2 svnserve,版本 1.8.13 (r1667537) 编译于 Jul 5 2015,01:32:57 在 x86_64-unknown-linux-gnu [root@Legion100 /tmp/src/subversion-1.8.13]#
7、配置svn
[root@Legion100 /tmp/src/subversion-1.8.13]# cd [root@Legion100 ~]# mkdir -p /home/svn [root@Legion100 ~]# svnadmin create /home/svn [root@Legion100 ~]# ls -l /home/svn 总用量 24 drwxr-xr-x 2 root root 4096 7月 5 01:51 conf drwxr-sr-x 6 root root 4096 7月 5 01:51 db -r--r--r-- 1 root root 2 7月 5 01:51 format drwxr-xr-x 2 root root 4096 7月 5 01:51 hooks drwxr-xr-x 2 root root 4096 7月 5 01:51 locks -rw-r--r-- 1 root root 246 7月 5 01:51 README.txt [root@Legion100 ~]# tree /home/svn /home/svn ├── conf │ ├── authz │ ├── hooks-env.tmpl │ ├── passwd │ └── svnserve.conf ├── db │ ├── current │ ├── format │ ├── fsfs.conf │ ├── fs-type │ ├── min-unpacked-rev │ ├── revprops │ │ └── 0 │ │ └── 0 │ ├── revs │ │ └── 0 │ │ └── 0 │ ├── transactions │ ├── txn-current │ ├── txn-current-lock │ ├── txn-protorevs │ ├── uuid │ └── write-lock ├── format ├── hooks │ ├── post-commit.tmpl │ ├── post-lock.tmpl │ ├── post-revprop-change.tmpl │ ├── post-unlock.tmpl │ ├── pre-commit.tmpl │ ├── pre-lock.tmpl │ ├── pre-revprop-change.tmpl │ ├── pre-unlock.tmpl │ └── start-commit.tmpl ├── locks │ ├── db.lock │ └── db-logs.lock └── README.txt 10 directories, 28 files [root@Legion100 ~]# #上面的命令执行完成之后,会自动建立svn库,在/home/svn文件夹含了conf,db,format,hooks,locks,README.txt等文件。
8、配置svn代码库
[root@Legion100 ~]# cd /home/svn/conf [root@Legion100 /home/svn/conf]# cat svnserve.conf | grep -Ev '^$|^#{2,}' #配置文件参考 [general] anon-access = read #禁止匿名访问,设置为none。默认为read,参数:read,write,none auth-access = write #授权用户写权限 password-db = passwd #用户账号密码文件路径,可以写绝对路径 authz-db = authz #访问控制权限文件路径,可以写绝对路径 # groups-db = groups realm = Legion #每个SVN项目的认证名,会在认证提示里显示,建议写项目名称。 # force-username-case = none # hooks-env = hooks-env [sasl] # use-sasl = true # min-encryption = 0 # max-encryption = 256 [root@Legion100 /home/svn/conf]#
[root@Legion100 /home/svn/conf]# cat passwd | grep -v '^#\|^$' #用户密码配置格式 [users] lookback = lookback Legion = lookback dwhd = lookback [root@Legion100 /home/svn/conf]# cat authz | grep -Ev '^#{2,}|^$|^# ' #配置权限控制文件,设置用户可以访问的目录格式 [aliases] [groups] admin = lookback users = Legion,dwhd [/] #路径设置是根(SVN的根) @admin = rw #管理组是读写权限 * = r #所有用户是读权限(只设置了管理组和普通用户,达到的效果就是普通组是读权限了) [root@Legion100 /home/svn/conf]#
9、测试启动svn
[root@Legion100 ~]# svnserve -d -r /home/svn --listen-port 3690
[root@Legion100 ~]# ss -tnl | grep 3690
LISTEN 0 7 *:3690 *:*
[root@Legion100 ~]# ps aux | grep 展开vn
root 62188 0.0 0.0 160820 852 ? Ss 02:07 0:00 svnserve -d -r /home/svn --listen-port 3690
[root@Legion100 ~]# killall svnserve
[root@Legion100 ~]# wget http://www.dwhd.org/script/svnserverinit.sh -O /etc/rc.d/init.d/svn
[root@Legion100 ~]# chmod +x /etc/rc.d/init.d/svn
[root@Legion100 ~]# chkconfig svn on
[root@Legion100 ~]# chkconfig --list svn
svn 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@Legion100 ~]#
启动脚本
#!/bin/bash ######################################################################### # File Name: svnserverinit.sh # Author: LookBack # Email: admin#dwhd.org # Version: # Created Time: 2015年07月05日 星期日 04时30分33秒 ######################################################################### # # svnserve Startup script for the Subversion svnserve daemon # # chkconfig: - 85 15 # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # description: The svnserve daemon allows access to Subversion repositories \ # using the svn network protocol. # processname: svnserve # config: /etc/sysconfig/svnserve # pidfile: /var/run/svnserve.pid # ### BEGIN INIT INFO # Provides: svnserve # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Short-Description: start and stop the svnserve daemon # Description: The svnserve daemon allows access to Subversion # repositories using the svn network protocol. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/svnserver/config ]; then . /etc/svnserver/config else mkdir $(dirname /etc/svnserver/config) touch /etc/svnserver/config cat > /etc/svnserver/config << EOF svn_port=3690 svn_home=/home/svn EOF . /etc/svnserver/config fi exec=/usr/local/svn/bin/svnserve prog=svnserve pidfile=${PIDFILE-/var/run/svnserve.pid} lockfile=${LOCKFILE-/var/lock/subsys/svnserve} args="--daemon --pid-file=${pidfile} $OPTIONS" #[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog lockfile=/var/lock/subsys/$prog start() { [ -x $exec ] || exit 5 [ -f $config ] || exit 6 if [ "$retval_pid" = "0" -a "$retval_port" = "0" ]; then echo -e "$prog ...... \033[32mRunning!\033[0m" else echo -n "Starting $prog ...... " if $exec -d -r $svn_home --listen-port $svn_port >/dev/null 2>&1; then echo -e "\033[32mSuccessfully!\033[0m" else echo -e "\033[31mError!\033[0m" fi fi return $retval } stop() { echo -n "Stopping $prog ...... " if [ "$retval_pid" = "0" -a "$retval_port" = "0" ]; then killall $prog >/dev/null 2>&1 retval=$? [ $retval -eq 0 ] && rm -f $lockfile && echo -e "\033[32mSuccessfully!\033[0m" || echo -e "\033[31mError!\033[0m" else echo -e "\033[31mNot Running!\033[0m" retval=$? fi return $retval } restart() { stop start } reload() { restart } force_reload() { restart } rh_status() { # run checks to determine if the service is running or use generic status pidNO=$(ps aux | pgrep $prog >/dev/null 2>&1) && retval_pid=$? portON=$(lsof -i :$svn_port >/dev/null 2>&1) && retval_port=$? echo -n "$prog ...... " if [ "$retval_pid" = "0" -a "$retval_port" = "0" ]; then echo -e "\033[32mRunning!\033[0m" else echo -e "\033[31mStopping!\033[0m" fi } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) #rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac exit $?
10、测试SVN
SVN Windows客户端下载
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏