1

我在 Ubuntu 10.04 服务器虚拟机(ESXi 4.1)上运行 Apache 2,得到了一些非常奇怪的东西:

有时会找到启用 mods 的目录。
有时不是。似乎没有大约 75% 没有找到。
两者之间没有任何改变。

以下是 error.log 中的一些摘录,结合命令行来演示正在发生的事情:

因此,我首先停止 Apache,以便更轻松地在日志中查找内容:

CMDLN: root@bunny:/etc/apache2# apache stop  
APWARN: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName  
ERRLOG: [Tue Feb 15 11:45:40 2011] [notice] caught SIGTERM, shutting down  

然后我开始它:

CMDLIN: root@bunny:/etc/apache2# apache start
APWARN: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
ERRLOG: [Tue Feb 15 11:46:09 2011] [notice] Apache/2.2.14 (Ubuntu) proxy_html/3.0.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

然后我重新启动它:

CMDLIN: root@bunny:/etc/apache2# apache restart
APWARN: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
ERRLOG: [Tue Feb 15 11:46:15 2011] [notice] SIGHUP received.  Attempting to restart

然后我将目录改回一个以测试它使用我的 shell 路径的理论

CMDLIN: root@bunny:/etc/apache2# cd ..
CMDLIN: root@bunny:/etc# apache restart
APWARN: apache2: Syntax error on line 33 of /etc/apache2/apache2.conf: Include directory 'mods-enabled' not found
ERRLOG: apache2: Syntax error on line 33 of /etc/apache2/apache2.conf: Include directory 'mods-enabled' not found

到目前为止看起来……有点……

CMDLIN: root@bunny:/etc# apache restart
APWARN: apache2: Syntax error on line 33 of /etc/apache2/apache2.conf: Include directory 'mods-enabled' not found

看起来还是这样,但这次没有日志错误。换回apache目录再试一次

CMDLIN: root@bunny:/etc# cd apache2/
CMDLIN: root@bunny:/etc/apache2# apache restart
APWARN: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
APWARN: httpd not running, trying to start
ERRLOG: [Tue Feb 15 11:46:30 2011] [warn] pid file /var/run/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
ERRLOG: [Tue Feb 15 11:46:30 2011] [notice] Apache/2.2.14 (Ubuntu) proxy_html/3.0.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

嗯,好像是这样吧?至于为什么……不知道……

除了那个 DNS 的东西之外,另一个 OK 重新启动......

CMDLIN: root@bunny:/etc/apache2# apache restart
APWARN: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
ERRLOG: [Tue Feb 15 11:46:36 2011] [notice] SIGHUP received.  Attempting to restart

到目前为止一切顺利......等等......糟糕,这显示在日志中,而我没有更改目录,而 Apache 正在尝试启动,而是关闭。

ERRLOG: apache2: Syntax error on line 33 of /etc/apache2/apache2.conf: Include directory 'mods-enabled' not found

我去重新启动它,然后...

CMDLIN: root@bunny:/etc/apache2# apache restart
APWARN: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
APWARN: httpd not running, trying to start
ERRLOG: [Tue Feb 15 11:46:45 2011] [warn] pid file /var/run/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
ERRLOG: [Tue Feb 15 11:46:45 2011] [notice] Apache/2.2.14 (Ubuntu) proxy_html/3.0.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

它已经备份了。我很困惑。

我不知道为什么会发生这种情况,而且应该这样做是没有意义的。我的直觉告诉我,它以某种方式没有走上正确的道路,并且出于某种原因期望启用 mod 与我所在的位置相关当 Apache 在运行过程中因同样的“错误”而自行关闭时

这是我的 httpd.conf:

<位置 ~ "/ws/?.*$">
    SetHandler perl 脚本
    PerlResponseHandler Webservices::Qmedtrix
</位置>

<目录/var/www>
    选项 +ExecCGI +包括
</目录>

<目录/usr/share>
    选项 ExecCGI FollowSymlinks 索引
</目录>

ProxyPass /group http://localhost:8080/group
ProxyPassReverse /group http://localhost:8080/group

这是我的 apache2.conf:

锁定文件 ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
超时 300
保持活动状态
MaxKeepAliveRequests 100
保持活动超时 15

启动服务器 2
MinSpareThreads 25
最大备用线程数 75
线程限制 64
每个孩子的线程数 25
最大客户数 150
MaxRequestsPerChild 0

用户 ${APACHE_RUN_USER}
组 ${APACHE_RUN_GROUP}

访问文件名 .htaccess

<文件 ~ "^\.ht">
    命令允许,拒绝
    拒绝一切
    满足所有
</文件>

DefaultType 文本/纯文本
主机名查找开启
错误日志 ${APACHE_LOG_DIR}/error.log

日志级别警告

包括 mods-enabled/*.load
包括 mods-enabled/*.conf

包括 httpd.conf
包括 ports.conf

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" 组合
LogFormat "%h %l %u %t \"%r\" %>s %O" 常见
LogFormat "%{Referer}i -> %U" 引用
LogFormat "%{User-agent}i" 代理

包括 conf.d/

包括启用站点/

这是我的默认虚拟域:

<虚拟主机 *:80>
    ServerAdmin webmaster@localhost
    DirectoryIndex index.shtml index.html

    文档根目录 /var/www
    <目录/>
        选项 FollowSymLinks
        AllowOverride 无
    </目录>
    <目录/var/www/>
        选项索引 FollowSymLinks 多视图 +包括 +ExecCGI
        AllowOverride 无
        命令允许,拒绝
        允许所有人
    </目录>

    错误日志 /var/log/apache2/error.log

    # 可能的值包括:调试、信息、通知、警告、错误、暴击、
    # 警报,出现。
    日志级别警告

    CustomLog /var/log/apache2/access.log 结合

</虚拟主机>

和我的 envars 文件:

#取消设置主页
# 我试过上面的行启用了,没有,没有区别。

如果 [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; 然后
        后缀="-${APACHE_CONFDIR##/etc/apache2-}"
别的
        后缀=
菲

导出 APACHE_RUN_USER=www-数据
导出 APACHE_RUN_GROUP=www-data
导出 APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid
导出 APACHE_RUN_DIR=/var/run/apache2$SUFFIX
导出 APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
导出 APACHE_LOG_DIR=/var/log/apache2$SUFFIX
导出 LANG=C
出口朗

我难住了。

有什么想法吗?

4

3 回答 3

3

我在 KVM 虚拟客户端上也遇到了完全相同的问题。我的解决方案是取消注释以下行:

#ServerRoot "/etc/apache2"

希望这可以帮助下一个开始想知道为什么他必须在“/etc/apache2”目录中运行“apache2ctl start”才能成功的人;)

于 2012-03-21T13:42:47.667 回答
0

您应该删除/etc/envvars文件中的行:

#unset HOME
# I have tried the above line enabled and not, no difference.

if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
        SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
        SUFFIX=
fi

删除所有这些。

然后还编辑您的 envvars 以删除您的 $suffix 以便您的最终文件看起来像这样:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2
export APACHE_LOCK_DIR=/var/lock/apache2
export APACHE_LOG_DIR=/var/log/apache2
export LANG=C
export LANG

我遇到和你一样的问题。并在使用环境变量后修复它。

于 2011-10-05T20:46:07.370 回答
0

apachectl 是一个 bash 脚本。您可能希望向 Ubuntu BTS 提交有关该行为的错误报告。

于 2011-04-15T21:25:53.683 回答