我在我们的一个开发服务器中共同托pipe了一组站点。
我需要configuration所有这些网站的
Allow from
指示。 由于这是关于dynamicIP的,这个变化比较频繁,所以我需要设置一个方法来轻松修改它们。
例:
<VirtualHost *:443> ServerName dbhost.domain ServerAdmin webmaster@domain DocumentRoot /srv/www/dbhost DirectoryIndex index.php index.php3 index.php4 SSLEngine On <Directory /srv/www/dbhost> order deny,allow allow from 192.168.0.0/16 <subnet1> <subnet2> <subnet3> <etc...> deny from all AllowOverride None AuthType Digest AuthDigestAlgorithm MD5 AuthName "devs" AuthDigestDomain / AuthDigestDomain / AuthDigestProvider file AuthUserFile <pwdfile> Require valid-user <Directory>
所以,我想在外部文件中包含“order / allow”,这样我就可以很容易地将它用于所有的configuration文件,只需要更改一次。
所以,我创build了一个新的文件,有以下几行:
order deny,allow allow from 192.168.0.0/16 <subnet1> <subnet2> <subnet3> <etc...> deny from all
然后,我修改了这个指令:
<Directory /srv/www/dbhost> Include /fullpath/to/acl.conf AllowOverride None
但是,apachectl -t报告错误:
apache2ctl -t Syntax error on line 1 of /fullpath/to/acl.conf: order not allowed here
那么,还有其他方法可以做到吗?
这种方法是可以的。 它会这样工作。 问题可能是因为你的Apache正在解释这个文件(acl.conf)(不仅仅是包含文件),因为它有.conf扩展名 – 你可能在httpd.conf
或apache.conf
某处有Include *.conf
。
将文件的名称更改为例如acl.include,并且应该可以。