使用Listen属性在httpd.conf文件中仅添加2个ip地址

时间:2013-08-02 09:05:35

标签: apache lampp

我正在添加ip:

Listen 127.0.0.1:80
Listen xxx.xxx.xxx.xxx:80

重新启动apache时会给我错误。

XAMPP: Error 1! Couldn't start Apache!
XAMPP: Starting diagnose...
XAMPP: Sorry, I've no idea what's going wrong.
XAMPP: Please contact our forum http://www.apachefriends.org/f/

如何使本地主机仅可用于局域网中的2台计算机。

1 个答案:

答案 0 :(得分:1)

指定Listen实际告诉Apache应该托管服务器的端口和IP地址,而不是哪些IP地址可以访问服务器。您要找的是Apache Access Control,在这里您将看到需要启用mod_authz_host,然后您可以AllowDeny主机和IP地址。< / p>

在httpd.conf中查找以下行:

LoadModule authz_host_module modules/mod_authz_host.so

确保LoadModule

前面没有“#”

现在转到配置的VirtualHost并添加以下行:

<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    #below add your acceptable IPs
    Allow from 127.0.0.0/12.12.12.12 
</Directory>

请注意,使用主机名会导致反向DNS查找,因此速度很慢。