[四.    利用Ant构建和部署Java工程 Ant可以代替使用javac、java和jar等命令来执行java操作,从而达到轻松的构建和部署Java工程的目的。下面来看几个知识点。 1.

2.4 ssl方式部署apache

2.4.1安装apache

./configure --prefix=/usr/local/apache2 --enable-dav --enable-ssl--enable-so --enable-mods-shared=all
make && make install

2.4.2安装svn

安装apr-1.4.6.tar.gz、apr-util-1.5.1.tar.gz、neon-0.29.6.tar.gz同2.2章节部分

unzip sqlite-amalgamation-3071502.zip
tar -xzvf subversion-1.7.8.tar.gz
mv sqlite-amalgamation-3071502 ./subversion-1.7.8/sqlite-amalgamation
cd subversion-1.7.8
./configure --prefix=/usr/local/svn --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --without-berkeley-db --with-ssl
make && make install

注:环境变量等配置参考2.2章节部分

2.4.2 部署认证

通常系统已默认安装openssl,并且与之依赖的包很多,可不卸载直接编译安装;或就用系统默认版本

创建ssl所需要的证书

这里所有的文件都是创建在/usr/local/apache2/conf目录中,按照默认httpd-ssl.conf中认证文件设置路径

创建key文件:

openssl genrsa -des3 -out server.key 1024

执行完后应该在当前目录中有一个server.key文件

查看创建的key文件:(不是必须)
openssl rsa -noout -text -in server.key
创建pem文件:(不是必须)
openssl rsa -in server.key -out server.key.unsecure
创建scr文件:
openssl req -new -key server.key -out server.csr
执行完后应该在当前目录中有一个server.csr文件
创建crt文件:
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
执行完后应该在当前目录中有一个server.crt文件

2.4.3修改apache的ssl配置文件

修改httpd.conf

在文件中找到下面一行,把注释去掉

#Include conf/extra/httpd-ssl.conf
修改httpd-ssl.conf
在extra目录中,修改ssl的配置文件
找到SSLCertificateFile和SSLCertificateKeyFile的配置,修改文件路径到上面创建的目录,
启动apache
# /usr/local/apache2/bin/httpd -k restart
httpd not running, trying to start
Apache/2.2.19 mod_ssl/2.2.19 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide the pass phrases.
Server www.example.com:443 (RSA)
Enter pass phrase:
OK: Pass Phrase Dialog successful.

注意:这时应该要求你回答证书密钥,回答后即可启动,打开浏览器测试,这时候应该能以https访问你的站点了。

但这时,是所有的用户都可以访问你的https站点的,如果你希望只有认证的用户才能访问的话,请继续2.4.4的配置!

2.4.4 创建认证客户所需要的证书

创建用户的key文件:
openssl genrsa -des3 -out client.key 1024
创建用户的crt证书文件:
openssl req -new -x509 -days 3650 -key client.key -out client.crt
修改SSLCACertificateFile的文件路径
创建访问用户的csr文件:
openssl req -new -out pony.csr
创建访问用户的crt证书文件:
openssl x509 -req -in pony.csr -out pony.crt -signkey client.key -CA client.crt -CAkey client.key -CAcreateserial -days 3650
导出为pfx证书:(ie中只能导入pfx证书)
openssl pkcs12 -export -in pony.crt -inkey client.key -out pony.pfx
在你的测试机的ie中导入这个pfx证书
修改ssl配置文件:
在httpd-ssl.conf文件中找到SSLCACertificateFile的配置,然后修改文件路径为client.crt
把以下两行注释去掉:
SSLVerifyClient require
SSLVerifyDepth 10

重新启动apache,再次访问apache的时候,ie就会弹出窗口选择证书了。

注:以上并未做实际测试,只供参考。

3 Linux下svn独立服务器方式部署

3.1安装SVN

tar -xzvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
cd ..
tar -xzvf apr-util-1.5.1.tar.gz
cd apr-util-1.5.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
echo "/usr/local/apr/lib/" >> /etc/ld.so.conf
Ldconfig
cd ..
tar -xzvf neon-0.29.6.tar.gz
cd neon-0.29.6
./configure --prefix=/usr/local/neon
make && make install
echo "/usr/local/neon/lib" >> /etc/ld.so.conf
ldconfig

[ 前置条件:配置tomcat、maven、jdk的环境变量 本文以jenkins为例(hudosn是jenkins的前身,配置方式类似、需要自行安装) 将下载好的jenkins、hudson放入tomcat或者其

cd ..
unzip sqlite-amalgamation-3071502.zip
tar -xzvf subversion-1.7.8.tar.gz
mv sqlite-amalgamation-3071502 ./subversion-1.7.8/sqlite-amalgamation
cd subversion-1.7.8
./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --without-berkeley-db --with-ssl
make && make install
cd ..
cat >> /etc/profile <
PATH=$PATH:/usr/local/svn/bin/;export PATH
EOF
检测版本是否安装正确
#/usr/local/svn/bin/svnserve --version

3.2 配置环境

创建版本库存放目录

mkdir -p /data/svndata/
创建版本库
svnadmin create /data/svndata/apps
svnadmin create /data/svndata/aizhouyou
设置访问权限
groupadd svn
useradd -g svn -s /sbin/nologin svn
chown -R svn:svn /data/svndata (设置访问权限)
分别修改配置文件,多版本库环境下
例1:apps版本库
vim/data/svndata/apps/conf/svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = /usr/local/svn/conf/passwd.conf
authz-db = /usr/local/svn/conf/authz.conf
realm =apps
例2:aizhouyou版本库
vim/data/svndata/aizhouyou/conf/svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = /usr/local/svn/conf/passwd.conf
authz-db = /usr/local/svn/conf/authz.conf
realm =aizhouyou

注意:此信息中,包含了一些权限设置,以及SVN的用户名、密码验证配置相关信息。这里为了方便使用,我将password-db和authz-db都统一放到了svn里面,这样,让多个版本库可以共享同样的密码和验证信息。

接下来,直接来到/usr/local/svn,建立conf目录,并建立passwd.conf和authz.conf文件统一管理。

mkdir -p/usr/local/svn/conf
vim/usr/local/svn/conf/passwd.conf
[users]
#username = password
#username2 = password2
test = 123456
diaohongyong = 123456
chengxiaochao = 123456
zhengyongli = 123456
zhangran = 123456
xiaoyali = 12345

比较好理解, 除了个users标签,后面的每一行,对应访问SVN的用户名和密码,中间以等号隔开,保存后,直接退出。

我们再来看看authz.conf文件:

[groups]
#admin = username, username2
admin = diaohongyong,chengxiaochao
developers=diaohongyong,zhengyongli,zhangran,xiaoyali
[/]
@admin = rw
[apps:/]
@admin = rw
@developers =rw
test = rw
[aizhouyou:/]
@admin = rw
xiaoyali = rw
groups表示用户组,这里把username,username2都设置到一个叫admin的组里面

[/]表示根目录及以下,根目录是svnserve启动时指定的,我们指定为/data/svndata,[/]就是表示对全部版本库设置权限。[apps:/]表示fengwang版本库设置权限,[aizhouyou:/]表示aizhouyou版本库设置权限,@admin=rw表示admin组的所有用户,都有读写权限

[三.    Ant的常用任务 在Ant工具中每一个任务封装了具体要执行的功能,是Ant工具的基本执行单位。在本小节中,主要引导读者来看下Ant的常用任务及其使用举例。 1.