• Hi everyone, I set up an ubuntu virtual box lamp machine with wp 4.3.1 on it for my wife to play around and make friends with on her laptop. It’s a multisite install because I want it to be double language.
    Is there any way of setting this up so that WP auto configures itself to the new IP and/or subnet at boot?
    I had already written a script to substitute IP addresses in wp-config.php, but it has become apparent that this won’t work …

    Can it be done? Has it been done? How is it done?
    I’m sorry if there’s a blatantly obvious way of doing this, but I missed it and google isn’t helping me much…

    TIA

Viewing 5 replies - 1 through 5 (of 5 total)
  • Rather than having IP addresses in your configuration files, I suggest that you use the “VirtualHost” technique, then all your websites are accessed by name, and the only IP address in sight is in your “hosts” file and is the universal localhost: “127.0.0.1”

    Details here:
    https://httpd.apache.org/docs/2.2/vhosts/
    https://en.wikipedia.org/wiki/Hosts_%28file%29

    That you are using virtualbox and dhcp will not be relevant as far as testing on the VM on the laptop goes.
    If you want to view the website from other computers by configuring the “hosts” file there, then you have the same issue as DHCP always give, many systems are sticky and usually reissue the same IP, other modem/routers let you assign fixed IP addressees to specified MAC identities.

    Thread Starter randommatt

    (@randommatt)

    I now have it working so that at home it doesn’t brake, I made the VM’s IP static. All these problems started because the sticky address from dhcp became “unstuck”. Also her parent’s house and the library have different address spaces and I’d like her to be able to work from there too.
    The problem with having it on a virtual machine is that it has to be network visible, I can’t check 127.0.0.1 on the laptop because it would not be the VM’s …
    I may have had an epiphany in the night, just to highlight my sheer ignorance … If I set all values to “localhost” would it work and be visible from other machines on the same network by pointing at the machines address?
    I started my endeavour on the assumption that the localhost address would only be visible from the local machine pointing at 127.0.0.1, but I just realised I may be very, and embarrassingly, wrong.

    If so what lines in wp-config and database fields do I need to change?

    TIA

    I can’t check 127.0.0.1 on the laptop because it would not be the VM’s

    On every machine localhost and 127.0.0.1 are synonyms, they ALWAYS refer to the local machine. So the laptop thinks that localhost is the laptop, and the VM thinks that localhost is the VM, sorry this will not help.

    Yes it is a problem that the library etc have different address ranges. It means that the entries in the hosts file on the foreign machines have to be different on each network.

    The simplest way to work is to do all the website development inside the VM where it is localhost, install and use Firefox and Chrome in the VM.

    If you want to show it at her parent’s house, then:
    Find the IP address allocated to the VM by their network.
    Add the site and and this IP to the hosts file on their computers.
    Now the name will get served by the webserver in the VM.

    To clarify how the hosts file is used:
    – whenever a browser is fetching a named website it FIRST consults the hosts file, if it finds a match it uses the listed IP address, otherwise it send the name the the DNS server and uses the IP address fetched.
    – Now it send the request for the named website to the IP address, the server there looks looks the name in VirtualHosts configuration, and activates the relevant files in the specified directory to create the web page data, these are sent back to the browser.

    Thread Starter randommatt

    (@randommatt)

    Thanks again for the help, but I’m afraid this still doesn’t work for me.
    The vm is a terminal only install (no X-server), so I can’t access the wp page from the vm. This configuration is by design and won’t change, the laptop cannot handle both a WP server, and two desktops running at the same time.

    I also understand how the host file works (thank you for the explanation), but I don’t see how this will help my scenario.

    The main issue is that WP will not work if the vm has an IP address that is different than the one it has been configured with.

    So my question has become: if I reconfigure my WP multisite install to use “localhost” as its address, will it be visible from other machines on the same network pointing at the vm’s assigned IP?

    If so which lines of which config files and database entries need to be changed?

    Thanks again.

    The main issue is that WP will not work if the vm has an IP address that is different than the one it has been configured with.

    This is not correct.
    A VirtualHost configured WordPress server does not need to know its own IP address, it does need to know how to access the database but this is always “localhost”.

    So my question has become: if I reconfigure my WP multisite install to use “localhost” as its address,

    Yes this is correct.

    will it be visible from other machines on the same network pointing at the vm’s assigned IP?

    Suppose that on the different networks you visit the VM is assigned the following IP addresses:
    Home – 192.168.0.37
    Library – 10.0.0.97
    In Law’s place – 192.168.1.11

    Then you configure the hosts files on the other computers on these networks to be:
    At home, add to hosts file:

    192.168.0.37 wifeofrandommatt.com
    192.168.0.37 www.wifeofrandommatt.com

    In Law’s place, add to hosts file:

    192.168.1.11 wifeofrandommatt.com
    192.168.1.11 www.wifeofrandommatt.com

    At the library you are probably out of luck because it is unlikely that you will be able to edit the hosts file on their computers.

    There are no changes to the WP database or configuration.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Virtualbox installation in dhcp network, can it be done?’ is closed to new replies.