WordPress not working on Intranet
-
OK I’m running WP4.1 on a LAMP server under Ubuntu. The idea is to provide a local server so I can test websites. It works fine (so far) on the UBUNTU PC but when I view it from another PC on the intranet the links dont work. Also all the text is there – but the theme is not applied. The links all refer to localhost.
I’m a WP newbie AND an ubuntu newbie so I’ll need clear instructions if you can help that would be great.
Also I have WEBMIN as a control panel.
LAMP and FTP are running fine.
-
I have been running LAMP on Ubuntu for years, developed lots of WordPress websites.
I am not familiar with the WEBMIN control panel, I do my configuration at the command line, I will look into it. Where did you get it from ?
The core of your problem is that you are accessing your website as “https://localhost/”, this is like naming your dog “Dog”, barely ok until you have two of them, if you had a cat instead, it would still be called “Dog”. As you have found, when you are at your neighbours, there is no way to distinguish your dog from theirs.
The good news is that once you know how to name your websites, that it gives you a much closer environment to the live internet, on occasions I even run websites locally using the exact same name they use on the internet.
Say you want a new website accessed as “https://wp1.local/”
So I suggest that you do this:
A) Install a new WordPress site in “/var/www/wp1”
B) Add a lines:127.0.0.1 wp1.local 127.0.0.1 www.wp1.local
to /etc/hosts
C) In file: /etc/apache2/sites-enabled/001-local
Add these lines:<VirtualHost *:80> DocumentRoot /var/www/wp1 ServerName wp1.local ServerAlias www.wp1.local </VirtualHost>
D) restart apache:
sudo /etc/init.d/apache2 graceful
E) Say your Computer has a LAN ip address of: “192.168.0.24”
Then on OTHER computers add these lines to their hosts file:192.168.0.24 wp1.local 192.168.0.24 www.wp1.local
Details on hosts file here:
https://en.wikipedia.org/wiki/Hosts_%28file%29Let me know how it works out.
Thanks Ross. Webmin is at https://www.webmin.com/
On googling around I see I need to set a fixed IP address; but when I try (as here)
https://www.lampjunkie.com/2008/05/set-a-static-ip-address-in-ubuntu-from-command-line/
my networking fails altogether.My LAMP server is presently at 192.168.1.5 but I cant say if it will stay there – depends on what I connect to my network. ( 8 – 10 possible machines)
Should I fix the IP address before following your instructions above?
You will need to assign a fixed ip address to access the websites from your LAN segment. I do this in my DCHP settings in my ADSL2 modem gateway router, in advanced management it has a table where you can assign a specific IP address to a MAC, assign it an address that is outside the auto allocated range and still within the netmask.
Not all modems can do it this way, years back I loaded some 3rd party software into a modem to do this.
There are also some dynamic ip management services.You said that your network failed when you tried to assign an ip. Was this address inside or outside the auto DHCP range ?
My router is a DSL-3780. I can access the advanced setup.
The router IP address is 192.168.1.1 with a subnet mask of 255.255.255.0
second IP address is 192.168.2.1 with same mask.
There is a DHCP table – all devices lie in the range
192.168.1.2 to 192.168.1.10
the server “compaq” is at 192.168.1.5I tried as shown above putting it at 192.168.1.100 but I got fault messages on restarting, and the link to the ethernet failed.
sorry, forgot to add dhcp range is set to
192.168.1.2 – 192.168.1.254The address you attempted to set is within the DHCP auto range. Suggest that you reduce the range for DHCP auto allocation to 192.168.1.2 – 192.168.1.99 and then try your manual setting to: 192.168.1.100 and of course restart everything.
On the other hand DHCP is by design and implementation usually lazy, it will use an old allocation if it can. So maybe and as a practical matter it is OK to expect the DHCP setting to persist, just don’t bet your whole existence upon it. In this case you could add “192.168.1.5 wp1.local” to everyone’s hosts file and run it till it breaks, at which time you find the proper solution.
Hi Ross; I’ve changed the dhcp in my router as you suggested.
On DHCP my ubuntu pc reports
gateway 192.168.1.1, I’f eth0; broadcats 192.168.1.255 etc.this is my /etc/network/interfaces file
# The loopback network interface
auto lo
iface lo inet loopback# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1and networking fails with a message “waiting 60 seconds” etc.
However if I replace it with the original file the networking is fine;
AND if I tell it
$ sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up
I can access the server remotely at 192.168.2.100Ross, hope you are still with me. All the info on the web re setting a static IP address is cr*p. I went into network manager, edited the connection to 192.168.1.100 and it works fine.
I now have a static IP address of 192.168.2.100
I’ve edited the hosts files and I can access the server via the intranet at https://www.wp1.local
The wordpress site links are still not correct. Do I now need to rebuild the site?Good work in locking down the ip addresses, from time to time check that your fix is still working.
Most likely you don’t need to rebuild the site, don’t do that yet.
Please check:
– Load several pages with the browser on the same computer as the localhost. Do all the pages:
* text load correctly
* text is layed out correctly
* Images load correctly
THESE three items establish that your website + css + images are all named and mapped correctly.Do the same test from a browser elsewhere on the LAN, do they work properly ? Again the homepage and some other pages.
Which items don’t load ?
Use a browser inspector like firebug to view the full network names of the items that fail to load, that will telly us a lot.Hi Ross! I can load the apache (renamed) page, php page, and links work fine on a site I built in Dreamweaver.
But when I access the wordpress site from another machine
https://www.wp1.local/wp1/ the page loads – but
the links are all wrong – it doesnt even link to the css stylesheet.
Picking one at random, the “log in” link is
https://localhost/wp1/wp-login.php
and it doesnt load when I click.On the LAMP server all is fine.
On your localhost machine, login to your WordPress administration, and go to: Dashboard > Settings > General.
Tell me what is in the WordPress Address and Site Address ?The “localhost” part should be “www.wp1.local”
This is a high risk change, one error and you are locked out of your site. Better to add lines like these to your wp-config.php file:define('WP_HOME','https://example.com'); define('WP_SITEURL','https://example.com');
wp address https://localhost/wp1
site address (same)so I should edit wp-config.php
and
define(‘WP_HOME’,’https://www.wp1.local’);
define(‘WP_SITEURL’,’https://www.wp1.local’);I did that and restarted apache.
When I open wp-config.php in gedit I see the lines above. So it hasnt been overwritten.
Yet when I go to dashboard settings the original settings are still showing.Do I need to tell wordpress somehow to rebuild the links?
Not sure that an apache restart is required, it is required when you change the virtualhost settings.
The whole point of having these settings in wp-config is to get around vicious circles in errors in these settings. What DOES matter is how the names are put into the web pages.
How does the site work ?
ON localhost ?
ON LAN ?
Same test as in post #10 aboveOn the LAMP server:
I browse to https://www.wp1.local – site works fine. TExt, layout, etc. I dont have any images on the site as yet.
Hover over “log in ” and the link is https://localhost/wp1/wp-login.php
Click and I can log in.On my windows box (via LAN) I browse to 192.168.2.100 – static IP working fine! and https://www.wp1.local and (in both cases)
text shows on screen but layout is wrong (css not attached)
Hover over “log in ” and the link is https://localhost/wp1/wp-login.php
view source and all links refer to localhost eg
‘<script type=’text/javascript’ src=’https://localhost/wp1/wp-includes/js/jquery/jquery.js?ver=1.11.1′></script>’
- The topic ‘WordPress not working on Intranet’ is closed to new replies.