WAMP 3.1.3:允许同一局域网内的计算机访问网络服务器 [英] WAMP 3.1.3: Allow computers on the same LAN to access web server

查看:34
本文介绍了WAMP 3.1.3:允许同一局域网内的计算机访问网络服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 www/wp 文件夹中安装了 WAMP 3.1.3 和一个 wordpress 网站.我需要从同一局域网上的计算机访问该网站.我尝试了几种解决方案,但都没有奏效.

I have WAMP 3.1.3 and a wordpress website installed in www/wp folder. I need to access the website from computers on the same LAN. I tried several solutions but none of them worked.

在我按如下方式修改 httpd-vhosts.conf 后,我在 http://192.168 获得了对 WAMP 的默认页面的访问权限.13.20:2000/ 通过局域网.

After I modified httpd-vhosts.conf as follows I gained access to WAMP's default page at http://192.168.13.20:2000/ through LAN.

# Virtual Hosts
<VirtualHost *:2000>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
    Require ip 192.168.13
  </Directory>
</VirtualHost>

但是,http://192.168.13.20:2000/wp 不起作用.有人可以帮我解决这个问题吗?

However, http://192.168.13.20:2000/wp does not work. Would someone please help me for this problem?

推荐答案

1- 访问 www 和子文件夹:

通常,如果您想从同一 LAN 上的另一台计算机访问您的 Web 服务器,您会收到此错误:

1- Access to www and subfolders:

Normally, if you want to access your web server from another computer on the same LAN you get this error:

http://192.168.13.188/

Forbidden
You don't have permission to access / on this server.
Apache/2.4.33 (Win64) PHP/5.6.35 Server at 192.168.13.188 Port 80

(192.168.13.188是运行WAMP服务器的电脑IP)

(192.168.13.188 is the IP of the computer running WAMP server)

同样,www 根目录的子文件夹也会发生同样的事情:

Similarly, the same thing happens for the subfolders of the www root:

http://192.168.13.188/wp/

Forbidden
You don't have permission to access /wp/ on this server.
Apache/2.4.33 (Win64) PHP/5.6.35 Server at 192.168.13.188 Port 80

这个问题可以通过如下编辑httpd-vhosts.conf"文件来简单解决:

This issue can be simply solved by editing "httpd-vhosts.conf" file as follows:

点击 WAMP 图标 > Apache > httpd-vhosts.conf

Click WAMP icon > Apache > httpd-vhosts.conf

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
    Require ip 192.168.13
  </Directory>
</VirtualHost>

您必须添加需要 ip 192.168.13".请注意,192.168.13 是您 LAN 的子网.这将允许局域网中的所有计算机访问您的网络服务器.

You have to add "Require ip 192.168.13". Note that 192.168.13 is the subnet of your LAN. This will allow all computers in the LAN to access your web server.

不要忘记重启Apache服务.否则更改将不会生效.

Do not forget to restart Apache service. Otherwise the changes will not take effect.

你也可以更具体:

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
    Require ip 192.168.13.207
    Require ip 192.168.13.20
  </Directory>
</VirtualHost>

这将只允许 IP 地址为 192.168.13.207 和 192.168.13.20 的计算机.

This will only allow computers with IP addresses 192.168.13.207 and 192.168.13.20.

即使在授予访问 LAN 计算机的权限后,他们也无法访问 phpmyadmin,因为它已在 phpmyadmin 的别名配置中被明确阻止.因此,我们必须对配置文件进行如下

Even after granting access to LAN computers, they won’t have access to phpmyadmin because it has been explicitly blocked in phpmyadmin’s alias configuration. Therefore, we have to edit the configuration file as follows:

单击 WAMP 图标 > Apache > 别名目录 > http://localhost/phpmyadmin/ > 编辑别名>

Click WAMP icon > Apache > Alias directories > http://localhost/phpmyadmin/ > Edit alias

Alias /phpmyadmin "c:/wamp64/apps/phpmyadmin4.7.9/"

<Directory "c:/wamp64/apps/phpmyadmin4.7.9/">
    Options +Indexes +FollowSymLinks +MultiViews
    AllowOverride all
    <ifDefine APACHE24>
        Require local
        Require ip 192.168.13
    </ifDefine>
    <ifDefine !APACHE24>
        Order Deny,Allow
            Deny from all
            Allow from localhost ::1 127.0.0.1
        Allow from 192.168.13
    </ifDefine>
    # To import big file you can increase values
    php_admin_value upload_max_filesize 128M
    php_admin_value post_max_size 128M
    php_admin_value max_execution_time 360
    php_admin_value max_input_time 360
</Directory>

您必须添加Require ip 192.168.13"和Allow from 192.168.13".

You have to add "Require ip 192.168.13" and "Allow from 192.168.13".

如果您尝试访问 LAN 中的 wordpress 网站,则会出现另一个问题.默认情况下,wordpress 配置为将您重定向到 localhost.换句话说,如果您打算通过 http://192.168.13.188/wordpress/ 访问您的网站wordpress 倾向于在 http://localhost/wordpress/ 打开,当然这会导致错误,因为您的网站不在客户端计算机的本地主机上,而是在 192.168.13.188 上!

If you try to access a wordpress website in your LAN, another problem arises. The wordpress is configured to redirect you to localhost by default. In other words, if you aim to access your site at http://192.168.13.188/wordpress/ the wordpress tends to be opened at http://localhost/wordpress/ and of course this will result in error because your website is not on the localhost of the client computer, it is on the 192.168.13.188!

如果您使用的是 Internet Explorer,您不会注意到这种重定向,因为 IE 不会反映它,而只会向您显示一个错误页面.但是,如果您尝试在 Chrome 或 Firefox 中打开您的网站,您将看到您被重定向到本地主机.无论如何,这个问题可以解决如下:

If you are using Internet Explorer you won’t notice this redirection because IE does not reflect it and just shows you an error page. However, if you try to open your website in Chrome or Firefox you will see that you are being redirected to localhost. Anyway, this issue can be resolved as follows:

登录 wordpress 管理面板 > 设置 > 常规

Login to wordpress admin panel > Settings > General

编辑WordPress 地址"和站点地址"字段.将 localhost 更改为您的 IP 地址:

Edit " WordPress Address" and "Site Address" fields. Change localhost to your IP address:

WordPress 地址(URL): http://192.168.13.188/wordpress

网站地址(URL): http://192.168.13.188/wordpress

仅此而已.如果您对完成此回答还有其他建议,请留下评论.

That’s all. If you have other suggestions to complete this answer please leave comments.

这篇关于WAMP 3.1.3:允许同一局域网内的计算机访问网络服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