阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 6.5环境下安装SVN 整合Apache+SSL

124次阅读
没有评论

共计 6952 个字符,预计需要花费 18 分钟才能阅读完成。

终于在服务器上初步搭建起来了 SVN(版本 1.8)。

服务器系统:CentOS 6.5 64 位,搭建过程中全部采用源码编译安装(configure/make/make install),推荐大家使用编译安装。

源码安装需要先安装 gcc 来进行编译,如果没有编译环境就 yum -y install gcc  安装一下。

下载的源码都是最新的,没办法,有些软件的源码旧版本真的很难找,干脆就用当前最新的了。

个人习惯把软件都装在 /usr/local/      源码下载放到 /usr/local/src/  以下没有特殊指明均如此

按照步骤如下:

su root  直接 root 权限下操作

一、安装 Apr, Apr-util

cd /usr/local/src
wget -c  http://mirror.bit.edu.cn/apache//apr/apr-1.5.1.tar.gz
tar -zxvf apr-1.5.1.tar.gz
chown -R root:root apr-1.5.1
cd apr-1.5.1
./configure –prefix=/usr/local/apr
make && make install

接下来,

wget -c http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
chown -R root:root apr-util-1.5.4
cd apr-util-1.5.4
./configure –prefix=/usr/local/apu –with-apr=/usr/local/apr/
make && make install

好啦,验证一下吧

./apr/bin/apr-1-config –version
1.5.1
./apu/bin/apu-1-config –version
1.5.4

二、安装 openssl

wget -c http://www.openssl.org/source/openssl-1.0.1k.tar.gz

tar -zxvf openssl-1.0.1k.tar.gz

cd openssl-1.0.1k.tar.gz

./config –prefix=/usr/local/openssl -fPIC no-gost no-shared no-zlib

make && make install

三、安装 apache httpd server

wget -c http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.10.tar.gz

 tar -zxvf httpd-2.4.10.tar.gz
 
 cd httpd-2.4.10

 安装 httpd 其依赖比较多,有些参数可能是旧版本使用的 可以先 ./configure –help 查看一下
 
 有很多从网上查看的编译方法如下,可能会发生错误:configure: error: pcre-config for libpcre not found.
 ./configure –prefix=/usr/local/apache –with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apu/
 –enable-so –enable-dav –enable-maintainer-mode –enable-rewrite
 –enable-ssl –with-ssl=/usr/local/openssl
 
 所以还得安装 pcre(正则表达式函数库)
 直接到官网下载 我这里下载的版本是 8.36
 tar -zxvf pcre-8.36.tar.gz
 cd pcre-8.36
 mv pcre-8.36 /usr/local/pcre 直接拷到 /usr/local
 ./configure(编译使用 gcc+,没有就安装一下 yum -y install gcc-c++)
 make && make install

 安装好了,就重新编译 httpd 就 OK 了
 ./configure –prefix=/usr/local/apache –with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apu/
 –enable-so –enable-dav –enable-maintainer-mode –enable-rewrite
 –enable-ssl –with-ssl=/usr/local/openssl –with-pcre=/usr/local/pcre/pcre-config

然后就开始 make,make install(前面安装 openssl 时如果不加上 -fPIC 这里可能就会出错)。
有些人在这一步可能会出现问题:

exports.c:1653: error: redefinition of ‘ap_hack_apr_version_string’
exports.c:1022: error: previous definition of ‘ap_hack_apr_version_string’ was here
这个是./server/exports.c 这个文件中 出现很多 两个相同的常量  从 apr apu included 进来的 都是相同的,我选择了一个笨方法  把多出来的常量删掉再 make install,其实 ./configure 中有个参数 –with-included-apr 加上编译就 OK 了。

安装完毕,尝试启动 /usr/local/apache/bin/apachectl -k start
打开浏览器 输入 http://127.0.0.1
页面显示:It works!

四、安装 Zlib

wget -c http://zlib.net/zlib-1.2.8.tar.gz

tar -zxvf zlib-1.2.8.tar.gz

chown -R root:root zlib-1.2.8

mv zlib-1.2.8 zlib

mv zlib /usr/local/

cd /usr/local/zlib

./configure

make && make install

五、安装 Sqlite

wget -c http://www.sqlite.org/2014/sqlite-autoconf-3080704.tar.gz

tar -zxvf sqlite.autoconf-3080704.tar.gz

chown -R root:root sqlite.autoconf-3080704.tar.gz

mv sqlite.autoconf-3080704 sqlite

mv sqlite /usr/local

cd /usr/local/sqlite

./configure

make && make install

六、安装 Subversion1.8

wget -c http://mirrors.hust.edu.cn/apache/subversion/subversion-1.8.11.tar.gz

tar -zxvf subversion-1.8.11.tar.gz

cd subversion-1.8.11

mkdir -p ./sqlite-amalgamation  (在这里 把刚刚安装好的 sqlite 中的 sqlite3.c 文件拷贝到这)

cp /usr/local/sqlite/sqlite3.c ./sqlite-amalgamation/

./configure –prefix=/usr/local/subversion –with-apxs=/usr/local/apache/bin/apxs –with-apr=/usr/local/apr/
–with-apr-util=/usr/local/apu/ –with-zlib –enable-maintainer-mode

