我必须如何配置 gitweb 和 gitolite 以便它们能够协同工作?

发布于 2024-12-01 20:43:07 字数 946 浏览 1 评论 0原文

我正在尝试让 gitweb 与 gitolite 一起工作...但到目前为止不成功。
我正在 RedHat Linux 机器上工作。存在一个名为 git 的用户。

gitolite 安装在:/home/git
存储库位置:/home/git/repositories

请注意,gitweb 可以与普通 git 一起正常工作。现在我正在尝试让它与 gitolite 一起工作。

我的文件如下所示:

  • /etc/gitweb.conf

    $projectroot = "/home/git/repositories";
    @git_base_url_list = qw(ssh://[MyHostName]/home/git/projects.list);
    $projects_list = "/home/git/projects.list"
    
  • /home/git/projects.list

    myrepo1.git
    myrepo2.git 
    
  • /home/git/.gitolite.rc

    $PROJECTS_LIST = $ENV{HOME} 。 “/projects.list”;
    $GL_GITCONFIG_KEYS = "gitweb.url receive.denyNonFastforwards receive.denyDeletes";
    

我错过了哪些配置? 我没有对 Apache 进行任何更改。

网址:http://MyHostName/git
这会出现 404 错误:未找到存储库

I am trying to make gitweb work with gitolite... but unsuccessful so far.
I am working on a RedHat Linux machine. A user called git exists.

gitolite is installed under: /home/git
Repository location: /home/git/repositories

Please note that, gitweb was working fine with plain vanilla git. Now i am trying to make it work with gitolite.

Here are what my files look like:

  • /etc/gitweb.conf

    $projectroot = "/home/git/repositories";
    @git_base_url_list = qw(ssh://[MyHostName]/home/git/projects.list);
    $projects_list = "/home/git/projects.list"
    
  • /home/git/projects.list

    myrepo1.git
    myrepo2.git 
    
  • /home/git/.gitolite.rc:

    $PROJECTS_LIST = $ENV{HOME} . "/projects.list";
    $GL_GITCONFIG_KEYS = "gitweb.url receive.denyNonFastforwards receive.denyDeletes";
    

What configuration have I missed?
I have not made any changes to Apache.

Web URL: http://MyHostName/git
This gives a 404 error saying - No repositories found.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

≈。彩虹 2024-12-08 20:43:07

我最近设置了 gitolite 和 gitweb,发现 /etc/gitweb.conf 需要非常很少的配置。你所拥有的对我来说看起来很合适。 /home/git/repositories 的权限是什么?您可能会发现它们限制太多。试试这个:

$ chmod -R 775 /home/git/repositories

这就是为我解决问题的方法(尽管我想有一种更安全的方法来设置权限)。如果可行,我建议您考虑一下为 Apache(或正在执行 gitweb 的任何用户帐户)提供对存储库目录的更细粒度的权限。

我的 .gitolite.rc 中也有这个:

GIT_CONFIG_KEYS => 'gitweb\.(owner|description|category)',

这样以下内容就可以在 /conf/gitolite.conf 中工作:

config gitweb.owner         =   owner name
config gitweb.description   =   some description
config gitweb.category      =   some category

I recently set up gitolite and gitweb and found that /etc/gitweb.conf required very little configuration. What you have looks right to me. What are the permissions like on /home/git/repositories? You may find they are too restrictive. Try this out:

$ chmod -R 775 /home/git/repositories

That's what solved the issue for me, (though I imagine there's a more secure way to set up the permissions). If that works, I'd recommend just having a look into giving Apache (or whatever user account gitweb is being executed under) more fine-grained permissions over the repositories directory.

I also have this in my .gitolite.rc:

GIT_CONFIG_KEYS => 'gitweb\.(owner|description|category)',

so that the following works in <gitolite-admin>/conf/gitolite.conf:

config gitweb.owner         =   owner name
config gitweb.description   =   some description
config gitweb.category      =   some category
紫南 2024-12-08 20:43:07

您需要添加 Gitolite contrib/gitweb.conf< /code>位于 /etc/gitweb_config.perl 末尾。
换句话说,您需要从 gitweb.conf perl 文件调用 Gitolite 函数,否则集成 GitWeb-Gitolite 将永远无法工作。

# check for (at least) "R" permission
    my ($perm, $creator) = &repo_rights($repo);
    return ($perm =~ /R/);

(这里 repo_rights 是来自 gitolite 的方法.pm

检查“帮助 gitweb"。

您需要在 gitweb_config.perl 末尾添加的最后几行是:

use lib (".");
require "gitweb.conf.pl";

这样,您将避免 /etc/gitweb.conf 中出现任何“500 - Internal Server Error 语法错误””错误消息。

如果您没有声明 gitweb.conf.plgitweb_config.perl,而是直接声明“gitweb.conf.pl” ,然后添加“use lib (".");”作为该文件的第一行。

You need to add the Gitolite contrib/gitweb.conf at the end of /etc/gitweb_config.perl.
In other words, you need to call a Gitolite function from your gitweb.conf perl file, otherwise the integration GitWeb-Gitolite will never work.

# check for (at least) "R" permission
    my ($perm, $creator) = &repo_rights($repo);
    return ($perm =~ /R/);

(here repo_rights is a method from gitolite.pm)

Check the section "helping with gitweb".

The last lines you need to add at then end of gitweb_config.perl are:

use lib (".");
require "gitweb.conf.pl";

That way, you will avoid any "500 - Internal Server Error syntax error at /etc/gitweb.conf" error message.

If you don't have a gitweb_config.perl in which you declare gitweb.conf.pl, but directly "gitweb.conf.pl", then add "use lib (".");" as the first line of that file.

夏尔 2024-12-08 20:43:07

1/安装gitolite并进行设置。然后,只需确保 /home/git/.gitolite.rc 包含未注释的部分,如下所示:

%RC = (
    ...
    UMASK                           =>  0027,
    ...
    ENABLE => [
        ...
        'gitweb',
        ...
     ]
);

2/正确设置 $projectroot$projects_list/etc/gitweb.conf 的 code> 指令(以匹配 projects.list 文件和 repositories 目录的位置)。类似:

$projectroot = "/home/git/repositories";
...
$projects_list = "/home/git/projects.list";

3/ 确保当前存储库文件也可由网络服务器用户读取。这些示例来自基于 debian 的系统,因此 YMMV:

sudo adduser www-data git                   # append `www-data` user to a `git` group
sudo chmod g+r /home/git/projects.list      # make sure group members can read the `project.list`
sudo chmod -R g+rx /home/git/repositories   # recursively set less restrictive access mode for group members
sudo /etc/init.d/apache2 restart            # restart web server to apply these changes

4/ 最后在 gitolite-admin< 的 /conf/gitolite.conf 文件中配置 gitweb 用户的访问权限/code> 客户端计算机上的存储库,并通过提交和推送它们(标准方式)来应用它们。我们希望通过 gitweb 查看和管理的存储库必须具有如下访问权限设置:

repo testing                                                                    
    RW+     = @all                                                              
    R       = gitweb  # add this line to make the repo browsable using `gitweb`

注意:... 仅表明文件中还有其他配置指令。不要把它们放在那里!

无需其他更改即可使 gitlab 可视化 gitolite 存储库。

(至少)适用于 gitolite 3.6.6 和 gitweb 2.1.4

1/ install gitolite and set it up. Then it suffices to make sure /home/git/.gitolite.rc contains uncommented parts that look like:

%RC = (
    ...
    UMASK                           =>  0027,
    ...
    ENABLE => [
        ...
        'gitweb',
        ...
     ]
);

2/ set correctly $projectroot and $projects_list directives of /etc/gitweb.conf (to match location of projects.list file and repositories dir). Like:

$projectroot = "/home/git/repositories";
...
$projects_list = "/home/git/projects.list";

3/ Make sure current repository files are also readable by webserver user. These examples are from debian based systems, so YMMV:

sudo adduser www-data git                   # append `www-data` user to a `git` group
sudo chmod g+r /home/git/projects.list      # make sure group members can read the `project.list`
sudo chmod -R g+rx /home/git/repositories   # recursively set less restrictive access mode for group members
sudo /etc/init.d/apache2 restart            # restart web server to apply these changes

4/ Finally configure access for gitweb user within your /conf/gitolite.conf file of gitolite-admin repository on a client machine and apply them by committing and pushing them (the standard way). A repository we would like to see and manage via gitweb has to have the access set like this:

repo testing                                                                    
    RW+     = @all                                                              
    R       = gitweb  # add this line to make the repo browsable using `gitweb`

Note: The ... only suggests there are other configuration directives within the files. Do not put them there!

No other chages are necessary to make gitlab visualize the gitolite repositories.

Applies (at least) for gitolite 3.6.6 and gitweb 2.1.4

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文