{"title": "CentOS\u642d\u5efaNginx+Subversion\u73af\u5883", "update_time": "2014-03-02 23:08:46", "tags": "svn nginx subversion", "pid": "282", "icon": "linux.png"}
因为某种原因我们需要用Nginx作为Subversion的http前端,但目前没有现成的Nginx+Subversion搭配方式。 而Subversion提供Apache的http处理模块。现在我们通过nginx反向代理给Apache的方式来实现Nginx+Subversion的组合方式。 ## 构建Apache+Subversion的环境 安装Apache ``` yum install -y httpd ``` 安装Subversion ``` yum install -y subversion ``` 安装Apache SVN模块 ``` yum install -y mod_dav_svn ``` 建立SVN库 ``` mkdir -p /home/svn/ cd /home/svn/ svnadmin create work chown -R apache.apache work ``` 添加Subversion账号 ``` htpasswd -c /home/svn/work/conf/passwdfile test ``` 修改/etc/httpd/conf.d/subversion.conf,内容如下 ``` LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
DAV svn SVNPath /home/svn/work AuthType Basic AuthName "Authorization Realm" AuthUserFile /home/svn/work/conf/passwdfile AuthzSVNAccessFile /home/svn/work/conf/authz Require valid-user
``` 启动httpd ``` /etc/init.d/httpd start ``` ## 使用Nginx反向代理 下载nginx ``` wget http://nginx.org/download/nginx-0.8.55.tar.gz tar -xzvf nginx-0.8.55.tar.gz cd nginx-0.8.55 ``` 添加nginx账号 ``` useradd -s /bin/false nginx ``` 编译安装nginx ``` ./configure --prefix=/opt/nginx-0.8.55 \ --with-http_stub_status_module \ --with-http_gzip_static_module make make install cd /opt && ln -sf nginx-0.8.55 nginx && cd - ``` 配置Nginx反向代理,修改/opt/nginx/conf/nginx.conf ``` server { listen 80; server_name svn.test.com; location /svn/work { proxy_pass http://127.0.0.1/svn/work; } location / { return 404; } } ``` 启动nginx ``` /opt/nginx/sbin/nginx ``` ## 最后 访问http://svn.test.com/svn/work 即访问svn库