Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
756 views
in Technique[技术] by (71.8m points)

php - Apache: Wordpress over local network

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.

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.

Then when I click on a link, it goes to localhost/wordpress/whatever which obviously doesn't work from another computer.

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.

Is there anything I'm missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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');

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.

By setting the before mentioned constants, you force Wordpress to serve the files from the given IP address.

Please remember to remove those constants from the wp-config.php file when you deploy your website to an actual server.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...