Yum Build svn Apache use hooks to check out the Web directory for automatic synchronization

Source: Internet
Author: User
Tags svn client svn update fully qualified domain name tortoisesvn

Purpose: Build SVN on the server, and Apache, use the SVN hooks to make local modifications, synchronize to the Web directory, and use Yum to install.


One: Turn off SELinux, shut down the firewall, or open the relevant port.


[Email protected] python]# Vim/etc/selinux/config

[Email protected] python]# Cat/etc/selinux/config


# This file controls the state of the SELinux on the system.

# selinux= can take one of these three values:

# Enforcing-selinux security policy is enforced.

# Permissive-selinux Prints warnings instead of enforcing.

# disabled-no SELinux policy is loaded.

Selinux=disabled #修改为disabled, the other # comment out

# selinuxtype= can take one of these the values:

# targeted-targeted processes is protected,

# Mls-multi level Security protection.

#SELINUXTYPE =targeted


[Email protected] python]# setenforce 0 #使配置立即生效

[[Email protected] python]# service iptables stop #关闭防火墙, or open the relevant port,

Iptables: Set the chain to policy accept:filter [OK]

Iptables: Clear Firewall rule: [OK]

Iptables: Uninstalling module: [OK]


II: Install Apache,

Yum install httpd Apr apr-util httpd-devel #使用yum安装httpd服务

[Email protected] python]# chkconfig httpd on #设置为系统服务, powered on

[Email protected] python]# httpd-version #查看apache版本

Server version:apache/2.2.15 (Unix)

Server built:oct 16 2014 14:48:21

[Email protected] python]# service httpd restart #启动apache服务

Stop httpd: [Failed]

Starting httpd:httpd:Could not reliably determine the server's fully qualified domain name, using 202.106.199.36 for Serverna Me

Determine

ServerName www.example.com:80


[Email protected] python]# vi/etc/httpd/conf/httpd.conf #定位到ServerName www.example.com:80 to remove the previous #, Restart Apache will not appear could not reliably determine the server's fully qualified domain name, using 202.106.199.36 for servername this The problem.



[Email protected] python]# service httpd restart

Stop httpd: [OK]

Starting httpd: [OK]


Three: Install SVN

[email protected] python]# Yum install subversion #同样使用网络源yum


[[email protected] python]# svnserve--version #查看svn版本, see version information, SVN installation succeeded.

Svnserve, Version 1.6.11 (r934486)

Compiled in Feb 10 2015,22:08:22


Copyright (C) 2000-2009 CollabNet.

Four: Configure SVN,

  1. [Email protected] python]# mkdir-p/home/svn #先创建svn版本库目录,

  2. [Email protected] python]# svnadmin create/home/svn/project1 #创建svn版本库project1

    [Email protected] svn]# svnadmin create/home/svn/project2 #创建svn版本库project2

    [[email protected] svn]# ls

    Project1 Project2

  3. Config file


    [[email protected] svn]# mkdir-p/home/svn/conf   #创建配置文件目录

    [[email protected] svn]# cp/home/svn/project1/conf/passwd/home/svn/conf/passwd #拷贝账号密码 file template

    [[email protected] svn]# Cp/home/svn/project1/conf/authz/home/svn/conf/authz #拷贝目录权限样板

    [[email protected] svn]# cp/home/svn/project1/conf/svnserve.conf/home/svn/conf/ svnserve.conf #拷贝全局配置文件样板

  4. Edit three configuration files and add the following code

    [[email protected] svn]# vi/home/svn/conf/passwd #编辑, config file


    [Email protected] svn]# CAT/HOME/SVN/CONF/PASSWD

    # # # This file is a example password file for Svnserve.

    # # # Its format was similar to that of svnserve.conf. As shown in the

    # # # example below it contains one section labelled [Users].

    # # # The name and password for each user follow, one account per line.

    [Users]

    # Harry = Harryssecret

    # sally = Sallyssecret

    test1=123456

    test2=123456

[Email protected] svn]# Vim/home/svn/conf/authz



admin = Test


Project1 = Test1


Project2 = Test2




[/]


@admin = RW


* =


[project1:/]


@admin = RW


@project1 = RW


* =


[project2:/]


@admin = RW


@project2 = RW


* =

[[email protected] svn]# vim/home/svn/conf/svnserve.conf #编辑全局文件, add the following code to the last line


[General]

#禁止匿名访问, set to none. Default is read, parameter: Read,write,none

Anon-access=none

#授权用户写权限

Auth-access=write

#用户账号密码文件路径, the absolute path can be written

password-db=/home/svn/conf/passwd

#访问控制权限文件路径, the absolute path can be written

Authz-db=/home/svn/conf/authz

#每个SVN项目的认证命, will be displayed in the certification prompt, suggested to write the project name

Realm=svn

5. Start SVN

[Email protected] svn]# svnserve-d-r/home/svn--config-file/home/svn/conf/svnserve.conf--listen-port 3690 #启动sv N

[Email protected] svn]#

[Email protected] svn]# ps-ef|grep svn #查看进程

Root 2815 1 0 15:48? 00:00:00 svnserve-d-r/home/svn--config-file/home/svn/conf/svnserve.conf--listen-port 3690

