CentOS搭建Nginx+Subversion环境

Apache Subversion(简称SVN,svn)

因为某种原因我们需要用Nginx作为Subversion的http前端,但目前没有现成的Nginx+Subversion搭配方式。
而Subversion提供Apache的http处理模块。现在我们通过nginx反向代理给Apache的方式来实现Nginx+Subversion的组合方式。

构建Apache+Subversion的环境:

[[email protected] ~]# yum install httd subversion mod_dav_svn -y
#mod_dav_svn是Apache的svn模块

建立SVN库:

[[email protected] ~]# mkdir -p /home/svn
[[email protected] ~]# cd /home/svn/
[[email protected] svn]# svnadmin create work
[[email protected] svn]# chown -R apache.apache work
[[email protected] svn]# tree work/
work/
├── conf
│   ├── authz
│   ├── passwd
│   └── svnserve.conf
├── db
│   ├── current
│   ├── format
│   ├── fsfs.conf
│   ├── fs-type
│   ├── min-unpacked-rev
│   ├── rep-cache.db
│   ├── revprops
│   │   └── 0
│   │       └── 0
│   ├── revs
│   │   └── 0
│   │       └── 0
│   ├── transactions
│   ├── txn-current
│   ├── txn-current-lock
│   ├── txn-protorevs
│   ├── uuid
│   └── write-lock
├── format
├── hooks
│   ├── post-commit.tmpl
│   ├── post-lock.tmpl
│   ├── post-revprop-change.tmpl
│   ├── post-unlock.tmpl
│   ├── pre-commit.tmpl
│   ├── pre-lock.tmpl
│   ├── pre-revprop-change.tmpl
│   ├── pre-unlock.tmpl
│   └── start-commit.tmpl
├── locks
│   ├── db.lock
│   └── db-logs.lock
└── README.txt

10 directories, 28 files

添加Subversion账号:

[[email protected] svn]# htpasswd -c /home/svn/work/conf/passwdfile visitor
New password: visitor#用户名和密码都设为visitor
Re-type new password:visitor
Adding password for user visitor

修改/etc/httpd/conf.d/subversion.conf,内容如下:

[[email protected] svn]# egrep -v "^#|^$" /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
<Location /svn/work>
	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
</Location>

修改Apache的端口:

[[email protected] svn]# grep "^Listen" /etc/httpd/conf/httpd.conf
Listen 81
[[email protected] svn]# service iptables stop && setenforce 0
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[[email protected] svn]# getenforce
Permissive
[[email protected] svn]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[[email protected] svn]# netstat -lnutp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1310/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1389/master
tcp        0      0 :::81                       :::*                        LISTEN      1632/httpd
tcp        0      0 :::22                       :::*                        LISTEN      1310/sshd
tcp        0      0 ::1:25                      :::*                        LISTEN      1389/master
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1143/dhclient

使用Nginx反向代理

[[email protected] src]# wget http://nginx.org/download/nginx-0.8.55.tar.gz
[[email protected] src]# pwd
/usr/local/src
[[email protected] src]# ls
nginx-0.8.55.tar.gz
[[email protected] nginx-0.8.55]# tar -xzvf nginx-0.8.55.tar.gz && cd nginx-0.8.55

添加nginx账号:

[[email protected] nginx-0.8.55]# useradd -s /bin/false nginx
/bin/false是最严格的禁止login选项,一切服务都不能用。
/sbin/nologin只是不允许login系统

安装依赖包:

[[email protected] nginx-0.8.55]# yum install gcc  pcre-devel openssl-devel  -y
[[email protected] nginx-0.8.55]# ./configure --prefix=/app/server/nginx-0.8.55 \ --with-http_stub_status_module \ --with-http_gzip_static_module
[[email protected] nginx-0.8.55]# make && make install
[[email protected] server]# ls
nginx-0.8.55
[[email protected] server]# ln -sf nginx-0.8.55/ nginx && cd -
[[email protected] nginx-0.8.55]# ll /app/server/
total 4
lrwxrwxrwx. 1 root root   13 Jul 25 09:36 nginx -> nginx-0.8.55/
drwxr-xr-x. 6 root root 4096 Jul 25 09:35 nginx-0.8.55

配置Nginx反向代理,修改/opt/nginx/conf/nginx.conf:

server {
    listen       80;
    server_name localhost ;

    location /svn/work {
        proxy_pass  http://127.0.0.1:81/svn/work;
    }

    location / {
        return 404;
    }
}

配置SNV:

