Apache:通过本地网络的 Wordpress [英] Apache: Wordpress over local network
问题描述
我在 Ubuntu VM 上有一个 Apache 网络服务器,我想从中运行一个只能从内部网络访问的 Wordpress Intranet 站点.该站点显然可以在服务器上的本地主机上正常工作.
I have an Apache webserver on a Ubuntu VM from which I want to run a Wordpress intranet site that can only be accessed from the internal network. The site works fine from localhost on the server obviously.
服务器的本地ip是192.168.1.93,当我去http://192.168.1.93/wordpress 从另一台计算机加载一个纯文本页面,没有主题或图像.
The server's local ip is 192.168.1.93, and when I go to http://192.168.1.93/wordpress from another computer it loads a text-only page, with no themes or images.
然后,当我单击一个链接时,它会转到 localhost/wordpress/任何显然在另一台计算机上不起作用的内容.
Then when I click on a link, it goes to localhost/wordpress/whatever which obviously doesn't work from another computer.
这里似乎有两个问题:一个是 Apache/Wordpress 似乎不能跨网络工作,第二个是 Wordpress 似乎显示了所有到 localhost 的链接.
There seem to be two issues here: one is that Apache/Wordpress doesn't seem to work across a network, the second is that Wordpress seems to show all the links to localhost.
有什么我遗漏的吗?
推荐答案
在您的 wp-config.php
中,设置以下常量:
In your wp-config.php
, set the following constants:
define('WP_SITEURL', 'http://192.168.1.93/wordpress');
define('WP_HOME', 'http://192.168.1.93/wordpress');
当您从本地计算机提供 wordpress 站点时,所有与主题相关的文件可能都来自 localhost
或 127.0.0.1
,这些地址总是指向本地计算机".因此,当您从另一台计算机访问该网站时,它会尝试从另一台计算机而不是服务计算机获取 CSS 文件和图像.
When you serve your wordpress site from your local computer, all theme related files are probably served from localhost
or 127.0.0.1
, which are addresses which always point to "the local computer". So, when you access the website from another computer, it tries to fetch the CSS files and images from the other computer and not from the serving one.
通过设置前面提到的常量,您可以强制 Wordpress 提供来自给定 IP 地址的文件.
By setting the before mentioned constants, you force Wordpress to serve the files from the given IP address.
当您将网站部署到实际服务器时,请记住从 wp-config.php
文件中删除这些常量.
Please remember to remove those constants from the wp-config.php
file when you deploy your website to an actual server.
这篇关于Apache:通过本地网络的 Wordpress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!