wordpress - WAMP 3.1.3 : Allow computers on the same LAN to access web server

标签 wordpress wamp

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

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

# 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不起作用。 有人可以帮我解决这个问题吗?

最佳答案

1- 访问 www 和子文件夹:

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

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)

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

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”文件来简单解决,如下所示:

单击 WAMP 图标 > 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 的子网。这将允许 LAN 中的所有计算机访问您的 Web 服务器。

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

您还可以更具体:

# 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 的计算机。

2- 访问 phpmyadmin:

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

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

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>

您必须添加“需要 ip 192.168.13”和“允许来自 192.168.13”。

3- 访问 WordPress 网站:

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

如果您使用的是 Internet Explorer,您将不会注意到此重定向,因为 IE 不会反射(reflect)它,只会向​​您显示错误页面。但是,如果您尝试在 Chrome 或 Firefox 中打开网站,您将看到您被重定向到本地主机。不管怎样,这个问题可以通过以下方式解决:

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

编辑“WordPress 地址”和“站点地址”字段。将 localhost 更改为您的 IP 地址:

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

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

仅此而已。如果您有其他建议来完成此答案,请发表评论。

关于wordpress - WAMP 3.1.3 : Allow computers on the same LAN to access web server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51761286/

相关文章:

php - 注册页面脚本: Fatal error

php - 创建用于在 WAMP 上安装的安装程序包

php - wordpress如何在数组中添加wp_editor

css - 横幅图片在移动设备上没有响应

php - WordPress - PHP 警告无法打开流 : No such file or directory (advanced-cache. php)

php - Nodejs 和 wamp 服务器混淆

css - 如何将页脚和栏移动到页面底部

css - WP Twentyseventeen 菜单颜色更改不起作用

mysql - 更新密码而不进行哈希处理导致 MYSQL 出现死胡同

MySQL 工作台不工作