我一直在尝试从旧的WordPress导入.xml文件到新的.我在php.ini中有以下设置:
但是,当我点击上传文件和导入按钮时,我得到一个空白页面.没有错误或任何东西.
任何人都知道如何解决这个问题?谢谢.
更新:
打开下面建议的错误显示后,我得到以下错误:
Fatal error: Class 'DOMDocument' not found in /var/www/html/wp-content/plugins/wordpress-importer/parsers.php on line 61
Run Code Online (Sandbox Code Playgroud)
然后我通过安装php-xml来解决这个问题.
Mik*_*lRo 19
原始形式的这个问题没有提供足够的信息来证明实际尝试猜测解决方案的合理性.
因此,我觉得最相关的答案是一些一般的故障排除步骤,可能会对类似的情况有所了解 - 我的重点是可能有助于这种特殊情况的提示,但是因为它总是相当冗长我还包括更多一般提示.
OP实际上并没有要求wordpress导入/导出功能的替代品,但由于这是一个迁移变坏(加上wordpress导入/导出功能留下很多欲望的事实),我将尝试回答关于Alans的问题在服务器/位置/域之间迁移wordpress的替代方法.
有明确说明的风险:这个答案会很长!
启用调试模式,并确保display_errors已启用,并error_reporting定义了适当的级别.这对于任何wordpress开发都至关重要.
打开wp-config.php并找到这一行:
define('WP_DEBUG', false);
Run Code Online (Sandbox Code Playgroud)
替换为:
//Switch on wordpress' built-in debug mode
define('WP_DEBUG', true);
/**
* Just a convenient check so you can leave the next few lines unchanged
* for next time you need debugging, and just switch true/false above.
*/
if (WP_DEBUG) {
//Handle all errors regardless of error level
ini_set('error_reporting', -1);
//Display errors directly in the browser
ini_set('display_errors', 'On');
}
Run Code Online (Sandbox Code Playgroud)
...如果由于某种原因线路已经存在,只需将其插入线路上方的某处即可.
/* That's all, stop editing! Happy blogging. */
Run Code Online (Sandbox Code Playgroud)
这应该允许您查看有关大多数(php-)错误的更多信息.
笔记:
WP_DEBUG到true,就会自动启用display_errors-但是我发现上面覆盖一些边缘情况下,错误哪里都不尽管所示WP_DEBUG为true.WP_DEBUG有条件地启用,例如通过IP :( define('WP_DEBUG', $_SERVER['REMOTE_ADDR'] === '123.123.123.123');显然替换您的实际IP)如果您在启用调试模式后确实看到引用其中一个插件的错误,我建议您就此问题与插件开发人员联系,或者只是卸载插件并找到另一个满足您需求的插件.在开发过程中甚至不关心使用调试模式的开发人员的插件很可能也包含安全问题和/或关于未来或第三方兼容性的子标准.
无论你做了什么来解决问题 - 再做一次.这应该给你一些工作,例如通过简单地粘贴谷歌,看看会出现什么.您可能不是第一个遇到任何问题的人.
If you still get no visible errors try to right click the "nothingness" and view the page source in a plaintext editor. Sometimes errors can be hidden inside an attribute, or behind an element on the screen.
You can also try to insert some intentionally broken code in wp-config.php to confirm that errors will in fact be printed. For example type this_function_surely_does_not_exist(); right after the ini_set() directives.
Some hosts restrict the use of ini_set(), so if things still aren't working, but you do not see any errors try to find out how you can set the relevant php.ini settings - it may be in your hosting providers control panel (cPanel, Plesk etc.), you may have direct access to your php.ini via FTP... or they may offer no way to set it (find a different provider at once!)
您也可能无法更改值,但默认情况下会在提供程序面板中的某处记录错误.
如果你得到一个完全白色的浏览器窗口,你可能会在某处发生致命错误 - 或者服务器本身存在配置问题.这超出了本答案的范围,因此如果下一部分中有关增加限制的建议不起作用,请尝试谷歌"WSOD"开始使用.
不要相信这只是因为你有一个名为的文件php.ini包含一行说memory_limit = 128M你的内存限制实际上是128M.这可以通过许多不同的方式设置,唯一可靠的方法是询问php当前的内存限制是什么.这对大多数人来说都是如此php.ini!
要了解您的工作环境是什么样的,请创建一个文件(最好是在您的wordpress安装的根目录中)phpinfo.php,其中包含以下内容:
<?php
//Your memory limit
echo 'memory_limit: ' . ini_get('memory_limit') . '<br>';
//Your maximum size of post-data (including file uploads)
echo 'post_max_size: ' . ini_get('post_max_size') . '<br>';
//The maximum file size for uploads
echo 'upload_max_filesize: ' . ini_get('upload_max_filesize') . '<br>';
//Maximum runtime for php scripts (in seconds)
echo 'max_execution_time: ' . ini_get('max_execution_time') . '<br>';
//Current error reporting level
echo 'error_reporting: ' . ini_get('error_reporting') . '<br>';
//Are errors displayed?
echo 'display_errors: ' . ini_get('display_errors') . '<br>';
//Will errors be logged?
echo 'log_errors: ' . ini_get('log_errors') . '<br>';
//Where will errors be logged?
echo 'error_log: ' . ini_get('error_log') . '<br>';
//What is the absolute path of this files parent folder
// = the complete path to your wordpress "root folder"
echo 'root of wordpress: ' . __DIR__ . '<br>';
/**
* If you are curious to see *a lot* of information about your environment
* then uncomment this line too:
*/
//phpinfo();
/**
* This should print whatever is in the error log, but it could potentially
* be huge, so use with caution!
*/
//echo '<pre>' . file_get_contents(ini_get('error_log')) . '</pre><br>';
Run Code Online (Sandbox Code Playgroud)
You should be aware that all of the above values can be changed during execution of a script - and some (poor quality) plugins actually will. I've seen plugins try to increase the memory_limit for instance - which is all fine and dandy, except 6-7 years pass, and a plugin "increasing" the memory limit to 32MB actually messes up the installation, because nowadays 64MB is needed for a pretty basic wordpress install, and 128MB would be a more reasonable minimum for most. The problem with this is that the only way to actually know the values for sure at any given point of execution is to insert the above right at that point.
Some very common reason for errors that happen "on occasion", particularly in connection with imports or file uploads is that either memory_limit, post_max_size or upload_max_filesize is set too low - you can try to increase them using ini_set() calls in wp-config.php:
ini_set('memory_limit', '256M');
ini_set('post_max_size', '128M');
ini_set('upload_max_filesize', '64M');
Run Code Online (Sandbox Code Playgroud)
Again your host may completely prevent you from affecting your limits using these functions, but may provide another way for you to set them.
If that doesn't work either, try disabling as many plugins as possible, and as a last resort switch to a default theme - but be prepared to lose widgets and a bunch of settings if things get to that.
If you're still stuck at square one ask a question on Stack Overflow, and be very verbose about exactly what you did before it all went south ;)
There are a lot of backup/migration plugins out there. If you are inexperienced working with files, databases and the like your best bet is probably to go with one of those. I will not recommend any specific plugin as changes are too frequent and I personally always do it manually - a google search should yield plenty of relevant results though, and I'm sure many of them can get the job done in most situations.
However, if like me, you prefer to do it manually to understand (and control) the process, here is the method I use to move, rename, clone or back up wordpress installations routinely - it should work for almost any standalone installation (ie. if you're trying to move a multisite you should probably go look for another guide).
These instructions should work whether you are
The basic steps are:
This requires that you have access to:
All decent hosting plans, and nearly all inexpensive shared hosting plans come with phpMyAdmin and FTP access. VPS', private servers etc. obviously comes with direct file and database access which will be even better (or at least faster).
If you do not have access to the above wherever your site is hosted, it is likely because you bought your site from someone who does not want you to move it away (usually because they designed your website for free or at a very low cost, and need you to stay with them to get back their investment). If that is the case you can try one of the many backup/migration plugins, but chances are they don't even allow you to install plugins, so you'll have to contact them and work out some agreement instead. (if you do not have access to your database, but you do have access to your files you can install phpMyAdmin yourself - but how to do that is way outside the scope of this answer)
Note that depending on what operation you are actually doing, some steps can be skipped - which you can feel free to do once you understand the process, and why each step is (sometimes) required - but if this is your first time just start from the top and work your way through each step.
You'll want to get all files in the "root" of your wordpress installation. That is the folder containing wp-content, wp-admin and wp-includes plus about 15-20 files. Make sure you get hidden files too (for example the file .htaccess will likely be hidden by default if you use FTP - in some cases this file is completely irrelevant, but in others it can be essential, so just make sure you get everything)
If your hosting provider has some sort of file manager you may want to try that first. A lot of file managers offer the option to up- or download folders as a single compressed archive - which will be a lot faster than downloading all files individually.
If you have a VPS or any solution with SSH or some other form of console access, use that and navigate to the "root" of your installation, then zip everything up - something like zip -r my_wp_backup.zip . should do. Download the file using whatever means you have.
If you only have FTP access to your files, it may take a while, but you simply log in with FTP (my favorite FTP client is FileZilla, because it's easy to use, and allows several simultaneous transfers... but any client should be fine). Navigate to the "root" of wordpress and transfer all files to a local folder on your computer (don't forget to show hidden files!)
If you have access to phpMyAdmin through your provider use that - it is by far the easiest, and I have never had a problem, except with extremely special databases or extremely old versions of phpMyAdmin.
Just log in to phpMyAdmin, select your database, click export and accept the defaults (options are very different depending on the version, but the defaults should be fine for any "normal" wordpress database). This should give you either a file download with a name ending in ".sql" - or a big text-field with huge amount of text in it. If you get the latter just copy it to a regular text file on your local computer - notepad, notepad++ or any other plain text editor will work (ie. don't use word, google docs or any other rich text editor!)
If you don't have access to phpMyAdmin you can either install it (which I'm not going to describe), or you must find some other way to export the database, for example:
mysqldump -u your_database_username -p your_db_name > my_backup.sql - if you don't know the name of your database, take a look in wp-config.php (also contains your username and password if you don't know those)You should now have a complete backup on your local disk.
phpinfo.php file above if your provider doesn't give you any clues)localhost is sufficient in most cases, but some providers have dedicated mysql-servers that require you to connect to some other hostname)Correct your wp-config.php file - the relevant lines are:
/** The name of the database for WordPress */
define('DB_NAME', 'your_database_name');
/** MySQL database username */
define('DB_USER', 'your_database_username');
/** MySQL database password */
define('DB_PASSWORD', 'your_database_password');
/** MySQL hostname */
define('DB_HOST', 'localhost');
Run Code Online (Sandbox Code Playgroud)
Though it's rather rare some plugins do write information in files that needs to be updated, so if the absolute path of your wordpress root folder, or the absolute URL of your installation is changing in the process of migrating you should also do a complete search and replace for those:
/var/www/www.example.com/web/blog and your new absolute path is /var/www/blog.example.com/public_html then search-and-replace those throughout all files. Do not include a trailing slash!http://www.example.com/blog and the new URL is going to be http://blog.example.com do a search for www.example.com/blog replacing with blog.example.com. Do not include http:// and do not include a trailing slash!Note that if for some reason you are in a situation where you do not know your old absolute path and/or URL you can find them in the database, so do step 5 first, and look in the prefix_options table for the values siteurl (your absolute URL) and upload_path will usually contain your absolute path (plus /wp-content/uploads) - if it doesn't then there will probably be other rows in the table that can tell you what the path was, look for something that starts with /var/www or /home/something.
As in step 1 your options may vary, but the point is to get all files uploaded to whatever folder is going to be your new root. Use whatever means you have available to do so.
Do not give in to the temptation to "try" the site out after uploading files - though unlikely it can have unforeseen consequences if you visit before all steps are completed!
Again, options vary:
SQL tab instead, and just paste the entire content directly in the big text field.mysql -u your_database_username -p your_new_db_name < my_backup.sqlIf you're restoring a backup to the same server and location you are done.
However, if you are migrating to a different server or a different URL you need to be aware that Wordpress itself, as well as a lot of plugins writes your absolute URL in a lot (thousands) of places in the database, and your absolute path is likely to also be present in at least a couple of rows.
You also need to be aware that a lot of plugins, as well as some core wordpress functions use the php function serialize to store complex data easily in the database. That format is very sensitive to changes, so a "regular" search and replace is very (very!) likely to break everything.
Luckily there is a free tool specifically designed with this in mind. I have no affiliation, but I cannot recommend interconnect/it database search and replace enough. It is well-maintained, super user friendly, and I have never personally experienced it mess anything up.
Download it using the link above, unzip it, rename the folder to something_random_for_security and upload it to your wordpress root folder. Then go to http://blog.example.com/something_random_for_security in your browser (obviously substituting relevant parts of the URL).
You'll be presented with a neat graphical interface, and it has probably already filled in your database details for you (by reading your wp-config.php).
At the top of the screen there's a search field and a replace field. Don't mess with anything else, unless of course it actually failed to get your database information automaticall.
Like for files you need to search for:
http:// and trailing slash)You can use the "Dry run" button first to see what will be changed, and if any obvious problems might arise - after that just click the "Live run" button and it'll chew through your entire database replacing in a serialize()-safe way where relevant.
If you have moved your site from one folder to another folder (or up or down a level), then permalinks/"pretty URLs" may not work (ie. your front page is fine but everything else is one big error). This is because of the rules in that "hidden" .htaccess-file getting "confused". The fix is very simple - just visit the "Settings" -> "Permalinks" in the wordpress admin... you don't need to make any changes, the file is automatically refreshed as soon as you visit the page.
Check that everything works, then go celebrate...
| 归档时间: |
|
| 查看次数: |
8168 次 |
| 最近记录: |