MacPorts Apache2 在启动时停止启动

发布于 2024-08-17 07:12:38 字数 2167 浏览 1 评论 0原文

我最近在两台不同的机器上注意到,通过 MacPorts 安装的 Apache2 在我启动时似乎已停止启动。诚实的事实是,我不能发誓它以前这样做过,但我想我会注意到这一点,因为安装 LaunchDaemon 是我安装过程的一部分。事实上,如果我尝试重新加载 LaunchDaemon,它会失败:

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
org.macports.apache2: Already loaded

除非我手动启动 Apache(使用 sudo apachectl restart),否则仅在进程列表中查找“apache2”或“httpd”产生以下内容:

$ sudo ps -ef | egrep "apache2|httpd"
    0    52     1   0   0:00.06 ??         0:00.08 /opt/local/bin/daemondo --label=apache2 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart ; --pid=none

1410639199 6960 6792 0 0:00.00 ttys001 0:00.00 egrep apache2|httpd

看起来守护进程本身已就位,但没有可执行文件。据我所知/可以告诉,相关的可执行文件(httpd 和 apachectl)是每个人都可以执行的。

还有其他人注意到这一点吗?有什么想法吗?

更新

按照下面的要求,我确实执行了launchctl list。该列表很长,我不知道如何剪切它,但足以说明没有列出任何 org.macports.* 项目。这本身很有趣,因为我的 MySQL 守护进程以相同的方式加载。它有效,但也没有出现在列表中。让我知道是否真的需要整个输出。

更新

我假设我已经在 sudo 下执行了launchctl list,但在下面 mipadi 的评论提示下,我再次尝试确保我这样做了,并且我假设不正确。在 sudo 下执行时,会出现 MacPorts 项目:

51  -   org.macports.mysql5
52  -   org.macports.apache2

我不确定这是否有帮助,但它仍然提供了更多信息。

更新

我在LaunchDaemons和环境变量中提出了一个不同但相关的问题。当我了解更多信息时,我将更新这两个问题。

更新

今天,根据邮件列表输入,我尝试使用通配符主目录。从学术上来说,它比我想要的更具包容性,但实际情况是我是唯一使用这台计算机的人;当然是唯一拥有 Apache 配置文件的人。

Include "/Users/*/Dropbox/Application Support/apache/conf.d.osx/*.conf"
Include "/Users/*/Library/Application Support/MacPorts/apache/conf.d/*.conf"

很遗憾...