make && make instal
好啦,来验证一下吧
/usr/local/subversion/bin/svnserve –version
svnserve, version 1.8.11 (r1643975)
      compiled Jan 12 2015, 18:58:04 on x86_64-unknown-linux-gnu
.
.
.
看一下 /usr/local/subversion/libexec/ 目录下是否存在
 mod_authz_svn.so
 mod_dav_svn.so

七、Subversion 和 Apache 整合

(1)配置 Subversion

建立 SVN 版本库
mkdir -p /opt/svn/data/repos

/usr/local/subversion/bin/svnadmin create /opt/svn/data/repos

cd /usr/local/data

apache 默认情况下访问权限是 daemon, 所以相应地,

chown -R daemon /opt/svn/data/repos

接下来,生成访问控制文件
apache 提供了生成工具,可以直接使用 htpasswd 命令生成

/usr/local/apache/bin/htpasswd -c /opt/svn/data/repos/conf/passwd admin  (-c 新建文件)
/usr/local/apache/bin/htpasswd /opt/svn/data/repos/conf/passwd username

用户创建完,接下来编辑一下 authz (/opt/svn/data/repos/conf/authz) 里面也 有相应的模板例子
[groups](表示群组)
boss=admin        // 组名 = 用户, 用户, 用户……(逗号分隔)
boys=username
……
[repos:/]
@boss=rw
@boys=r
*=
具体怎么配置就自己去查阅资料啦。r 读 w 写

(2)配置 Apache

cd /usr/local/apache/

把 subversion 中的两个文件拷贝到./modules/
cp /usr/local/subversion/libexec/mod_authz_svn.so ./modules/

cp /usr/local/subversion/libexec/mod_dav_svn.so ./modules

接下来,编辑 httpd.conf

vi ./conf/httpd.conf

首先在 LoadModules 的末端,加上
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

然后在配置末尾加上
<Location /repos>
  DAV svn
  SVNParentPath /opt/svn/data/  #SVN 仓库的父目录
  SVNListParentPath On
  SVNAutoversioning On
  SVNReposName “repos”
  AuthzSVNAccessFile /opt/svn/data/repos/conf/authz  #前面生成的访问控制文件
  AuthType Basic
  AuthName “hello,welcome to my repos!”
  AuthUserFile /opt/svn/data/repos/conf/passwd  #用户文件
  Require valid-user
</Location>

到此整合完啦,重启一下 apache

./bin/apachectl -k restart

可以用浏览器打开 输入 http://127.0.0.1/repos 提示输入帐号 密码 进入。

八、配置 Https

(1)首先要生成证书私钥

cd /usr/local/apache/conf/  #直接在 conf 目录下存放

/usr/local/openssl/bin/openssl genrsa 1024 > server.key
输出提示:
Generating RSA private key, 1024 bit long modulus
…..++++++
……..++++++
e is 65537 (0x10001)
这样就生成好了 server.key 这个文件在 conf 中

(2)对凭证进行填写必要信息

/usr/local/openssl/bin/openssl req -new -key server.key > server.csr

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Guangdong
Locality Name (eg, city) []:Shenzhen
Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxxxx
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:xxxxxxx
Email Address []:xxxxxxx

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:xxxxxxx
An optional company name []:xxxxxxx

填好信息,生成 server.csr

(3)生成证书

/usr/local/openssl/bin/openssl req -x509 -days 1024 -key server.key -in server.csr > server.crt    #  -days 表示有效期

(4)编辑配置文件 httpd.conf  httpd-ssl.conf

vi httpd.conf 

将 #Include conf/extra/httpd-ssl.conf
前面的‘#’去掉
Include conf/extra/httpd-ssl.conf

vi ./extra/httpd-ssl.conf

加上
SSLCertificateFile “/usr/local/apache/conf/server.crt”
SSLCertificateKeyFile “/usr/local/apache/conf/server.key”

(5)强制要求通过 https 访问 /repos

在 httpd.conf 中
<Location /repos>
 SSLRequireSSL
  .
  .
  .
  .
  .
</Location

(6)

 重启 Apache,搞定。

————————————– 分割线 ————————————–

Linux 中 Subversion 配置实例 http://www.linuxidc.com/Linux/2012-02/53109.htm

CentOS 6.2 SVN 搭建 (YUM 安装) http://www.linuxidc.com/Linux/2013-10/91903.htm

CentOS 6.5 部署 Apache+SVN  http://www.linuxidc.com/Linux/2013-12/94315.htm

Apache+SVN 搭建 SVN 服务器 http://www.linuxidc.com/Linux/2013-03/81379.htm

Windows 下 SVN 服务器搭建和使用 + 客户端重新设置密码 http://www.linuxidc.com/Linux/2013-05/85189p5.htm

Ubuntu Server 12.04 安装 SVN 并迁移 Virtual SVN 数据 http://www.linuxidc.com/Linux/2013-05/84695.htm

Ubuntu Server 搭建 svn 服务以及迁移方法 http://www.linuxidc.com/Linux/2013-05/84693.htm

借助网盘搭建 SVN 服务器 http://www.linuxidc.com/Linux/2013-10/91271.htm

————————————– 分割线 ————————————–

更多 CentOS 相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计6952字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中