randrews's picture

Hi,

How do I modify these settings?  The WordPress Address and Site Address are both populated with the private IP address my VM is using (under Settings > General from the wp-admin page).  No where in the setup or config did I see a prompt to change these.  The boxes are both gray and I  cannot change the fields. 

The problem is some plugins use these, and they fail with the private IP.  For example, a google XML site map does not work with http://privateip/xml.  


Thanks

Forum: 
Alon Swartz's picture

The default configuration is to support all hostnames dynamically, but you change that in /var/www/wordpress/wp-config.php

old
---
define('WP_SITEURL', 'http://'.$_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://'.$_SERVER['HTTP_HOST']);

new
---
define('WP_SITEURL', 'http://www.yoursite.com');
define('WP_HOME', 'http://www.yoursite.com');

There is a gotcha though, as wordpress stores those values in the database. You can change them as follows:

SITE='http://www.yoursite.com'
NAME=wordpress
DB_PREFIX=wp_

mysql --defaults-extra-file=/etc/mysql/debian.cnf <USE $NAME;
UPDATE ${DB_PREFIX}options SET option_value='$SITE' WHERE option_name='home';
UPDATE ${DB_PREFIX}options SET option_value='$SITE' WHERE option_name='siteurl';
EOF
randrews's picture

Thanks I modified my config.php.  I'm not sure on the DB side though - what's the easiest way to tweak that?

 

Thanks


Alon Swartz's picture

Just run the code that I posted above to update the database, but make sure your set SITE to your domain name before you do...

randrews's picture

Hi,

I'm getting this when I enter this from the CLI:

 mysql --defaults-extra-file=/etc/mysql/debian.cnf <USE $NAME;
-bash: USE: No such file or directory
 


Jeremy Davis's picture

The command should be run by MySQL not bash (hence the mysql at the start). I don't know why it's not working because I don't know much about using MySQL at the commandline. From what I can gather the line should be launching MySQL command prompt as the default debian user and loading the wordpress DB. But I just tested it myself and sure enough, it errors. This is not quite so tidy, but do this instead (assuming your domain name is www.yoursite.com):

mysql --defaults-extra-file=/etc/mysql/debian.cnf

Which should open a priveledged mysql command prompt that looks like this:

mysql>

At that prompt type these lines (substituting your real site url & pressing <enter> after each line):

USE wordpress;
UPDATE wp_options SET option_value='http://www.yoursite.com' WHERE option_name='home';
UPDATE wp_options SET option_value='http://www.yoursite.com' WHERE option_name='siteurl';
quit;

I'm not sure why Alons code didn't work (perhaps it needs to be run as a script instead of just typed at the commandline?) but I tested what I posted here and it works.

Alon Swartz's picture

Sorry about that, the copy/paste I did to the comment area lost the formatting when converting to html, thats why it didn't work - there is a missing << EOF

SITE='http://www.yoursite.com'
mysql --defaults-extra-file=/etc/mysql/debian.cnf <<EOF
USE wordpress;
UPDATE wp_options SET option_value='$SITE' WHERE option_name='home';
UPDATE wp_options SET option_value='$SITE' WHERE option_name='siteurl';
EOF
randrews's picture

Thanks Jeremy.  Your code got me through it. 


Add new comment