Root 2817 2200 0 15:48 pts/0 00:00:00 grep sv N

[Email protected] svn]# netstat-ln |grep 3690 #查看端口

TCP 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN

[Email protected] svn]# killall svnserve #杀进程

V: Configure SVN to support Apache access

#创建用户, the user password should be the same as the user above

[Email protected] svn]# HTPASSWD-CM/HOME/SVN/CONF/HTTP_PASSWD test

[Email protected] svn]# htpasswd-c/home/svn/conf/http_passwd test1

[Email protected] svn]# htpasswd-c/home/svn/conf/http_passwd test2

Six: Adjustment of hooks


Edit Post-commit File "Hook script" #在项目库 hooks/directory

[Email protected] html]# cd/home/svn/project1/hooks/

[Email protected] hooks]# pwd

/home/svn/project1/hooks

[email protected] hooks]# cat Post-commit

#!/bin/bash

Svn=/usr/bin/svn

Web=/var/www/html

Export Lang=en_us. UTF-8

$SVN update--username test1--password ' 123456 ' $WEB


#其中SVN = change to the SVN command location on the right

web= right to your actual web directory

#让post-commit have permission to execute chmod 777 Post-commit (Must have)

The owner and the owner group that guarantee all the contents of the repository are Apache program users and groups.

[Email protected] hooks]# chmod 777 Post-commit

[email protected] hooks]# LL

Total Dosage 40

-rwxrwxrwx. 1 root root 124 July 16:04 Post-commit

-rw-r--r--. 1 root root 1977 July 15:24 Post-commit.tmpl

-rw-r--r--. 1 root root 1638 July 15:24 Post-lock.tmpl

-rw-r--r--. 1 root root 2289 July 15:24 Post-revprop-change.tmpl

-rw-r--r--. 1 root root 1567 July 15:24 Post-unlock.tmpl

-rw-r--r--. 1 root root 3426 July 15:24 Pre-commit.tmpl

-rw-r--r--. 1 root root 2410 July 15:24 Pre-lock.tmpl

-rw-r--r--. 1 root root 2786 July 15:24 Pre-revprop-change.tmpl

-rw-r--r--. 1 root root 2100 July 15:24 Pre-unlock.tmpl

-rw-r--r--. 1 root root 2780 July 15:24 Start-commit.tmpl

[Email protected] hooks]# chown apache:apache/home/svn-r

#还要让hooks下所有都有777

[Email protected] hooks]# chmod-r 777.

[email protected] hooks]# LL

Total Dosage 40

-rwxrwxrwx. 1 Apache Apache 124 July 16:04 Post-commit

-rwxrwxrwx. 1 Apache Apache 1977 July 15:24 Post-commit.tmpl

-rwxrwxrwx. 1 Apache Apache 1638 July 15:24 Post-lock.tmpl

-rwxrwxrwx. 1 Apache Apache 2289 July 15:24 Post-revprop-change.tmpl

-rwxrwxrwx. 1 Apache Apache 1567 July 15:24 Post-unlock.tmpl

-rwxrwxrwx. 1 Apache Apache 3426 July 15:24 Pre-commit.tmpl

-rwxrwxrwx. 1 Apache Apache 2410 July 15:24 Pre-lock.tmpl

-rwxrwxrwx. 1 Apache Apache 2786 July 15:24 Pre-revprop-change.tmpl

-rwxrwxrwx. 1 Apache Apache 2100 July 15:24 Pre-unlock.tmpl

-rwxrwxrwx. 1 Apache Apache 2780 July 15:24 Start-commit.tmpl

#导出项目至站点目录

[Email protected] hooks]# SVN checkout svn://192.168.0.142/project1/var/www/html/

SVN: Unable to connect to host "192.168.0.142": Deny connection

[Email protected] hooks]#

[Email protected] hooks]#

[Email protected] hooks]# svnserve-d-r/home/svn--config-file/home/svn/conf/svnserve.conf--listen-port 3690 #刚才 The kill process turns off SVN, starts SVN, and then checks out to the web directory/var/www/html

[Email protected] hooks]#

[Email protected] hooks]# svn checkout svn://192.168.0.142/project1/var/www/html/ #检出到web目录

Certification field: <svn://192.168.0.142:3690> SVN

Password for "root":

Certification field: <svn://192.168.0.142:3690> SVN

User name: test1

Password for "test1":


-----------------------------------------------------------------------

Attention! Your password, for the authentication domain:


<svn://192.168.0.142:3690> SVN


Can only be saved in plain text on disk! If possible, consider configuring your system so that Subversion

You can save the encrypted password. Please refer to the documentation for more information.

Save unencrypted password (yes/no)? Yes

Remove version 0.

[Email protected] hooks]#

#检出成功,

Test SVN.

Install SVN client tortoisesvn under Windows.

Tortoisesvn:http://tortoisesvn.net/downloads.html

1. Check out the SVN server Project1 to local, modify the index.html content,

2. The content of the webpage changes after the local modified file commint after accessing http://192.168.0.142. Success.

This article is from the IT Technology summary blog, so be sure to keep this source http://menglingqian.blog.51cto.com/8281087/1680611

Yum Build svn Apache use hooks to check out the Web directory for automatic synchronization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.