Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git—服务于apache的两个回购分支_Git_Apache_Git Branch - Fatal编程技术网

Git—服务于apache的两个回购分支

Git—服务于apache的两个回购分支,git,apache,git-branch,Git,Apache,Git Branch,我们有两个git回购分支机构(team1和team2)。我想在两个主机名或URL下通过apache为分支提供服务。目前,主URL为team1提供服务。我希望apache也为team2提供服务,这样他们也可以在服务器上检查更新。请告诉我如何配置它,以便对team2的更新应反映在不同的URL中。您需要在Apache中创建新的VirtualHost配置。它定义了将确定apache在何处搜索web文件的主机名 请参阅:至少在单分支部署中对我有效的一种方法: 以下示例使用Linux环境 将服务器上的裸Gi

我们有两个git回购分支机构(team1和team2)。我想在两个主机名或URL下通过apache为分支提供服务。目前,主URL为team1提供服务。我希望apache也为team2提供服务,这样他们也可以在服务器上检查更新。请告诉我如何配置它,以便对team2的更新应反映在不同的URL中。

您需要在Apache中创建新的VirtualHost配置。它定义了将确定apache在何处搜索web文件的主机名


请参阅:

至少在单分支部署中对我有效的一种方法:

以下示例使用Linux环境

将服务器上的裸Git存储库创建到不可访问www的位置(例如
/home/someuser/repo.Git
):

将服务器的repo添加到开发repo的远程:

$ git remote add production someuser@server:~/repo.git
然后创建一个
post receive
钩子(进入
home/someuser/repo.git/hooks
),用于检查推送的分支:

#!/bin/bash
# post-receive

# Read hook input params.
while read oldrev newrev refname; do
    # Get "simple" branch name from push data.
    branch=$(git rev-parse --symbolic --abbrev-ref $refname)

    if [ "team1" == "$branch" ]; then

        # team1 branch pushed.

    elif [ "team2" == "$branch" ]; then

        # team2 branch pushed.

    fi
done
然后在if-else中,您需要获取推送的内容,并将它们部署到某些目录中,这些目录具有分配给它们的不同虚拟主机。假设
team1
位于
/var/www/team1/html
中,
team2
位于
/var/www/team2/html

部署是通过更改服务器repo的git工作树位置并在那里获取更改来实现的。两个团队都应该做到以下几点:

#!/bin/bash
# post-receive

# Destinations to deploy repo contents to.
TEAM1_DEST="/var/www/team1/html"
TEAM2_DEST="/var/www/team2/html"

# Read hook input params.
while read oldrev newrev refname; do
    # Get "simple" branch name from push data.
    branch=$(git rev-parse --symbolic --abbrev-ref $refname)

    if [ "team1" == "$branch" ]; then

        # team1 branch pushed.
        GIT_WORK_TREE=$TEAM1_DEST git checkout -f team1

    elif [ "team2" == "$branch" ]; then

        # team2 branch pushed.
        GIT_WORK_TREE=$TEAM2_DEST git checkout -f team2

    fi
done
记住为
post receive
挂钩设置
chmod+x


我曾多次使用这种方法在推送上部署网站注意:上面的钩子尚未测试,但显示了原理。

很抱歉,这不是关于创建虚拟主机的问题。
#!/bin/bash
# post-receive

# Destinations to deploy repo contents to.
TEAM1_DEST="/var/www/team1/html"
TEAM2_DEST="/var/www/team2/html"

# Read hook input params.
while read oldrev newrev refname; do
    # Get "simple" branch name from push data.
    branch=$(git rev-parse --symbolic --abbrev-ref $refname)

    if [ "team1" == "$branch" ]; then

        # team1 branch pushed.
        GIT_WORK_TREE=$TEAM1_DEST git checkout -f team1

    elif [ "team2" == "$branch" ]; then

        # team2 branch pushed.
        GIT_WORK_TREE=$TEAM2_DEST git checkout -f team2

    fi
done