WordPress:“HTTP 错误。” 上传文件时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4091063/
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: "HTTP Error." When Uploading Files
提问by Will D. White
I'm running WP 3.0.1 on a shared host using PHP5. I'm having issues uploading files that are a little larger via the media uploader in the admin section of WP.
我正在使用 PHP5 的共享主机上运行 WP 3.0.1。我在通过 WP 管理部分的媒体上传器上传稍大的文件时遇到问题。
Every time I try to upload a file thats over a few megabytes, it uploads, says its crunching, then gives me a big red "HTTP Error." - nothing more.
每次我尝试上传超过几兆字节的文件时,它都会上传,说它正在运行,然后给我一个大红色的“HTTP 错误”。- 仅此而已。
This only happens on files that are a little larger - ie a 20mb .mp3 file. A 5mb file seems to work fine. Whats weird is in the past we've uploaded 40mb files without a problem.
这只发生在稍大一点的文件上 - 即 20mb .mp3 文件。一个 5mb 的文件似乎工作正常。奇怪的是,过去我们上传了 40mb 的文件没有问题。
--
——
Here's the steps I've taken so far to try and remedy the situation:
到目前为止,我已经采取了以下步骤来尝试纠正这种情况:
- Double checked php.ini to ensure increase upload, post and memory size were high enough.
- Updated .htaccess to include filter the security mod I found elsewhere.
- Double checked all file permissions via ftp to ensure they were 755.
- Called the host - "They don't support 3rd party scripts" (I hate IPower)
- Tried with different audio files of similar size.
- Disabled all plugins
- 仔细检查 php.ini 以确保增加上传、发布和内存大小足够大。
- 更新了 .htaccess 以包含过滤我在别处找到的安全模块。
- 通过 ftp 仔细检查所有文件权限以确保它们是 755。
- 打电话给主持人——“他们不支持第 3 方脚本”(我讨厌 IPower)
- 尝试使用类似大小的不同音频文件。
- 禁用所有插件
--
——
Do you guys have any more ideas regarding what might be causing the vague "HTTP Error." problem?
你们对可能导致模糊的“HTTP 错误”的原因有更多想法吗?问题?
Thanks in advance.
提前致谢。
采纳答案by EAMann
The problem, as you've already inferred, is in the size of your file upload. Just to remind you, HTTP isn't really built for transferring large files ... it cando it, but not always, and not very well. You're running into an issue where your host is cutting off the transfer because the file is too large. It's most likely a server setting somewhere that you don't have access to.
正如您已经推断出的,问题在于您上传的文件的大小。提醒您一下,HTTP 并不是真正为传输大文件而构建的……它可以做到,但并非总是如此,也不是很好。您遇到的问题是您的主机因为文件太大而中断传输。这很可能是您无权访问的服务器设置。
Since "they don't support 3rd party scripts" I'm guessing you're in a shared hosting environment, which is why something could change on your server without you doing anything. Possible solutions:
由于“他们不支持 3rd 方脚本”,我猜您处于共享托管环境中,这就是为什么您的服务器可能会在您不做任何事情的情况下发生变化。可能的解决方案:
- Get a different host
- Use a dedicated server
- Transfer your larger files via FTP rather than from within WordPress.
- 换个主机
- 使用专用服务器
- 通过 FTP 而不是从 WordPress 内部传输较大的文件。
回答by William Turrell
I had a similar problem with Nginx and PHP5-FPM (and WordPress 4.1).
我在 Nginx 和 PHP5-FPM(以及 WordPress 4.1)上遇到了类似的问题。
Symptoms: the file (< 5MB, so relatively small) is partway through the transfer, as indicated by the progress bar, when suddenly you get the HTTP error message.
症状:文件(< 5MB,因此相对较小)在传输过程中,如进度条所示,突然收到 HTTP 错误消息。
Even if you've set upload_max_filesize
in your php.ini, you should also check post_max_size
is (at least) as big. Remember to restart php5-fpm.
即使你已经upload_max_filesize
在你的 php.ini 中设置,你也应该检查post_max_size
它(至少)一样大。记得重启php5-fpm。
If it still doesn't work, edit your nginx.conf
file (in Debian/Ubuntu it's /etc/nginx/nginx.conf) and add this in the httpblock:
如果它仍然不起作用,请编辑您的nginx.conf
文件(在 Debian/Ubuntu 中为 /etc/nginx/nginx.conf)并将其添加到http块中:
client_max_body_size 100m;
Then restart Nginx.
然后重启Nginx。
回答by Fanis
One of our clients, had the same issue.
我们的一位客户遇到了同样的问题。
Finally we found out that the wordpress "HTTP Error" when uploading images, was happening due to a change on the server side. The hosting comany, decided to add APC accelerate to the server in order to increase server's stability and speed. APC accelerate should work only with FastCGI and not with su, so they set PHP to run as FastCGI.
最后我们发现上传图片时出现 wordpress“HTTP 错误”,是由于服务器端发生了变化。托管公司决定为服务器添加APC加速,以提高服务器的稳定性和速度。APC 加速应该仅适用于 FastCGI 而不适用于 su,因此他们将 PHP 设置为作为 FastCGI 运行。
When using PHP as FastCGI, if you try to upload a file larger than 128KB, an error "mod_fcgid: HTTP request length 131388 (so far) exceeds MaxRequestLen (131072)" occurs and causes an 550 internal server error. This happens because the value of MaxRequestLen directive is set to 131072 bytes (128KB) by default. One way to correct this (if server uses Plesk), is to edit /etc/httpd/conf.d/fcgid.conf and set MaxRequestLen to a higher value, for example 15MB (MaxRequestLen 15728640). If server uses cPanel, this change can be done via the WHM of the server.
使用PHP作为FastCGI时,如果尝试上传大于128KB的文件,会出现“mod_fcgid:HTTP请求长度131388(目前)超过MaxRequestLen(131072)”的错误,导致550内部服务器错误。发生这种情况是因为 MaxRequestLen 指令的值默认设置为 131072 字节 (128KB)。纠正此问题的一种方法(如果服务器使用 Plesk)是编辑 /etc/httpd/conf.d/fcgid.conf 并将 MaxRequestLen 设置为更高的值,例如 15MB (MaxRequestLen 15728640)。如果服务器使用 cPanel,则可以通过服务器的 WHM 完成此更改。
So, if you can upload images up to 128KB, this is the solution to your problem.
因此,如果您可以上传最大 128KB 的图像,这就是您问题的解决方案。
回答by zuzuleinen
Put this line in your wp-config file:
将此行放在您的 wp-config 文件中:
define('WP_MEMORY_LIMIT', '64M');
回答by benna
I had the same issue whenever I tried to upload media, except I got the "HTTP Error" on files larger than 124Kb! WP 3.3.1, PHP 5.2.
每当我尝试上传媒体时,我都会遇到同样的问题,除了我在大于 124Kb 的文件上遇到“HTTP 错误”!可湿性粉剂 3.3.1,PHP 5.2。
I called my host and they upped memory to 64M (also changed this in wp-config) and upload_limit to 8 MB (default was 2 MB). This didn't work so I resorted to almost everything else, from tampering with the .htaccess to reinstalling WP to installing a fresh WP on another server, but everything pointed to a server issue. I called the host again and spoke to another technician who increased the allowed HTTP Request Length setting.
我打电话给我的主机,他们将内存提升到 64M(也在 wp-config 中更改了这一点)和 upload_limit 到 8 MB(默认为 2 MB)。这不起作用,所以我求助于几乎所有其他方法,从篡改 .htaccess 到重新安装 WP,再到在另一台服务器上安装新的 WP,但一切都指向服务器问题。我再次致电主机并与另一位增加了允许的 HTTP 请求长度设置的技术人员交谈。
回答by bwobbones
For future readers, just managed to find the solution to this one after a tough day of searching.
对于未来的读者,经过一天艰难的搜索,才设法找到了这个问题的解决方案。
There's a setting in the fcgid.conf file (for me in /etc/apache2/mods-enabled): FcgidMaxRequestLen
. See https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidmaxrequestlen
有一个在fcgid.conf文件(在/我等/ apache2的/启用MODS - )的设置:FcgidMaxRequestLen
。见https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidmaxrequestlen
I set that in bytes to an appropriate length and everything works. It seems that apache have changed their thinking on the default value (which is now 131072 bytes):
我以字节为单位将其设置为适当的长度,一切正常。看来 apache 已经改变了他们对默认值的想法(现在是 131072 字节):
Before 2.3.6, this defaulted to 1GB. Most users of earlier versions should use this directive to set a more reasonable limit.
在 2.3.6 之前,默认为 1GB。大多数早期版本的用户应该使用这个指令来设置一个更合理的限制。
回答by albaiti
server maybe have imagick installed as default library , for a fix for wordpress
服务器可能安装了 imagick 作为默认库,用于修复 wordpress
I put the following code into my functions.php
file. It works!
我将以下代码放入我的functions.php
文件中。有用!
add_filter( 'wp_image_editors', 'change_graphic_lib' );
function change_graphic_lib($array) {
return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
}
回答by sudip
For me, "http error" issue occurred when php is running in fast cgi mode.
对我来说,当 php 在快速 cgi 模式下运行时出现“http 错误”问题。
"MaxRequestLen" from mod_fcgid was limiting file upload size and wordpress was throwing "http error".
来自 mod_fcgid 的“MaxRequestLen”限制了文件上传大小,而 wordpress 则抛出“http 错误”。
You need to add the following configurations in your httpd.conf (apache2.conf on ubuntu 14) :
您需要在 httpd.conf(ubuntu 14 上的 apache2.conf)中添加以下配置:
<IfModule mod_fcgid.c>
# 20MB
MaxRequestLen 20000000
</IfModule>
回答by Crob
I tried all the commonly suggested php.ini changes as well as wp-config changes with no luck. Finally found someone suggesting to look at the XHR async-upload.php details in my browser and found out that our firewall was flagging the upload as a trojan (MalAgent.H_9218 to be specific) for some reason. So don't forget to check there, it could identify other possible upload issues as well.
我尝试了所有通常建议的 php.ini 更改以及 wp-config 更改,但没有成功。终于发现有人建议在我的浏览器中查看 XHR async-upload.php 的详细信息,并发现我们的防火墙出于某种原因将上传标记为木马(具体来说是 MalAgent.H_9218)。所以不要忘记检查那里,它也可以识别其他可能的上传问题。
Chrome instructions:Hit F12 and select the network tab, then attempt an upload with WordPress, make sure the filter row is on either All or XHR, in the left bottom pane find and select async-upload.php, in the right bottom pane select preview.
Chrome 说明:点击 F12 并选择网络选项卡,然后尝试使用 WordPress 上传,确保过滤器行在全部或 XHR 上,在左下窗格中找到并选择 async-upload.php,在右下窗格中选择预览。
回答by Ruslan Novikov
In my case solved by switching off Adblocker extentionin browser
在我的情况下,通过关闭浏览器中的Adblocker 扩展来解决