如何调试apache虚拟主机配置?

发布于 2024-10-27 21:50:41 字数 1683 浏览 4 评论 0原文

我的 apache 虚拟主机配置再次出现问题。 (使用默认配置而不是我的特定配置)。

问题不在于配置错误,而在于如何解决它。

有人有好的建议可以快速解决此类问题吗?

更多信息。

默认的conf文件是这个:

NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost

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

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                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
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

不适用的虚拟主机配置是这个:

<VirtualHost *:*>

ProxyPreserveHost On
ProxyPass / http://ip.ip.ip.ip:8088/
ProxyPassReverse / http://ip.ip.ip.ip:8088/
ServerName wiki.mydomain.com

</VirtualHost>

Once again, I have a problem with my apache virtual host configuration. (The default configuration is used instead of my specific one).

The problem is not really the misconfiguration but how to solve it.

Does anyone has good advices to do resolve this kind of problem quickly?

Some more informations.

The default conf file is this one:

NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost

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

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                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
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

And the virtual host config that doesn't apply is this one:

<VirtualHost *:*>

ProxyPreserveHost On
ProxyPass / http://ip.ip.ip.ip:8088/
ProxyPassReverse / http://ip.ip.ip.ip:8088/
ServerName wiki.mydomain.com

</VirtualHost>

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

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

发布评论

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

评论(8

吝吻 2024-11-03 21:50:41

语法检查

要检查配置文件是否存在语法错误:

# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -t

# Debian-based (Ubuntu)
apache2ctl -t

# MacOS
apachectl -t

列出虚拟主机

要列出所有虚拟主机及其位置:

# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -S

# Debian-based (Ubuntu)
apache2ctl -S

# MacOS
apachectl -S

Syntax check

To check configuration files for syntax errors:

# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -t

# Debian-based (Ubuntu)
apache2ctl -t

# MacOS
apachectl -t

List virtual hosts

To list all virtual hosts, and their locations:

# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -S

# Debian-based (Ubuntu)
apache2ctl -S

# MacOS
apachectl -S
相思碎 2024-11-03 21:50:41

我认为这是一个命令可能会有一些帮助:

apachectl -t -D DUMP_VHOSTS

您将获得所有虚拟主机的列表,您将知道哪一个是默认的,并且您将确保您的语法正确(与 apachectl configtest 建议的相同) yojimbo87)。

您还将知道每个虚拟主机的声明位置。如果你的配置文件很乱,它会很方便。 ;)

Here's a command I think could be of some help :

apachectl -t -D DUMP_VHOSTS

You'll get a list of all the vhosts, you'll know which one is the default one and you'll make sure that your syntax is correct (same as apachectl configtest suggested by yojimbo87).

You'll also know where each vhost is declared. It can be handy if your config files are a mess. ;)

网名女生简单气质 2024-11-03 21:50:41

如果您尝试调试虚拟主机配置,您可能会发现 Apache -S 命令行开关很有用。也就是说,键入以下命令:

httpd -S

该命令将转储出 Apache 如何解析配置文件的描述。仔细检查 IP 地址和服务器名称可能有助于发现配置错误。 (有关其他命令行选项,请参阅 httpd 程序的文档)。

If you are trying to debug your virtual host configuration, you may find the Apache -S command line switch useful. That is, type the following command:

httpd -S

This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes. (See the docs for the httpd program for other command line options).

你与昨日 2024-11-03 21:50:41

首先使用 apachectl configtestconfig 文件是否有语法错误> 然后查看 apache 错误日志

First check out config files for syntax errors with apachectl configtest and then look into apache error logs.

心舞飞扬 2024-11-03 21:50:41

我有一个新的 VirtualHost 配置文件,但在使用 apachectl -S 命令时未显示。经过一番绞尽脑汁后,我意识到我的文件没有后缀“.conf”。一旦我用该后缀重命名了文件,我的虚拟主机就开始显示并工作了!

I had a new VirtualHost configuration file that was not showing when using the apachectl -S command. After much head scratching I realised that my file did not have suffix ".conf". Once I renamed the file with that suffix my Vhost started showing and working!

两相知 2024-11-03 21:50:41

我最近在虚拟主机方面遇到了一些问题。我使用 a2ensite 来启用主机,但在运行重新启动之前(这会在失败时终止服务器),我运行了

apache2ctl -S

它,它为您提供了有关虚拟主机发生情况的一些信息。它并不完美,但有帮助。

I recently had some issues with a VirtualHost. I used a2ensite to enable a host but before running a restart (which would kill the server on fail) I ran

apache2ctl -S

Which gives you some info about what's going on with your virtual hosts. It's not perfect, but it helps.

向日葵 2024-11-03 21:50:41

我发现我自己的错误,我没有添加日志文件名:
错误日志 /var/log/apache2

还有这条路:
目录“/usr/share/doc/”
不包含网站来源。

我改变了这两个之后,一切都工作了。
有趣的是,apache 没有发出任何错误,只是没有在我的 Mac OS Sierra 上默默地打开我的网站。

I found my own mistake, I did not add log file name:
ErrorLog /var/log/apache2

And this path:
Directory "/usr/share/doc/"
Did not contain website sources.

After I changed these two, all worked.
Interestingly, apache did not issue any errors, just did not open my website silently on my Mac OS Sierra.

北音执念 2024-11-03 21:50:41

一个非常重要的工具是

apachectl -t -D DUMP_INCLUDES

它向我展示了我正在修复和修补的文件
事实上包含在一个本身不包含的文件中。

谢谢大家

a very important tool is

apachectl -t -D DUMP_INCLUDES

it showed me that the file that i was fixing and mending
was in fact included by a file that was itself not included.

thank everybody

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