简体   繁体   English

将 WordPress 站点迁移到本地主机

[英]Migrating a WordPress site to localhost

I have just followed the following guide on manually migrating a WordPress site to localhost: http://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/我刚刚按照以下指南手动将 WordPress 网站迁移到本地主机:http: //www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/

I have followed all of the steps: downloading files using FTP, exporting database, importing to localhost database, changing url links to localhost and finally updating wp-config.php我遵循了所有步骤:使用 FTP下载文件、导出数据库、导入到本地主机数据库、更改到本地主机的 url链接以及最后更新wp-config.php

I tried this on two of my sites and came across different problems:我在我的两个网站上尝试过这个并遇到了不同的问题:

  1. 'Safari cannot connect to the server' error message “Safari 无法连接到服务器”错误消息
  2. The following text displayed on the screen:屏幕上显示以下文字:

     <?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ). '/wp-blog-header.php' );

Image of this error message此错误消息的图像

Can anyone advise as to how I can make my website display?谁能建议我如何显示我的网站?

It looks like your server is not treating the.php files as PHP.看起来您的服务器没有将 .php 文件视为 PHP。 Rather, it is simply serving the.php files in plaintext.相反,它只是以明文形式提供 .php 文件。 I'm not familiar enough with MAMP to say how to fix this, but perhaps adding the tag would help bring in people with more knowledge if Atlas_Gondal's answer doesn't work.我对 MAMP 不够熟悉,无法说明如何解决此问题,但如果Atlas_Gondal 的答案不起作用,添加标签可能有助于吸引更多知识的人。

(I think this would be more appropriate as a comment, I'm a new user and my rep is too low to comment. ☹️) (我认为这作为评论更合适,我是新用户,我的代表太低无法发表评论。☹️)

There are 2 possible issues:有两个可能的问题:

Invalid Directory (High Chance)目录无效(高机会)

It looks like either files are not under MAMP directory OR MAMP is not pointing to that directory.看起来要么文件不在 MAMP 目录下,要么 MAMP 没有指向该目录。

Solution:解决方案:

If you have MAMP PRO:如果您有 MAMP PRO:

  1. Launch MAMP PRO启动 MAMP PRO
  2. Click on HOSTS tab单击主机选项卡
  3. Localhost will be there (if not then add by clicking on + icon at left bottom)本地主机将在那里(如果没有,则通过单击左下角的+图标添加)
  4. Choose Document Root (click on three dotted directory for browsing)选择Document Root(点击三点目录浏览)

If you have standard MAMP:如果你有标准的 MAMP:

  1. Open MAMP打开MAMP
  2. Select Preferences选择首选项
  3. Select Apache (You will be able to see the current location of your document root)选择 Apache(您将能够看到文档根目录的当前位置)
  4. Click on the object next to the 'Document Root:'单击“文档根目录:”旁边的对象
  5. Select the new location for your document root选择文档根目录的新位置
  6. click on the 'Select' button点击“选择”按钮
  7. Select OK MAMP automatically stops and starts the Apache and MySQL server选择 OK MAMP 自动停止和启动 Apache 和 MySQL 服务器

PHP parsing is disabled (Less Chances) PHP 解析被禁用(更少的机会)

Solution:解决方案:

  1. Edit this file in any editor:在任何编辑器中编辑此文件:

     /Applications/MAMP/conf/apache/httpd.conf
  2. Search for #AddHandler type-map搜索#AddHandler type-map

  3. Add this code, (below that line)添加此代码,(在那行下方)

     AddHandler application/x-httpd-php.php
  4. Save the file保存文件

  5. Restart MAMP.重新启动 MAMP。

Lemme know, if none of it works让我知道,如果它们都不起作用

-> İnstall xampp or appserv (etc.) your computer. -> 安装 xampp 或 appserv(等)您的计算机。

-> Start apache and Mysql (for xampp) -> 启动 apache 和 Mysql(对于 xampp)

-> Download files to server file (xampp -> htdocs, appserv ->www) -> 下载文件到服务器文件 (xampp -> htdocs, appserv ->www)

-> Open phpmyadmin and create database with the same name on your host -> 打开 phpmyadmin 并在您的主机上创建具有相同名称的数据库

-> İmport data -> 导入数据

-> Configure your wp-config file, -> 配置你的 wp-config 文件,

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'dbname');

/** MySQL database username */
define('DB_USER', 'username');

/** MySQL database password */
define('DB_PASSWORD', 'password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

-> Replace Url's -> 替换网址

UPDATE wp_options set option_value=REPLACE(option_value,'Site Url','127.0.0.1') where option_name='siteurl';

UPDATE wp_options set option_value=REPLACE(option_value,'Site Url','127.0.0.1') where option_name='home';

UPDATE wp_posts SET post_content=REPLACE(post_content,'Site Url', '127.0.0.1') ;

I follow these steps and it works for me.我遵循这些步骤,它对我有用。 Maybe you could have skipped a few steps也许你可以跳过几步

You need to download All in One WP Migration WordPress plugin first you need to setup on your live website then take a backup from there.wpress extension.您需要首先下载 All in One WP Migration WordPress 插件,您需要在您的实时网站上进行设置,然后从那里进行备份。wpress 扩展名。

After that, you just need to install a basic version of WordPress to your localhost and activate this plugin to your local site and import the backup which you created from your live site.之后,您只需将基本版本的 WordPress 安装到您的本地主机并将此插件激活到您的本地站点并导入您从实时站点创建的备份。 You don't need to create and rename databases or anything this plugin will do everything for you.您不需要创建和重命名数据库或任何此插件将为您做的一切。

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

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