[[email protected] conf]# pwd
/home/svn/work/conf
[[email protected] conf]# egrep -v "^$|^#" svnserve.conf
[general]
anon-access = read
auth-access = write
password-db = /home/svn/work/conf/passwd
authz-db = /home/svn/work/conf/authz
[[email protected] conf]# which svnserve
/usr/bin/svnserve
[[email protected] conf]# /usr/bin/svnserve -d -r /home/svn
[[email protected] conf]# netstat -lnutp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      4806/svnserve
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1744/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1389/master
tcp        0      0 :::81                       :::*                        LISTEN      1632/httpd
tcp        0      0 :::22                       :::*                        LISTEN      1744/sshd
tcp        0      0 ::1:25                      :::*                        LISTEN      1389/master
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1143/dhclient
[[email protected] conf]# /app/server/nginx/sbin/nginx
[[email protected] conf]# netstat -lnutp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      4806/svnserve
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      4809/nginx
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1744/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1389/master
tcp        0      0 :::81                       :::*                        LISTEN      1632/httpd
tcp        0      0 :::22                       :::*                        LISTEN      1744/sshd
tcp        0      0 ::1:25                      :::*                        LISTEN      1389/master
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1143/dhclient
[[email protected] work]# cat /home/svn/work/conf/authz
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the ‘$authenticated‘ token,
###  - only anonymous users, using the ‘$anonymous‘ token,
###  - anyone, using the ‘*‘ wildcard.
###
### A match can be inverted by prefixing the rule with ‘~‘. Rules can
### grant read (‘r‘) access, read-write (‘rw‘) access, or no access
### (‘‘).

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =
[/]
test=r
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
时间: 2024-10-14 00:55:34

CentOS搭建Nginx+Subversion环境的相关文章

搭建Nginx+JAVA环境

搭建Nginx+JAVA环境 Apache对Java的支持很灵活,他们的结合度也很高,例如Apache+Tomcat和Apache+resin等都可以实现对Java应用的支持.Apache一般采用一个内置模块来和Java应用服务器打交道.与Apache相比,Nginx在配合Java应用服务器方面,耦合度很低,它只能通过自身的反向代理功能来实现与Java应用服务器的支持,这恰恰是Nginx的一个优点,耦合度的降低,可以使Nginx与Java服务器的相互影响降到最低. 接下来通过Nginx+Tomc

【svn】Centos搭建svn服务器环境

1.需求描述 在Centos系统中搭建svn服务器环境 2.搭建过程 2.1 yum安装svn [[email protected] /]# yum install svn 2.2 新建目录存储svn目录 [[email protected] /]# mkdir /usr/svn 2.3 新建测试仓库pro [[email protected] /]# svnadmin create /usr/svn/pro 进入到目录/usr/svn/pro展开目录 说明: hooks目录:放置hook脚步文

Centos 搭建java运行环境

 linux 搭建java运行环境 [本文档所介绍的内容适用于公司测试/生产等常见的java环境部署] 一:环境部署前准备: 1.1相关软件以及系统 系统要求:Centos 6.0(以上) (64位) 相关中间件:jdk1.7.0_71,  apache-tomcat7.0 1.2下载jdk和tomcat等相关软件 下载jdk(版本为jdk1.7.0_71) wget --no-check-certificate --no-cookies --header "Cookie: oraclelice

PHP-Windows下搭建Nginx+PHP环境

项目中光用Nginx了, 由于有运维人员, 很少搭建Nginx服务器, 开发也就用用Apache, 搭过几次Nginx也忘的快, 每次都去翻别人博客, 今天重搭特此记录, 装前最好了解下FastCGI(点我去学习) 1.首先需要准备的应用程序包. nginx:nginx/Windows-1.7.6 (点我去官网选版本) php:php-5.3.29-nts-Win32-VC9-x86.zip (点我去官网选版本)(nginx下php是以FastCGI的方式运行,所以我们下载非线程安全也就是nts

腾讯云CentOS搭建JavaWeb运行环境(简易版)

腾讯云上购买的服务器快到期了,最后用来记录下怎么搭建JavaWeb运行环境. 在腾讯云上购买云主机后,进入云主机-控制台,会看到以下界面 点击更多,重装系统 弹出以下界面,选择服务市场-->基础镜像,选择你所需要的环境(如果购买的时候已选好环境可以略过..),我这里选的是Java多版本环境(Tomcat JDK MySql). 选完后输入密码,然后点击开始重装 系统开始重装,等待系统重装完毕. 重装成功后,登录云主机去查看配置的环境,这里推荐两个软件 WinSCP PuTTY 用WinSCP跟云

CentOS下搭建nginx+php环境

一.下载安装nginx 参见 http://www.cnblogs.com/kreo/p/4378086.html 不再赘述 二.下载php #下载 wget http://bg2.php.net/distributions/php-5.6.7.tar.gz #解压 tar zxvf php-5.6.7.tar.gz #编译 ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=

centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)

第一部分LNMP环境搭建 一.编译安装nginx1.10.3 1.准备 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [[email protected] ~]# uname -a Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_6

CentOS搭建python开发环境

装了个CentOS 5.5,想在上面搭个python的开发环境,可是还是遇到了很多问题,记录一下过程: 1.python升级 查看python版本 python -V Python 2.4.3 因为python3的变化很大,还是希望用新的版本,goole了一把,看到有一个指导贴: cd /usr/local/src wget http://www.python.org/ftp/python/3.2/Python-3.2a1.tgz --14:51:31-- http://www.python.o

搭建Nginx+Java环境测试并且运行

一.简介: Tomcat在高并发环境下处理动态请求时性能很低,而在处理静态页面更加脆弱.虽然Tomcat的最新版本支持epoll,但是通过Nginx来处理静态页面要比通过Tomcat处理在性能方面好很多. 二.下载安装: 下载nginx http://nginx.org/en/download.html 下载解压后放到F:\nginx-1.7.1(官网这样要求的,不知道放其它盘有没有问题) 启动nginx.exe,然后在浏览器输入127.0.0.1即可 配置自己的项目测试 第二环节我们使用了默认