php Wordpress 主机 IP 已更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/535534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Wordpress host IP changed
提问by Andrew
I've got a Wordpress site on our home intranet that has run into trouble now that the IP address has changed - The index page loads, but not the CSS and I can't log in to the site administration panel.
我的家庭 Intranet 上有一个 Wordpress 站点,由于 IP 地址已更改,该站点遇到了问题 - 加载了索引页面,但未加载 CSS,我无法登录站点管理面板。
Unfortunately I am a bit behind on backups. Is there a way to get Wordpress to refer to the new IP address?
不幸的是,我在备份方面有点落后。有没有办法让 Wordpress 引用新的 IP 地址?
回答by Schoffelman
You have two places to update this (well three, but we'll stick with the two).
你有两个地方可以更新这个(三个,但我们会坚持两个)。
Ifyou can still log into your admin section, type the following for your URI /wp-admin/options.php - so for example, if your site is http://localhostthen your full URL will be http://localhost/wp-admin/options.php. Once you've logged into your site you should see two fields (well you'll see a lot of fields), but you'll want to look for the two with URL's in them - the Site URL and the Blog URL (in WP 2.7 the fields are labeled "home" and "siteurl", not sure on the other versions).
如果您仍然可以登录到您的管理部分,请为您的 URI /wp-admin/options.php 键入以下内容 - 例如,如果您的站点是http://localhost,那么您的完整 URL 将是http://localhost/ wp-admin/options.php。登录站点后,您应该会看到两个字段(好吧,您会看到很多字段),但是您需要查找其中包含 URL 的两个字段 - 站点 URL 和博客 URL(在 WP 中) 2.7 字段被标记为“home”和“siteurl”,其他版本不确定)。
Or, you can log into MySQL database and run the following.
或者,您可以登录 MySQL 数据库并运行以下命令。
Select * from wp_options where option_name IN('siteurl','home');
I just ran this today on one of my installs. If you're option_value is set to your localhost - you can then run the following:
我今天刚刚在我的一个安装上运行了这个。如果您将 option_value 设置为您的本地主机 - 您可以运行以下命令:
update wp_options set option_value='http://www.yourblogname.com' where option_name = 'siteurl';
update wp_options set option_value='http://www.yourblogname.com' where option_name = 'home';
This should update your table structure.
这应该更新您的表结构。
回答by Binny V A
You have to change the 'home' and 'siteurl' in the settings. Since you cannot open the admin side of wordpress, open the database in phpMyAdmin(or something similar).
您必须在设置中更改“home”和“siteurl”。由于您无法打开 wordpress 的管理端,请在 phpMyAdmin(或类似的东西)中打开数据库。
The options can be found in the 'wp_options' table(wp_ prefix might be different). Find the necessary setting using this query...
选项可以在“wp_options”表中找到(wp_前缀可能不同)。使用此查询查找必要的设置...
SELECT * FROM `wp_options` WHERE `option_name` IN ('siteurl', 'home')
Change the values of both the options to the new IP.
将两个选项的值更改为新 IP。
回答by nullvariable
To temporarily be able to login, use this code in your wp-config.php:
要暂时能够登录,请在 wp-config.php 中使用以下代码:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
or you can add this to your theme's functions.php:
或者您可以将其添加到主题的functions.php:
update_option('siteurl','http://example.com/');
update_option('home','http://example.com/');
Warning: Updating the SQL database will be required in order for installed plugins to use the new URL/hostname. So if you use plugins modifying the database is required.
警告:为了让安装的插件使用新的 URL/主机名,需要更新 SQL 数据库。所以如果你使用插件修改数据库是必需的。
回答by Shoban
I ran into this problem once. Loginto your DB and check your wp_options (if wp_ is your table prefix) and then search for all records and replace your old ip with new.
我曾经遇到过这个问题。登录您的数据库并检查您的 wp_options(如果 wp_ 是您的表前缀),然后搜索所有记录并将您的旧 IP 替换为新 IP。
Possible columns to have the old ip would be 'permalinks' etc.. Sorry I cant see my blog's table structure now otherwise I would have posted the correct column name.
具有旧 ip 的可能列是“永久链接”等。对不起,我现在看不到我博客的表结构,否则我会发布正确的列名。
回答by cdmckay
I ran into this problem before when I was migrating a site from test to production. Conveniently, MySQL has a string replace function.
我之前在将站点从测试迁移到生产时遇到过这个问题。方便的是,MySQL 有一个字符串替换功能。
Try something like this:
尝试这样的事情:
UPDATE wp_posts SET post_content = REPLACE(post_content,"http://localhost","http://www.myblog.com")
回答by Yang
Be careful for the link: https or http !!
注意链接:https 或 http !!
in the command line:
在命令行中:
mysql -u root -p
in the SQL, set new IP for xxxx
在 SQL 中,为 xxxx 设置新 IP
mysql> use wordpress;
mysql> select * from wp_options where option_id=1;
mysql> update wp_options set option_value="http://xxxx" where option_id=1; exit
mysql> 使用 wordpress;
mysql> select * from wp_options where option_id=1;
mysql> 更新 wp_options set option_value="http://xxxx" where option_id=1; 出口
Restart server
重启服务器
回答by CODE-REaD
Possibly WordPress.org's coverage of this issuewas not available at the time the other answers here were written, but as of now I find it more complete and easier to follow.
在撰写此处的其他答案时,可能WordPress.org 对此问题的报道尚不可用,但截至目前,我发现它更完整且更易于理解。
In my case, the method of modifying wp-config.phpwas only partially successful. The Relocate methoddescribed in the above web page ultimately succeeded.
就我而言,修改方法wp-config.php只是部分成功。上面网页中描述的Relocate方法最终成功了。
Here is a synopsis of WordPress.org's coverage:
以下是WordPress.org 报道的概要:
1 Changing the Site URL 1.1 Edit wp-config.php 1.2 Edit functions.php 1.3 Relocate method 1.3.1 Code function 1.3.2 Steps 1.4 Changing the URL directly in the database 2 Moving Sites 2.1 Altering Table Prefixes 2.2 Changing Template Files 2.3 Changing the Config file 2.4 Verify the Profile 2.5 Changing the .htaccess file 2.6 Additional items of note 2.6.1 Important GUID Note 2.7 Multi-site notes 2.8 wp-cli
1 Changing the Site URL 1.1 Edit wp-config.php 1.2 Edit functions.php 1.3 Relocate method 1.3.1 Code function 1.3.2 Steps 1.4 Changing the URL directly in the database 2 Moving Sites 2.1 Altering Table Prefixes 2.2 Changing Template Files 2.3 Changing the Config file 2.4 Verify the Profile 2.5 Changing the .htaccess file 2.6 Additional items of note 2.6.1 Important GUID Note 2.7 Multi-site notes 2.8 wp-cli

