简体   繁体   English

WordPress本地服务器到实时主机

[英]Wordpress local server to live host

I am developing a wordpress site. 我正在开发一个wordpress网站。 I uploaded the files(wordpress) to my live host. 我将文件(wordpress)上传到我的实时主机上。 So my new live url site for my wordpress like this sample url http://mywordpress.com/ , the display seems to be fine, but when I start browsing the menus page will be redirected to my local server, instead of http://mywordpress.com/about-us/ it went to my localhost like http://localhost/mywordpress/about-us 因此,我的wordpress的新实时URL站点(例如此示例url http://mywordpress.com/ )显示效果很好,但是当我开始浏览菜单页面时,将重定向到本地服务器,而不是http:/ /mywordpress.com/about-us/转到了我的本地主机,例如http:// localhost / mywordpress / about-us

So when I checked the page source all the links including the stylesheet is link to my local. 因此,当我检查页面源代码时,包括样式表在内的所有链接都链接到本地​​。 even though I use this code 即使我使用此代码

<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" media="all" />

Its kinda weird... but anyone knows how to configure this? 有点奇怪...但是没有人知道如何配置吗?

You may need to refresh your permalinks: see step 5 below. 您可能需要刷新永久链接:请参阅下面的步骤5。 Official documentation on this subject may clear some things up as well. 关于此主题的官方文档也可能会清除一些问题。


Steps to move a local WordPress install to a live site 将本地WordPress安装移至实时站点的步骤

This is my method, and it has worked every time. 这是我的方法,并且每次都有效。 Assume local WP install is at http://localhost/wordpress/ with WP database named wordpress and live WP install is at http://livesite.com/ with WP database named livesite : 假设本地WP安装在http:// localhost / wordpress /上 ,WP数据库名为wordpress ,实时WP安装在http://livesite.com/上 ,WP数据库名为livesite

  1. Create a backup of local WP database - 创建本地WP数据库的备份 -
    • navigate to http://localhost/phpmyadmin 导航到http:// localhost / phpmyadmin
    • select database wordpress from side menu 从侧面菜单中选择数据库wordpress
    • click EXPORT 点击导出
    • check the box for Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement 选中Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement的框
    • click GO - it should download a file called wordpress.sql 单击“开始”-它应下载一个名为wordpress.sql的文件
  2. Download a database for the live site - 下载实时站点的数据库 -
    • sign in + navigate to http://localhost/wordpress/wp-admin/options-general.php 登录+导航到http://localhost/wordpress/wp-admin/options-general.php
    • enter the live site values for WordPress Address (URL) and Site Address (URL) 输入WordPress Address (URL)Site Address (URL)的实时站点值
    • click SAVE CHANGES - this will break your local WP installation: that's why we made the backup 单击“ SAVE CHANGES”-这将中断您的本地WP安装:这就是我们进行备份的原因
    • repeat step 1 [Create a backup of local WP database] - include all substeps 重复步骤1 [创建本地WP数据库的备份]-包括所有子步骤
    • rename this newly downloaded file from wordpress.sql to livesite.sql 将这个新下载的文件从wordpress.sql重命名为livesite.sql
  3. Prepare WP files for live site 准备实时站点的WP文件
    • upload WP file structure to http://livesite.com/ 将WP文件结构上传到http://livesite.com/
    • edit /wp-config.php to have live database name, username and password 编辑/wp-config.php以获取实时数据库名称,用户名和密码
  4. Import live WP database - if you haven't created the livesite database yet, do so now 导入实时WP数据库 -如果尚未创建livesite数据库,请立即进行
    • navigate to http://livesite.com/phpmyadmin or equivalent 导航到http://livesite.com/phpmyadmin或同等功能
    • select database livesite from side menu 从侧面菜单中选择数据库活动livesite
    • click IMPORT 点击导入
    • choose local file livesite.sql from step 2 从步骤2中选择本地文件livesite.sql
    • click GO - it should successfully import the livesite database 单击“执行”-它应成功导入livesite数据库
  5. Refresh live site permalinks - your permalinks are set correctly but not updated to reflect the new domain, so get WP to update them 刷新实时站点永久链接 -您的永久链接设置正确,但未更新以反映新域,因此请获取WP进行更新
  6. Revert local installation - this can really be done at any point after step 2. 还原本地安装 -实际上可以在步骤2之后的任何时候完成。
    • Follow step 4 from http://localhost/phpmyadmin using the backup created in step 1. This is the only way to fix the local install because we changed the domain in step 2 and we can't even get back to the settings page. 使用步骤1中创建的备份,从http:// localhost / phpmyadmin执行步骤4。这是修复本地安装的唯一方法,因为我们在步骤2中更改了域,甚至无法返回到设置页面。

