Question

How to access WordPress site running in Vagrant box on DigitalOcean droplet?

Posted February 20, 2021 172 views
WordPress

I can successfully run a local WordPress site in a vagrant box on my laptop.

Local Vagrantfile entries:

config.vm.hostname = “wordpress”
config.vm.network “private_network”, ip: “10.23.45.60”

From a browser, I can access the WordPress site at http://10.23.45.60

But, once I try doing the same thing on my DigitalOcean droplet, does not work.
Droplet Vagrantfile entries:

config.vm.hostname = “wordpress”
config.vm.network “privatenetwork”, ip: “10.23.45.60”
config.vm.network :forwarded
port, host: 8086, guest: 80

From a browser, I cannot access the WordPress site at http://xxx.xxx.xxx.xxx:8086
(xxx.xxx.xxx.xxx is my droplet’s public IP)
And, please note, I have a number of other sites running from different Vagrant boxes on my DigitalOcean droplet, just not WordPress sites.

This is my configuration for WordPress (setting database & user):

/usr/local/bin/wp core config –dbname=wordpress –dbuser=wordpress –dbpass=wordpress123

This is what I used to install WordPress:

/usr/local/bin/wp core install –url=http://10.23.45.60 \
–title=“Blog” –adminuser=“admin” –adminpassword=“admin” \
–admin_email=“vagrant@localhost.localdomain

Like I mentioned above, the WordPress site that is running on my local vagrant box is accessible to me at http://10.23.45.60. But, the WordPress site running on my droplet’s vagrant box is not accessible using my droplet’s public IP and forwarded port. I don’t know what I’m missing.

Any help would be appreciated.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

@earlpearl17 is this resolved?

  • First, during my WordPress install, I changed my configuration to the following:

    /usr/local/bin/wp core install –url=http://142.93.158.28 \
    –title=“Blog” –adminuser=“admin” –adminpassword=“admin” \
    –admin_email=“vagrant@localhost.localdomain

    Then, I accessed my WordPress database and had to modify both my ‘home’ & 'siteurl’ fields in the wp_options table to include the port number. So, for both, from http://142.93.158.28 to
    http://142.93.158.28:8086

    Then, it worked.

    Just an FYI. I had another vagrant box that hosted phpMyAdmin. I configured the phpMyAdmin box to allow remote access to other boxes, in this case my WordPress box. I added the following to /etc/phpMyAdmin/config.inc.php:

    $cfg['Servers’][$i]['host’] = '10.23.45.60’; //WordPress box IP

    Then, on my WordPress box, I had to add a database user:

    mysql -u root -p
    <enter password to login>

    GRANT ALL PRIVILEGES ON . TO 'wpuser’@'10.23.45.35’
    IDENTIFIED BY 'somepassword’ WITH GRANT OPTION;
    FLUSH PRIVILEGES;

    Note, 10.23.45.35, is the IP of my phpMyAdmin vagrant box.

    Then, I was able to login to the WordPress database server and change both the 'home’ & 'siteurl’ to include the port number. And, voila!

    I hope this helps someone else.