Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by megaspaz: http://wiki.apache.org/httpd/Info/CommonMisconfigurations The comment on the change is: added toc and got rid of numbers in body section discussed w. pctony ------------------------------------------------------------------------------ This page will describe common misconfigurations as seen in #apache as well as describe why these are wrong. + [[TableOfContents(4)]] + === Name Based Virtual Host === - ==== 1. Not matching the value of NameVirtualHost with a corresponding <VirtualHost> block. ==== + ==== Not matching the value of NameVirtualHost with a corresponding <VirtualHost> block. ==== Example: {{{NameVirtualHost *:80 @@ -24, +26 @@ Why is the first virtual host wrong? It's wrong on a couple of levels. The most obvious is that some.domain.com used in the first <!VirtualHost> block doesn't match *:80 used in !NameVirtualHost. The other being that !NameVirtualHost refers to an interface, not a domain. For instance using *:80, means catch all interfaces on port 80. !NameVirtualHost 1.1.1.1:80, would mean to catch the interface defined as 1.1.1.1 on port 80. While you can use a "!NameVirtualHost some.domain.com/<!VirtualHost some.domain.com>" combination, it doesn't really make sense and is not used... at least not used by anyone who's experienced with Apache administration.[[BR]][[BR]] - ==== 2. Not setting a ServerName in a virtual host. ==== + ==== Not setting a ServerName in a virtual host. ==== Example: {{{NameVirtualHost *:80 @@ -42, +44 @@ The second virtual host is wrong because when using name based virtual hosts, the !ServerName is used by Apache to determine which virtual host configuration to use. Without it, Apache will never use the second virtual host configuration and will use the default virtual host. The default virtual host when using name based virtual hosts is the first defined virtual host.[[BR]][[BR]] - ==== 3. Mixing non-port and port name based virtual hosts. ==== + ==== Mixing non-port and port name based virtual hosts. ==== Example: {{{NameVirtualHost * NameVirtualHost *:80 @@ -60, +62 @@ Because !NameVirtualHost * means catch all interfaces on all ports, the *:80 virtual host will never be caught. Every request to Apache will result in the some.domain.com virtual host being used.[[BR]][[BR]] - ==== 4. Using the same Listen and/or NameVirtualHost multiple times. ==== + ==== Using the same Listen and/or NameVirtualHost multiple times. ==== Example: {{{# Can happen when using multiple config files. # In one config file: @@ -79, +81 @@ Multiple !NameVirtualHost lines will yield a "!NameVirtualHost *:80 has no !VirtualHosts" warning. Apache will ignore the second directive and use the first defined !NameVirtualHost line, though. This seems to happen when one is using multiple virtual host configuration files and doesn't understand that you only need to define a particular !NameVirtualHost line once.[[BR]][[BR]] - ==== 5. Multiple SSL name based virtual hosts on the same interface. ==== + ==== Multiple SSL name based virtual hosts on the same interface. ==== Example: {{{NameVirtualHost *:443 @@ -99, +101 @@ === Scope === - ==== 1. Adding/Restricting access and options in <Directory /> ==== + ==== Adding/Restricting access and options in <Directory /> ==== Example: {{{<Directory /> # This was changed from the default of AllowOverride None. @@ -110, +112 @@ <Directory /> is not a URL path. It is a filesystem path. Making changes in this <Directory> block will have no effect on your website !DocumentRoot. In the example above, what might have been attempted was being able to use htaccess in the !DocumentRoot. The problem being that the htaccess file will still be ignored because the !AllowOverride is set in the wrong <Directory> block.[[BR]][[BR]] - ==== 2. Trying to set directory and index options in a script aliased directory. ==== + ==== Trying to set directory and index options in a script aliased directory. ==== Example: {{{ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory /var/www/cgi-bin>
