虚拟机上的 Apache 2 *有时*找不到启用 mods 的目录

发布于 2024-10-17 19:55:44 字数 6424 浏览 8 评论 0原文

我在 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 之外再次正常重启...

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

而且它是备份。我很困惑。

我不知道为什么会发生这种情况,而且这样做也是没有意义的。我的直觉告诉我,它不知何故没有找到正确的路径,并且由于某种原因期望启用 mods 与我在 shell 中的位置相关......而这本身就会一直很毛茸茸,当 Apache 在运行过程中因同样的“错误”而关闭时,情况变得更糟

这是我的 httpd.conf:

<Location ~ "/ws/?.*$">
    SetHandler perl-script
    PerlResponseHandler Webservices::Qmedtrix
</Location>

<Directory /var/www>
    Options +ExecCGI +Includes
</Directory>

<Directory /usr/share>
    Options ExecCGI FollowSymlinks Indexes
</Directory>

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

这是我的 apache2.conf:

LockFile ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15

StartServers          2
MinSpareThreads      25
MaxSpareThreads      75
ThreadLimit          64
ThreadsPerChild      25
MaxClients          150
MaxRequestsPerChild   0

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

AccessFileName .htaccess

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

DefaultType text/plain
HostnameLookups On
ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

Include mods-enabled/*.load
Include mods-enabled/*.conf

Include httpd.conf
Include 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\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Include conf.d/

Include sites-enabled/

这是我的默认虚拟域:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DirectoryIndex index.shtml index.html

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews +Includes +ExecCGI
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

</VirtualHost>

和我的 envars 文件:

#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

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

我'我难住了。

有什么想法吗?

I'm running Apache 2 on an Ubuntu 10.04 server VM (ESXi 4.1) and getting something very weird:

Sometimes the mods-enabled directory is found.
Sometimes it's not. It seems to not be about 75% not found.
Nothing is changed in between.

Here's some excerpts from the error.log combined with command lines to demonstrate what's going on:

So I start out by stopping Apache to make it easier to find stuff in the log:

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  

Then I start it:

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

Then I restart it:

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

Then I change directories back one to test the theory it's using my shell path

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

Looks like it so far... kinda..

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

Still looks like it, but no log error this time. Change back to the apache directory and try it again

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

Hmm, looks like that was it, right? As to why... no idea...

Another OK restart except for that DNS thing...

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

So far so good... wait... Oops, this shows up in the log while I haven't changed directories, while Apache is trying to start, but instead shuts down.

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

I go to restart it and...

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

And it's back up. And I am bewildered.

I have no idea why this is happening, and it doesn't make sense it should be doing this. My instinct was telling me it was somehow not getting the right path and expecting mods-enabled for some reason to be relative to where I was, in my shell... and while that in and of itself would have been hairy, it got worse when Apache shut itself down right in the middle of running for this same "error"

Here's my httpd.conf:

<Location ~ "/ws/?.*$">
    SetHandler perl-script
    PerlResponseHandler Webservices::Qmedtrix
</Location>

<Directory /var/www>
    Options +ExecCGI +Includes
</Directory>

<Directory /usr/share>
    Options ExecCGI FollowSymlinks Indexes
</Directory>

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

Here's my apache2.conf:

LockFile ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15

StartServers          2
MinSpareThreads      25
MaxSpareThreads      75
ThreadLimit          64
ThreadsPerChild      25
MaxClients          150
MaxRequestsPerChild   0

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

AccessFileName .htaccess

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

DefaultType text/plain
HostnameLookups On
ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

Include mods-enabled/*.load
Include mods-enabled/*.conf

Include httpd.conf
Include 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\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Include conf.d/

Include sites-enabled/

And here's my default Virtual Domain:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DirectoryIndex index.shtml index.html

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews +Includes +ExecCGI
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

</VirtualHost>

and my envars file:

#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

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

I'm stumped.

Any ideas what's going on here?

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

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

发布评论

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

评论(3

娜些时光,永不杰束 2024-10-24 19:55:44

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

#ServerRoot“/etc/apache2”

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

I had the exact same problem, also on a KVM virtual client.
The solution for me was to uncomment the following line:

#ServerRoot "/etc/apache2"

Hope this can help the next guy who starts wondering why he has to run "apache2ctl start" in the "/etc/apache2" directory in order to succeed ;)

情徒 2024-10-24 19:55:44

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

apachectl is a bash script.
You might want to file a bug report for that behavior to Ubuntu BTS.

从来不烧饼 2024-10-24 19:55:44

您应该删除 /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

删除所有内容。

然后还编辑您的环境变量以删除您的 $ 后缀,以便您的最终文件看起来像这样:

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

完全相同与您遇到的问题相同。并在使用环境变量后修复了它。

You should remove the lines in your /etc/envvars file:

#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

Remove all of that.

Then also edit your envvars to remove your $suffix so that your end file looks something like this:

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

I had exactly the same problem as you did. And fixed it after playing with the envvars.

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