在LAN,WAMP上共享localhost

时间:2013-09-26 19:17:00

标签: apache localhost wamp

我有一个简单的PHP项目只是php和apache,我想在我的本地网络上分享这个项目,我怎么能搞清楚这个?

我尝试了一些在这里建立的解决方案,但无法使其发挥作用。

有人有任何想法吗?

我已经将我的httpd.conf从apache文件夹更改为:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

改变了:

Listen 80

为:

Listen 192.168.50.1:80

但是也不要工作。

1 个答案:

答案 0 :(得分:2)

好好改变一切。

此更改允许访问您安装的驱动器的根目录。不是一个好主意。 S将其改回:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

也回到

Listen 80

假设您的网站位于c:\wamp\www,并且您的子网实际上是192.168.50,就像您上面使用的一样,只允许通过本地网络访问您的网站的简单方法是更改​​此部分的httpd.conf

寻找

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

#   onlineoffline tag - don't remove
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1    
</Directory>

并改变该部分的这一部分

#   onlineoffline tag - don't remove
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1 ::1 localhost
    Allow from 192.168.50

Allow from 192.168.50将允许从该子网上的任何IP进行访问,即192.168.50.1 - &gt; 192.168.255

如果您将网站放入子文件夹,请执行以下操作:

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

#   onlineoffline tag - don't remove
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1 ::1 localhost
</Directory>

<Directory "c:\wamp\www\sitefolder">
    Options Indexes FollowSymLinks
    AllowOverride all
    Allow from 192.168.50
</Directory>

这会使您的wampserver主页保持安全,但允许sitefolder访问本地网络中的所有人。