How to debug an apache virtual host configuration?

前端 未结 7 1874
渐次进展
渐次进展 2020-12-02 05:40

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

相关标签:
7条回答
  • 2020-12-02 05:52

    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. ;)

    0 讨论(0)
  • 2020-12-02 05:53

    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!

    0 讨论(0)
  • 2020-12-02 05:57

    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).

    0 讨论(0)
  • 2020-12-02 05:59

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

    0 讨论(0)
  • 2020-12-02 06:04

    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.

    0 讨论(0)
  • 2020-12-02 06:06

    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.

    0 讨论(0)
提交回复
热议问题