VM *上的Apache 2有时*没有找到启用mods的目录

时间:2011-02-15 20:29:26

标签: ubuntu apache2 virtual-machine mod-perl2 esxi

我在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正在尝试启动,而是关闭。 < / p>

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启用由于某种原因相对于 I 的位置,在我的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

我很难过。

有什么想法在这里发生了什么?

3 个答案:

答案 0 :(得分:3)

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

#ServerRoot“/ etc / apache2”

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

答案 1 :(得分:0)

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

答案 2 :(得分: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

我有完全和你一样的问题。并且在玩envvars之后修复它。