httpd: Syntax error on line 512 of /opt/local/apache2/conf/httpd.conf: Wildcard patterns not allowed in Include /Users/*/Dropbox/Application Support/apache/conf.d.osx/*.conf

Something that I've noticed recently on two different machines is that Apache2 installed via MacPorts seems to have stopped launching when I boot up. The honest truth is that I can't swear it did so before, but it's something I think I'd notice because installing the LaunchDaemon is part of my install process. In fact, if I try to reload the LaunchDaemon, it fails:

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
org.macports.apache2: Already loaded

Unless I start Apache manually (using sudo apachectl restart), grep'ing for either "apache2" or "httpd" in my process list only produces this:

$ sudo ps -ef | egrep "apache2|httpd"
    0    52     1   0   0:00.06 ??         0:00.08 /opt/local/bin/daemondo --label=apache2 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart ; --pid=none

1410639199 6960 6792 0 0:00.00 ttys001 0:00.00 egrep apache2|httpd

Looks like the daemon itself is in place, but no executable. As far as I know/can tell, the relevant executables (httpd and apachectl) are executable by everyone.

Has anyone else noticed this? Any ideas?

UPDATE

As requested below, I did execute launchctl list. The list is long and I'm not sure how to snip it, but suffice to say that no org.macports.* items are listed. That in itself is interesting because my MySQL daemon is loaded the same way. It works, but also doesn't appear in the list. Let me know if the entire output is really needed.

UPDATE

I assumed that I had executed launchctl list under sudo, but prompted by mipadi's comment below, I tried again ensuring that I did so and I assumed incorrectly. When executed under sudo, the MacPorts items appear:

51  -   org.macports.mysql5
52  -   org.macports.apache2

I'm not sure whether that will help, but it's a little more info nonetheless.

UPDATE

I've asked a different, but related, question at LaunchDaemons and Environment Variables. I'll update both questions as I learn more.

UPDATE

Today, based on mailing list input, I tried using a wildcard home directory. Academically, it's a little more inclusive than I'd like, but the practical reality is that I'm the only one using this computer; certainly the only one who'd have Apache config files laying around.

Include "/Users/*/Dropbox/Application Support/apache/conf.d.osx/*.conf"
Include "/Users/*/Library/Application Support/MacPorts/apache/conf.d/*.conf"

Unfortunately...

httpd: Syntax error on line 512 of /opt/local/apache2/conf/httpd.conf: Wildcard patterns not allowed in Include /Users/*/Dropbox/Application Support/apache/conf.d.osx/*.conf

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

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

发布评论

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

评论(7

猫烠⑼条掵仅有一顆心 2024-08-24 07:12:38

我在这里找到了这个问题的答案:

https://trac.macports.org/ticket/36101

“显然,我在更改本地 dnsmasq 配置时修复了此问题。在 /etc/hosts 中,我将服务器名 (gala) 添加到环回条目中:

127.0.0.1 本地主机盛会

然后我更改了 /opt/local/apache2/conf/httpd.conf 中的 ServerName 以匹配:

服务器名称盛会

Apache 现在在我启动时启动。”

I found my answer to this problem here:

https://trac.macports.org/ticket/36101

"I apparently fixed this when changing my local dnsmasq config. In /etc/hosts I added my servername (gala) to the loopback entry:

127.0.0.1 localhost gala

and then I changed ServerName in /opt/local/apache2/conf/httpd.conf to match:

ServerName gala

Apache now starts at boot for me."

往日情怀 2024-08-24 07:12:38

既然我现在知道为什么 Apache 在启动时停止加载,我将阐明这个答案并将这个问题标记为已回答。 Apache 在启动时停止启动的原因是我试图跨系统共享 httpd.conf 文件。配置文件需要包含我的主目录中存在的目录中的文件。由于每台计算机上的主目录都不同,因此我尝试引用 ${HOME} 环境变量。

当机器启动后手动启动时,这可以正常工作,但启动时会失败,因为尚未设置环境变量。如上所述,请参阅此问题了解更多信息。

Since I now know why Apache has stopped loading on startup, I'm going to articulate that answer and mark this question as answered. The reason Apache has stopped launching on boot is that I'm trying to share an httpd.conf file across systems. The config file needs to Include files from directories that exist within my home directory. Since the home directory is different on each machine, I was trying to reference the ${HOME} environment variable.

This works fine when manually starting after the machine is booted, but fails on startup because the environment variable isn't yet set. As mentioned above, see this question for more information.

隔纱相望 2024-08-24 07:12:38

Rob:

  1. 有同样的问题:“sudo launchctl load -w ...”在我登录时启动了 Apache2,但在启动过程中不起作用(“-w”应该已经解决了这个问题)。另外,正如您所注意到的,守护进程似乎是使用 launchctl 注册的。它将显示“sudo launchctl list”,另一个“sudo launchctl load ...”将导致错误消息。

  2. 我玩了“sudo port load apache2”和“sudo port unload apache2”,但无法在重新启动时运行httpd。

  3. ,我去掉了MacPorts启动项:“sudo port unload apache2”,用“sudo launchctl list”检查org.macports.apache2不再注册启动。

  4. 之后,我按照 http://diymacserver.com > 上的步骤操作文件>虎>启动阿帕奇。我只需要将路径从 /usr/local/... 调整为 /opt/local/...

现在,MacPorts Apache2 每次重新启动都可以正常启动。

祝你好运,克劳斯

Rob:

  1. Had the same problem: "sudo launchctl load -w ..." started Apache2 while I was logged in, but did not work during startup (the "-w" should have taken care of that). Also, as you noticed, the daemon seems to be registered with launchctl. It will show up with "sudo launchctl list" and another "sudo launchctl load ..." will result in the error message.

  2. I played with "sudo port load apache2" and "sudo port unload apache2", but could not get httpd running on reboot.

  3. In the end, I got rid of the MacPorts startup item: "sudo port unload apache2", checked with "sudo launchctl list" that org.macports.apache2 is no longer registered for startup.

  4. Afterwards, I followed the steps on http://diymacserver.com > Docs > Tiger > Starting Apache. I only had to adapt the path from /usr/local/... to /opt/local/...

Now the MacPorts Apache2 is starting fine with every reboot.

Good luck, Klaus

旧城烟雨 2024-08-24 07:12:38

我发现我的 MacPorts apache2 由于 httpd.conf 中的“错误”而无法启动。

我正在使用

Listen 127.0.0.1:80
Listen 192.168.2.1:80
Listen 123.123.123.123:80 # Example IP, not the one I was really using

And in Console.app 我看到

4/8/12 4:59:06.208 PM org.macports.apache2: (49)Can't assign requested address: make_sock: could not bind to address 192.168.2.1:80
4/8/12 4:59:06.208 PM org.macports.apache2: no listening sockets available, shutting down
4/8/12 4:59:06.208 PM org.macports.apache2: Unable to open logs

我尝试调整所有日志文件夹的权限(尽管当我手动启动 apache2 时日志写得很好),但这没有帮助。

尽管 Apache Listen 文档 明确指出

多个监听指令可用于指定要监听的多个地址和端口。服务器将响应来自任何列出的地址和端口的请求。

我决定尝试切换回仅使用

Listen 80

这样做之后 apache2 启动时没有错误或警告。

I found that my MacPorts apache2 was not starting on boot because of an “error” in my httpd.conf.

I was using

Listen 127.0.0.1:80
Listen 192.168.2.1:80
Listen 123.123.123.123:80 # Example IP, not the one I was really using

And in Console.app I was seeing

4/8/12 4:59:06.208 PM org.macports.apache2: (49)Can't assign requested address: make_sock: could not bind to address 192.168.2.1:80
4/8/12 4:59:06.208 PM org.macports.apache2: no listening sockets available, shutting down
4/8/12 4:59:06.208 PM org.macports.apache2: Unable to open logs

I tried adjusting permissions on all the log folders (despite the fact that logs were being written just fine when I manually started apache2) and that didn't help.

Even though the Apache Documentation for Listen clearly states

Multiple Listen directives may be used to specify a number of addresses and ports to listen to. The server will respond to requests from any of the listed addresses and ports.

I decided to try switching back to just using

Listen 80

And after doing so apache2 is starting on boot with no errors or warnings.

想念有你 2024-08-24 07:12:38

如果您将 Subversion 与 Apache 结合使用,您可能会发现 Apache 未启动,因为 mod_dav_svn.so 文件已移至 /opt/local/libexec。您需要调整 Apache 启动文件以适应该文件的新位置。

If you're using Subversion with Apache, you may find that Apache is not starting because the mod_dav_svn.so file has moved to /opt/local/libexec. You'll need to adjust your Apache startup files to account for the new location of this file.

帅气尐潴 2024-08-24 07:12:38

在较新版本的 MacPorts 中,您可以运行 sudo port load apache2 来指示 MacPorts 处理 launchctl 设置并自动启动该进程。要停止该进程,请运行port unload

加载后检查 /opt/local/apache2/logs/error_log 是否有错误,包括配置问题。

In newer versions of MacPorts you can run sudo port load apache2 to instruct MacPorts to take care of the launchctl setup and automatically start the process. To stop the process run port unload.

After loading check /opt/local/apache2/logs/error_log for errors, including configuration issues.

缪败 2024-08-24 07:12:38

除了我的 之前的回答之外,我还发现有时 Apache 无法启动,因为系统的其他部分尚未准备好。

在一台 OS X Server 计算机上,我还使用 DNS 为该计算机创建一个“仅限内部”的 DNS 名称,并且该名称在我的 Apache 配置中使用。有时,当 Apache 尝试启动 DNS 服务器时,DNS 服务器尚未准备好,并且 Apache 由于主机名无效而无法加载。

我还在其他没有本地 DNS 的非服务器系统上看到过这种情况,而且 Apache 所需的其他东西还没有准备好。

有效的一件事是编辑位于 /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapperapache2.wrapper,MacPorts 的 < code>daemondo 用于启动 Apache。

编辑 Start() 函数以添加 sleep 命令,以便在启动 Apache 之前等待一段时间。

原始(我的机器上的第 14-17 行)

Start()
{
    [ -x /opt/local/apache2/bin/apachectl ] && /opt/local/apache2/bin/apachectl start > /dev/null
}

添加了等待时间

Start()
{
    [ -x /opt/local/apache2/bin/apachectl ] && sleep 10 && /opt/local/apache2/bin/apachectl start > /dev/null
}

In addition to my previous answer I have also found that sometimes Apache fails to start because something else with the system is not yet ready.

On one OS X Server machine I also use the DNS to create a “internal only” DNS name for the machine and that name is used in my Apache configuration. Sometimes when Apache tries to start the DNS server is not yet ready and Apache fails to load because the hostname isn’t valid.

I have also seen this on other non-Server systems without local DNS as well where something else required by Apache must not be ready yet.

One thing that has worked is to edit the apache2.wrapper located at /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper that MacPorts’ daemondo uses to start up Apache.

Edit the Start() function to add a sleep command to wait a bit before launching Apache.

Original (Lines 14-17 on my machine)

Start()
{
    [ -x /opt/local/apache2/bin/apachectl ] && /opt/local/apache2/bin/apachectl start > /dev/null
}

With wait time added

Start()
{
    [ -x /opt/local/apache2/bin/apachectl ] && sleep 10 && /opt/local/apache2/bin/apachectl start > /dev/null
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文