lilingjie2015 发表于 2018-9-4 11:38:55

利用apache+svn+jenkins+maven 实现java环境的自动化构建和部署(二)(网内首发超详细版)

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
  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
页: [1]
查看完整版本: 利用apache+svn+jenkins+maven 实现java环境的自动化构建和部署(二)(网内首发超详细版)