Centos 編譯安裝Apache subversion-1.9.7 + httpd 2.4.32
一、下載安裝Subversion必要的源碼文件
Apache
wget http://mirrors.shu.edu.cn/apache/httpd/httpd-2.4.32.tar.gz
Subversion
wget http://mirrors.hust.edu.cn/apache/subversion/subversion-1.9.7.tar.gz
apr源碼包
wget http://mirror.bit.edu.cn/apache//apr/apr-1.6.3.tar.gz
apr-util源碼包
wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
serf源碼包
wget http://mirrors.shu.edu.cn/apache/serf/serf-1.3.9.tar.bz2
scons源碼包
wget https://sourceforge.net/projects/scons/files/scons/2.5.1/scons-2.5.1.tar.gz
openssl源碼包
wget https://www.openssl.org/source/openssl-1.1.1-pre4.tar.gz
sqlite-amalgamation源碼包
wget http://www.sqlite.org/2018/sqlite-autoconf-3230000.tar.gz
二、安裝必要依賴
1、yum -y install zlib zlib-devel openssl openssl-devel python*
三、安裝apr
tar xvf apr-1.6.3.tar.gz cd apr-1.6.3 mkdir /usr/local/apr ./configure --prefix=/usr/local/apr make && make install
四、安裝apr-util
tar xvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 mkdir /usr/local/apr-util ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install
五、安裝scons
tar xvf scons-2.5.1.tar.gz cd scons-2.5.1 mkdir /usr/local/scons python setup.py install --prefix=/usr/local/scons
六、安裝serf
tar xvf serf-1.3.9.tar.bz2 cd serf-1.3.9 mkdir /usr/local/serf /usr/local/scons PREFIX=/usr/local/serf APR=/usr/local/apr APU=/usr/local/apr-util /usr/local/scons install cp /usr/local/serf/lib/libserf-1.so* /usr/local/lib/
七、安裝openssl
tar xvf openssl-1.1.1-pre4.tar.gz cd openssl-1.1.1-pre4 ./config --prefix=/usr/local/opensll-1.1.1 make && make install
八、安裝sqlite
tar xvf sqlite-autoconf-3230000.tar.gz cd sqlite-autoconf-3230000 ./configure --prefix=/usr/local/sqlite mkdir /usr/local/sqlite make -j `grep processor /proc/cpuinfo | wc -l` && make install
九、安裝httpd
useradd -r -d /app/website -s /sbin/nologin apache //app/website 表示網站的默認路徑 ,如果不指定的話,默認是/var/www/html tar xvf httpd-2.4.32.tar.gz cd httpd-2.4.32 ./configure --prefix=/usr/local/httpd-2.4.32 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-openssl=/usr/local/opensll-1.1.1 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util vim /usr/local/httpd-2.4.32/conf/httpd.conf //修改默認用戶及主頁 User apache Group apache LoadModule dav_module modules/mod_dav.so //取消此行註釋
十、安裝Subversion
tar -xvf subversion-1.9.7.tar.gz cd subversion-1.9.7 ./configure --prefix=/usr/local/subversion-1.9.7 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-zlib=/usr/local/zlib --with-serf=/usr/local/serf/ --enable-mod-activation --with-apache-libexecdir=/usr/local/httpd-2.4.32/modules/ make -j `grep processor /proc/cpuinfo | wc -l` && make install //根據CPU核心自動安排多線程編譯 echo "export PATH=/usr/local/subversion-1.9.7/bin:$PATH" >> /etc/profile source /etc/profile svn help
如果出現如下信息
svn: error while loading shared libraries: libserf-1.so.1: cannot open shared object file: No such file or director
cd /etc/ld.so.conf.d/ vi user-libs.conf 把我們拷貝serf的文件的目錄加上 /usr/local/serf/lib ldconfig
十一、創建svn倉庫
mkdir -p /data/repos svnadmin create /data/repos cd /data/repos
十二、目錄結構
總用量 24 drwxr-xr-x. 2 root root 4096 4月 3 17:59 conf drwxr-sr-x. 6 root root 4096 4月 3 17:32 db -r--r--r--. 1 root root 2 4月 3 17:32 format drwxr-xr-x. 2 root root 4096 4月 3 17:32 hooks drwxr-xr-x. 2 root root 4096 4月 3 17:32 locks -rw-r--r--. 1 root root 229 4月 3 17:32 README.txt
十三、啟動關閉svn服務
一臺機器可以啟動多個svn服務,需修改不同端口號。
svnserve -d -r /data/repos --listen-port 3690 ps -ef|grep svn netstat -ln|grep 3690 killall svnserve
十四、設置svn服務開機啟動
方法一:
修改/etc/rc.d/rc.local文件,添加如下命令
/usr/local/subversion-1.9.7/svn/bin/svnserve -d -r /data/repos --listen-port 3690
方法二:
在/etc/init.d/目錄下創建svn文件並設置權限755,代碼如下
#!/bin/bash # centos下可以用如下命令管理svn: service svn start(restart/stop) SVN_HOME=/data/repos if [ ! -f "/usr/local/subversion-1.9.7/svn/bin/svnserve" ] then echo "svnserver startup: cannot start" exit fi case "$1" in start) echo "Starting svnserve..." /usr/local/subversion-1.9.7/svn/bin/svnserve -d --listen-port 3690 -r $SVN_HOME echo "Finished!" ;; stop) echo "Stoping svnserve..." killall svnserve echo "Finished!" ;; restart) $0 stop $0 start ;; *) echo "Usage: svn { start | stop | restart } " exit 1 esac
十五、實現svn代碼倉庫與web線上同步
svn代碼倉庫目錄/data/repos/www1
web線上目錄/data/wwwroot/www1
1、首先checkout一份
svn co svn://192.168.1.254/www1 /data/wwwroot/www1
2、修改目錄權限
cd /data/repos/www1/hooks cp post-commit.tmpl post-commit vi post-commit
3、建立同步腳本
cd /data/repos/www1/hooks cp post-commit.tmpl post-commit vi post-commit
添加如下代碼
export.UTF-8 SVN=/usr/local/subversion-1.9.7/svn/bin WEB=/data/wwwroot/www1 $SVN update $WEB --username test --password 123456 chown -R 766 $WEB
chmod 755 post-commit
Centos 編譯安裝Apache subversion-1.9.7 + httpd 2.4.32