NOTES 笔记

  • using WP 3.3.1 使用WP 3.3.1
  • using phpMyAdmin 3.4.8 使用phpMyAdmin 3.4.8

As mentioned in the comments, you will need to browse to the Settings->General page and update your site URL and wordpress URL. 如评论中所述,您将需要浏览至“设置”->“常规”页面并更新您的站点URL和wordpress URL。

If you can't get to the Settings page because you get redirected to your local site (this has happened to me before), you may have to edit the values in mysql directly, which isn't too bad, really. 如果由于重定向到本地站点而无法进入“设置”页面(这在我之前已经发生过),则可能必须直接在mysql中编辑值,实际上还不错。

The settings are located in the wp_options table under the option_name "siteurl" and "home". 设置位于wp_options表中的option_name“ siteurl”和“ home”下。 If you need more help with that, post a comment. 如果您需要更多帮助,请发表评论。

It sounds to me like your database may be using old values for your url's. 在我看来,您的数据库可能正在使用旧值作为url。

For a quick solution that may or may not solve your issue, try http://www.velvetblues.com/web-development-blog/wordpress-plugin-update-urls/ . 对于可能无法解决您问题的快速解决方案,请尝试http://www.velvetblues.com/web-development-blog/wordpress-plugin-update-urls/ It's a great plugin. 这是一个很棒的插件。 If not... here are my bullet proof instructions for transferring from local to online. 如果不是...,这是我的防弹说明,用于从本地转移到在线。

