【问题标题】:Gitweb - 404 - No projects foundGitweb - 404 - 未找到项目
【发布时间】:2017-01-09 15:59:18
【问题描述】:

我有一个带有 Centos 7 的 DigitalOcean droplet,但在我的 droplet 上看不到我的存储库。

我有一个用户 git,在相应的主文件夹中我有文件夹“项目”:/home/git/projects

在该文件夹内是一个测试存储库,初始化为:git init --bare

这是我的gitweb.conf

$projectroot = "/home/git/projects";
$git_temp = "/tmp";
$home_link = $my_uri || "/";
$home_text = "indextext.html";
$projects_list = $projectroot;

这里是我的可用站点文件:

server {
        listen       80;
        server_name  git.apselom.com;

        access_log /var/log/nginx/git.apselom.com.access_log main;
        error_log /var/log/nginx/git.apselom.com.error_log info;

        location /gitweb.cgi {
                root /var/www/git/;
                include fastcgi_params;
                gzip off;
                fastcgi_param SCRIPT_NAME $uri;
                fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
        }
    location / {
                root /var/www/git/;
                index gitweb.cgi;
        }
}

有了这些,我只得到错误:404 - No projects found。

【问题讨论】:

  • 不要将我们链接到图像。相反,请告诉我们您收到 404 错误。

标签: git centos7 gitweb


【解决方案1】:

我怀疑问题是您的 Web 服务器正在运行的用户无法访问您的 git 存储库。

奇怪的是,您说您使用的是 CentOS 7,但 CentOS 7 附带 Apache httpd,而您的配置看起来像 Lighttpd。 CentOS 的gitweb 软件包附带一个 Apache 配置文件,因此使用它基本上是:

  • 安装软件包:

    yum install gitweb httpd
    
  • 创建您的git 用户并确保apache 用户能够访问内容:

    # useradd -c 'git user' git
    # usermod -a -G git apache
    # su - git <<EOF
    mkdir projects
    git init --bare projects/project1
    git init --bare projects/project2
    EOF
    # chmod -R g+rwX /home/git
    
  • 编辑/etc/gitweb.conf 指向项目目录:

    our $projectroot = "/home/git/projects";
    
  • 启动网络服务器:

     systemctl enable httpd
     systemctl start httpd
    

你很高兴:

$ links http://localhost/git/
[...]
   Project            Description             Owner   Last Change                                  
   project1 Unnamed repository; edit this... git user No commits  summary | shortlog | log |       
                                                                  tree                             
   project2 Unnamed repository; edit this... git user No commits  summary | shortlog | log |       
                                                                  tree                             

不过,关键部分是确保您的 Web 服务器对您的 /home/git 目录具有适当的权限。如果您没有使用 Apache,请找出您的 Web 服务器正在使用的用户,然后在上面替换它。

【讨论】:

    【解决方案2】:

    你可以很容易的将apache加入到git的组中。

    usermod -a -G git apache
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      • 2017-10-08
      • 1970-01-01
      相关资源
      最近更新 更多