Git instaweb httpd配置在OSX Leopard服务器上使用apache2

时间:2009-10-02 10:20:10

标签: git macos configuration instaweb

默认情况下,git instaweb需要lighttpd Web服务器,而在OSX Leopard服务器上,apache2是默认服务器。

将以下内容添加到.git / config:

[instaweb]
local = true
httpd = apache2 -f
port = 4321
modulepath = /usr/libexec/apache2

并运行“git instaweb”会导致:

apache2 not found.  
Install apache2 or use --httpd to specify another httpd daemon.

如何设置.git/config以使其使用我的默认网络服务器?

由于

3 个答案:

答案 0 :(得分:3)

原因是apache2在OS X中被命名为httpd,而模块在其他地方。我尝试更改配置,使其指向正确的路径,但服务器仍无法正常工作。

或者,您可以使用已安装的webrick守护程序。将这些行添加到〜/ .gitconfig文件(全局设置)或.git / config文件(本地设置)中:

[instaweb]
               httpd = webrick

答案 1 :(得分:1)

如果你看一下这个git-instaweb patch from February 2009,你会看到:

# check if server can be executed
httpd_only="$(echo $httpd | cut -f1 -d' ')"
if ! type $httpd_only >/dev/null 2>&1; then
  echo >&2 "$httpd_only not found. Install $httpd_only or use" \
           + "--httpd to specify another httpd daemon."
fi

你的apache2可执行属性有问题吗?


2014年更新(5年后):commit like f8ee1f0表明git-instaweb不仅支持Apache,而且支持Apache 2.4:

  

检测可用的Apache MPM并根据以下优先顺序使用第一个:

  • mpm_event
  • mpm_prefork
  • mpm_worker

Thomas Okkenanswer(upvoted)详细说明了如何引用https来启动git-instaweb。

答案 2 :(得分:1)

我让git instaweb在我的Mac上运行内置的Apache(运行Lion),如下所示:

  1. 以root身份:
    cd /usr/sbin; ln -s httpd apache2
  2. 以root身份编辑 / usr / libexec / git-core / git-instaweb :在行
    LockFile "$fqgitdir/gitweb/$httpd_only/access.lock"
    User UsernameForYourGitServer
  3. 之后添加行
    PidFile "$fqgitdir/pid"
  4. 最后,作为您的git用户,cd到您的存储库,然后运行
    git instaweb --httpd apache2 -m /usr/libexec/apache2
  5. 当您已经使用标准服务器时,即使您拥有" Web Sharing"打开。 gitweb服务器将是一个单独的进程,侦听端口1234,而不是标准服务器使用的端口80。

    要使用launchd启动此服务器,请创建一个文件 /Library/LaunchDaemons/git-web.plist ,如下所示:

        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
            <key>Label</key>
            <string>GitWeb</string>
            <key>WorkingDirectory</key>
            <string>/Wherever/Your/Repository/Is</string>
            <key>ProgramArguments</key>
            <array>
                <string>git</string>
                <string>instaweb</string>
                <string>--httpd</string>
                <string>apache2</string>
                <string>-m</string>
                <string>/usr/libexec/apache2</string>
            </array>
            <key>KeepAlive</key>
            <true/>
        </dict>
        </plist>