如何使您的 Apache 应用程序在网络内可访问

如何使您的 Apache 应用程序在网络内可访问

我有一台 Windows XP 计算机,我已在计算机上安装了 WAMP 并制作了一个基于 PHP 的 Web 应用程序。我可以使用浏览器从这台计算机访问该 Web 应用程序,并指向:http://localhost/myApp/--- 并且页面加载正常。

现在我想让这个网站 ( http://localhost/myApp) 可供网络内的所有计算机访问(以后可能也可供公众访问)。我对此很陌生,如何才能让我的网站可供网络内的所有计算机和互联网上的公众访问?

我尝试修改 Apache (WAMP) 中的 httpd.conf 文件,将其更改 Listen 80Listen 10.10.10.10:80(其中我10.10.10.10用这台 Windows XP 计算机的实际 IP 替换)。我还尝试了 WAMP 中的“在线”功能。但似乎都不起作用。

我如何才能让它可访问?

答案1

实际上更好的解决方案是这样的:

对于 Apache 2.4.x

在 httpd.conf 文件中找到此部分,此更改还修正了语法以使用 Apache 2.4 的新语法。

<Directory "c:/wamp/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
#    Require all granted
#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
</Directory>

并将其更改为

<Directory "c:/wamp/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #

    # This looks after 127.0.0.1 ::1 and localhost
    Require local
    # This should be the first 3 quartiles of the standard subnet ipaddress range
    Require ip 192.168.0
</Directory>

或者如果你仍在使用 Apache 2.2

更改类似部分如下

<Directory "d:/wamp/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1 ::1 localhost 
    # This should be the first 3 quartiles of the standard subnet ipaddress range
    Allow from 192.168.0
</Directory>

如果你使用该Allow from all方法,实际上你允许任何 IP 地址访问,甚至是外部互联网地址。这可能非常危险。

相关内容