I've migrated from local to online hundreds of times and I think most tutorials on wordpress migration are overly complex. 我已经从本地迁移到在线了数百次,而且我认为大多数有关wordpress迁移的教程都过于复杂。 Here's my method (assuming you already have a fresh wordpress installation and database) 这是我的方法(假设您已经有了全新的 wordpress安装和数据库)

  1. Go to phpMyAdmin for your local server and export your database (but not as a file)... just get the straight SQL text and copy it. 转到本地服务器的phpMyAdmin并导出数据库(但导出为文件)...只需获取直接的SQL文本并将其复制即可。

  2. Paste that code into dreamweaver, text editor, coda or any plaintext word processor that can do a search and replace. 将该代码粘贴到Dreamweaver,文本编辑器,Coda或任何可以进行搜索和替换的纯文本文字处理器中。 Then search for "http://MyOldWordpressUrl.com/wordpress" (make sure there is NO slash after the final directory) and replace with "http://MyNewWordpressUrl.com/wordpress". 然后搜索“ http://MyOldWordpressUrl.com/wordpress”(确保最终目录后没有斜杠),并替换为“ http://MyNewWordpressUrl.com/wordpress”。 Obviously don't include the quotation marks. 显然不包括引号。 Make sure your old wordpress URL is correct. 确保您的旧wordpress网址正确。 You can double check in admin -> general settings. 您可以再次检查admin->常规设置。

  3. Get into your control panel for your online hosting and go to the database for your new wordpress install (this should be a brand new installation where you haven't yet created any posts or input any data-- just what wordpress gives you). 进入控制台进行在线托管,然后转到数据库以进行新的wordpress安装(这应该是一个全新的安装,在这里您还没有创建任何帖子或输入任何数据-只是wordpress所提供的功能)。 Export the database and save it as a file (just in case). 导出数据库并将其保存为文件(以防万一)。 Now drop all the tables. 现在删除所有表格。 Click YES when it asks you if you're sure. 当系统询问您是否确定时,请单击“是”。 Then click on the SQL icon (should be in the upper left hand corner of the left sidebar). 然后单击SQL图标(应在左侧边栏的左上角)。 This should open a new window. 这应该打开一个新窗口。 Now paste in your code from step 2 and click GO. 现在,粘贴步骤2中的代码,然后单击“执行”。

  4. Transfer your theme folder via FTP. 通过FTP传输主题文件夹。

  5. Right now you should go to the new wordpress install's wp-admin. 现在,您应该转到新的wordpress安装的wp-admin。 Your same User Name and password will apply. 您的相同用户名和密码将适用。 Go to "add a post" and add any image from your computer... wait for it to upload, now delete it. 转到“添加信息”并从您的计算机添加任何图像...等待其上传,现在将其删除。 This step is to have the server create the uploads folder to be 100% certain is registered by wordpress and set to the correct permissions. 此步骤是让服务器创建上载文件夹,以确保100%由wordpress注册并设置为正确的权限。 I've wasted hours before by transferring the uploads folder directly by FTP, so don't do it. 通过直接通过FTP传输上载文件夹,我已经浪费了数小时,所以不要这样做。

  6. Step 5 created an uploads folder in FTP, now you can drag and drop the contents of your uploads folder (ie 2008, 2009, 2010, 2011 + subfolders) into the uploads folder. 步骤5在FTP中创建了一个上载文件夹,现在您可以将上载文件夹的内容(即2008、2009、2010、2011 +子文件夹)拖放到上载文件夹中。 There should be nothing in it except an empty folder (because you deleted that file in step 5), so it's fine to overwrite if it warns you. 除了一个空文件夹外,里面什么也没有(因为您在第5步中删除了该文件),因此如果警告您,可以覆盖它。

  7. The only remaining step is to transfer your plugins. 剩下的唯一步骤是转移您的插件。 You can do it via FTP, although it's probably faster to add them directly through the Wordpress admin via "add plugin" and search + install. 您可以通过FTP进行操作,尽管通过“添加插件”通过Wordpress管理员直接添加它们并搜索+安装可能更快。

  8. Oh yeah, now go to permalink settings and click "default", update, then choose whatever you want-- you need to refresh permalinks to. 哦,是的,现在转到永久链接设置,然后单击“默认”,进行更新,然后选择所需的内容-您需要刷新永久链接。

That's foolproof... but you have to be somewhat familiar/confident using PHP myadmin. 那是万无一失的……但是您必须使用PHP myadmin有点熟悉/自信。 Although I've founds some widgets do not transfer via this method, so you may have to drag and drop some widgets again (appearance -> widgets) after the transfer. 尽管我发现有些小部件无法通过此方法进行传输,所以在传输后您可能不得不再次拖放一些小部件(外观->小部件)。

For clarification on step 1 and step 3, see the diagrams here: http://webdesignerwall.com/tutorials/exporting-and-importing-wordpress ... but the rest of that WDW tutorial is guaranteed to give you problems at somepoint. 有关第1步和第3步的说明,请参见此处的图: http ://webdesignerwall.com/tutorials/exporting-and-importing-wordpress ...但该WDW教程的其余部分一定会给您带来问题。

The reason behind this, After you move wordpress site from local server to live you not changed the site url and home address.So, when ever you try to open your site in real server it will redirect back to your local server.You need to open PhpMyAdmin Tool in Cpanel or FTP and select your database then open wp_options table. 其背后的原因是,将wordpress网站从本地服务器移到在线状态后,您无需更改网站的网址和家庭住址。因此,当您尝试在真实服务器中打开网站时,它将重定向回您的本地服务器。打开phpMyAdmin的工具在交友或FTP,然后选择你的数据库,然后打开wp_options表。

In wp_options table change the value of site url and home . wp_options表中,更改站点urlhome的值。

Now your problem will solved. 现在您的问题将解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM