RHEL(AS4)上安装apache2.2.3 + svn1.4 + 自动邮件通知
OS: Redhat AS4.0
安装包情况如下: Desktops: X Windows System - 默认安装 GNOME Desktop Environment - 默认安装 KDE - 不安装 Applications: Editors - 默认安装 Engineering and Scientific - 不安装 Graphical Internet - 默认安装 testx-based Internet - 不安装 Office/Productivity - 不安装 Sound and Video - 不安装 Authoring and Publishing - 不安装 Graphics - 不安装 Games and Entertainment - 不安装 Servers: Server configuration Tools - 默认安装 Web server - 不安装 Mail Server - 不安装 Windows File Server - 不安装 DNS Name Server - 不安装 FTP server - 默认安装 PostgreSQL Database - 不安装 MySQL Database - 不安装 News Server - 不安装 Network Servers - 不安装 Legacy Network Server - 默认安装 Development: Development Tools - 默认安装 X Sofware Development - 默认安装 GNOME Software Development - 默认安装 KDE Software Development - 不安装 Legacy Software Development - 默认安装 System: Administrator Tools - 默认安装 System Tools - 默认安装 Printing Support - 不安装 Server IP: 192.168.10.100 1) 安装Apache Server 2) 安装SVN 3) 邮件通知脚本/修改log脚本/强制写log脚本 1. 安装Apache2.2.3 ,这里可以下载http://apache.justdn.org/httpd/httpd-2.2.3.tar.gz # service iptables stop //关闭linux防火墙 # wget http://apache.justdn.org/httpd/httpd-2.2.3.tar.gz //下载apache安装包 # chmod a+x httpd-2.2.3.tar.gz //添加可执行权限 # tar zxvf httpd-2.2.3.tar.gz //解压缩安装包 # cd httpd-2.2.3 //进入安装目录 # ./configure --enable-module=so --enable-dav --enable-dav-fs --enable-dav --enable-so --prefix=/usr/local/apache2 //--enable-module=so配置Apache支持Dynamic Shared Objects (DSO)模式,--enable-dav即添加mod_dav.so模块,--enable-dav-fs即添加mod_dav_fs.so模块,--prefix=/usr/local/apache2是所需要安装到的目录位置。 # make //进行编译 # make install //编译后进行安装 安装完毕,进行测试。 # vi /usr/local/apache2/conf/httpd.conf //修改apache配置文件 将ServerName 修改为ServerName:80 # cd /usr/local/apache2/bin //进入apache控制脚本目录 # ./apachectl start //启动apache 用IE打开http://192.168.10.100, 可以看到It works!说明apache已经可以正常工作了。 2. 安装SVN1.4.0 # wget http://www.iusesvn.com/bbs/download/subversion-1.4.0.tar.gz //下载subversion安装包 # chmod a+x subversion-1.4.0.tar.gz //添加可执行权限 # tar zxvf subversion-1.4.0.tar.gz //解压缩安装包 # cd subversion-1.4.0 //进行安装目录 # ./configure --prefix=/usr/local/subverion --with-apxs=/usr/local/apache2/bin/apxs //--with-apxs指定apxs的安装的目录,可以在安装过程中自动生成两个必要的模块文件mod_dav_svn.so和mod_authz_svn.so以及能够支持它们可以正常地工作。 # make # make install # mkdir /svnroot //创建SVN根目录svndata # svnadmin create --fs-type fsfs /svndata/test //在SVN根目录下创建一个名叫test的仓库,--fs-type为指定仓库的文件格式为fsfs # htpasswd -c -m /svndata/test/passwd windy //在/svnroot/test下创建用MD5方式加密的密码文件passwd,-c参数为create的意思,-m参数为以MD5加密方式 New password: xxxxxx Re-type new password: xxxxxx Adding password for user windy //添加成功 修改apache配置文件。 # vi /usr/local/apache2/conf/httpd.conf # Example: # LoadModule foo_module modules/mod_foo.so 在这下面检查这两行,一般会自动加入,如果没有则要手工加入 LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so 在末尾加上以下参数 <Location /svn> DAV svn SVNPath /svndata/test AuthType Basic AuthName "Windy's SVN" AuthUserFile /svndata/test/passwd Require valid-user </Location> # /usr/local/apache2/bin/apachectl restart //重启apache server *配置在linux下apache自动启动的标准脚本 # cd /etc/init.d # vi apache 加上以下脚本 #!/bin/sh # description: Apache auto start-stop script. # chkconfig: - 20 80 APACHE_HOME=/usr/local/apache2 APACHE_OWNER=root if [ ! -f "$APACHE_HOME/bin/apachectl" ] then echo "Apache startup: cannot start" exit fi case "$1" in 'start') su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl start" ;; 'stop') su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl stop" ;; 'restart') su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl restart" ;; esac # chmod 770 apache # chkconfig --add apache # ntsysv 在图象化界面中选种apache自动启动。 Ok,测试Apache # service apache start # service apache stop # service apache restart 测试SVN 用IE打开http://192.168.10.100/svn,输入用户名和密码,能看到以下信息,说明我们已经配置成功了。 Revision 0: / -------------------------------------------------------------------------------- Powered by Subversion version 1.4.0 (r21228). (关于权限文件,在这不做多讲。) 3. 配置邮件通知 安装Active Perl # wget http://downloads.activestate.com ... 4-gcc-267479.tar.gz # chmod a+x ActivePerl-5.8.8.819-i686-linux-glibc-2.2.4-gcc-267479.tar.gz # tar zxvf ActivePerl-5.8.8.819-i686-linux-glibc-2.2.4-gcc-267479.tar.gz # cd ActivePerl-5.8.8.819-i686-linux-glibc-2.2.4-gcc-267479 # ./install.sh Did you read the LICENSE.txt file? [no] yes Do you agree to the ActivePerl Community License v2.1? [no] yes Enter top level directory for install? [/opt/ActivePerl-5.8] /usr/local/ActivePerl Install HTML documentation [yes] Proceed? [yes] Installing ActivePerl... Copying files to /usr/local/ActivePerl...done Relocating...done (106 files relocated) Generating HTML documentation...Enter top level directory for install? [/opt/ActivePerl-5.8] /usr/local/ActivePerl done Syncing perl PPM database with .packlists...done ActivePerl has been successfully installed at /usr/local/ActivePerl. Please modify your startup environment by adding: /usr/local/ActivePerl/bin to PATH /usr/local/ActivePerl/man to MANPATH For general questions or comments about ActivePerl, please contact us at <support@ActiveState.com>. Thank you for using ActivePerl! //安装完成 安装Perl模块Module::Build # wget http://search.cpan.org/CPAN/auth ... Build-0.2805.tar.gz # chmod a+x Module-Build-0.2805.tar.gz # tar zxvf Module-Build-0.2805.tar.gz # cd Module-Build-0.2805 # perl Build.PL # ./Build # ./Build test # ./Build install //安装完成 安装Perl模块Authen::SASL (optional Perl module for SVN::Notify) # wget http://search.cpan.org/CPAN/auth ... en-SASL-2.10.tar.gz # chmod a+x Authen-SASL-2.10.tar.gz # tar zxvf Authen-SASL-2.10.tar.gz # cd Authen-SASL-2.10 # perl Makefile.pl ==> Auto-install the 1 optional module(s) from CPAN? [n] y ==> Auto-install the 1 optional module(s) from CPAN? [n] y //之后一路按回车 # make test # make install //安装完成 安装Perl模块Net::SMTP_auth (optional Perl module for SVN::Notify) # wget http://search.cpan.org/CPAN/auth ... TP_auth-0.08.tar.gz # chmod a+x Net-SMTP_auth-0.08.tar.gz # cd Net-SMTP_auth-0.08 # perl Makefile.pl # make test # make install //安装完成 安装Perl模块SVN::Notify (Perl module) # wget http://search.cpan.org/CPAN/auth ... -Notify-2.64.tar.gz # chmod a+x SVN-Notify-2.64.tar.gz # cd SVN-Notify-2.64 # perl Build.PL # ./Build # ./Build test # ./Build install //安装完成 *自动发邮件脚本 配置post-commit文件 //此文件在commit时会运用到这个脚本 # cd /svndata/test/hooks # cp post-commit.tmpl post-commit # vi post-commit 在末尾删除原来的,添加上以下参数 REPOS="$1" REV="$2" /usr/bin/svnnotify --repos-path "$1" --revision "$2" --to windy@xxx.com --handler "HTML::ColorDiff" --with-diff --smtp mail.xxx.com --subject-prefix '[Windy SVN]' //--to windy@xxx.com为要通知的邮件地址,我们一般会做个邮件组,这个组内包含了这个项目的所有人,--smtp mail.xxx.com为你的内部邮件服务器地址,必须使用域名,要内部DNS能够解析到,可能需要在内部DNS服务器上手动添加主机记录,[Windy SVN]必须有SVN字段,否则将收不到邮件,注重格式,此脚本有bugzilla和JIRA系统进行整合的参数。 # chmod a+x post-commit //添加可执行权限给post-commit *可修改log脚本 配置pre-revprop-change文件 //此文件在show log中修改log时会运用到这个脚本,得到修改的权限,否则会报错DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent. At least one property change failed; repository is unchanged # cd /svnroot/test/hooks # cp pre-revprop-change.tmpl pre-revprop-change # vi pre-revprop-change 在末尾删除原来的,添加上以下参数 EPOS="$1" REV="$2" USER="$3" PROPNAME="$4" if [ "$PROPNAME" = "svn:log" ]; then exit 0; fi exit 1 # chmod a+x pre-revprop-change //添加可执行权限给pre-revprop-change *强制写log脚本 配置pre-commit文件 //此文件在用户每次更新库中都必须要求写log,此文以log最低5个字符为例 # cd /svnroot/test/hooks # cp pre-commit.tmpl pre-commit # vi pre-commit 在末尾删除原来的,添加上以下参数 REPOS="$1" TXN="$2" SVNLOOK=/usr/bin/svnlook # check that logmessage contains at least 5 alphanumeric characters LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c` if [ "$LOGMSG" -lt 5 ]; then echo -e "\nEmpty log message not allowed. Commit aborted!" 1>&2 exit 1 fi //[ "$LOGMSG" -lt 5 ] -lt 5这个5是至少为5个字符,请注意。 # chmod a+x pre-commit //添加可执行权限给pre-commit OK,配置完毕。让我们使用TortoiseSVN来测试!随便修改一个文本文件,进行commit!之后windy@XXX.com邮件会收到以下图的邮件。 ![]() |



windymax
博客统计信息
热门文章
最新评论
友情链接
