上传图片时如何解决HTTP错误?
-
-
`AddType x-mapp-php5 .php`背后的原因是什么?这似乎是特定于服务器的.我认为它更有可能破坏您的网站(例如PHP)(或者如果您很幸运,请"不做任何事情"),而不是进行任何改进?What is the reasoning behind `AddType x-mapp-php5 .php`? That would seem to be very server specific. I would think it is more likely to break your site (ie. PHP) horribly (or _do nothing_ if you are lucky) rather than improving anything?
- 0
- 2018-01-01
- MrWhite
-
6 个回答
- 投票数
-
- 2012-07-26
在聊天中使用@Wyck进行故障排除后,我们已将范围缩小到了根本问题.
问题与我的服务器配置有关,没有为Apache/PHP分配适当的内存.
如果有人遇到同样的问题,请尝试验证服务器配置设置中是否为Apache/PHP分配了足够的(64 MB +)服务器内存.您也可以将其添加到wp-config.php文件中:
define('WP_MEMORY_LIMIT', '64MB');
如果上述解决方案不起作用,请阅读文章 图片/Media Uploader问题? 进行进一步的故障排除.
尝试将以下.htaccess调整中的一项或全部添加到WordPress安装根目录中的.htaccess文件中.
请认真尝试以下每种解决方案之一,以使您知道是哪种解决方案.不要只是将它们全部立即粘贴到您的.htaccess文件中.
尝试以下行:
AddType x-mapp-php5 .php
mod_security 可能引起问题.禁用它以查看是否是问题所在.为此,请在您的wp-admin目录中创建一个.htaccess文件.将此添加到它:
<IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule>
如果您在Web服务器上使用基于身份验证的访问控制(通常称为htpasswd,基本身份验证,受密码保护的目录或类似名称),则WordPress无法为Flash Uploader,Cron和XMLRPC处理它.需要排除相关文件才能工作.请记住,这可能会破坏您的安全性考虑.
# Exclude the file upload and WordPress CRON scripts from authentication <FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$"> Satisfy Any Order allow,deny Allow from all Deny from none </FilesMatch>
最后一点:有人说,如果使用较低版本的PHP 5.3.X,可以尝试禁用PHP安全模式.
如果您正在运行WordPress多站点并且收到与图像上传有关的HTTP错误或内部服务器错误,请阅读 将图像上传到多站点导致HTTP错误失败),以获取其他可能的故障排除想法和解决方案.
After troubleshooting with @Wyck in chat, we have narrowed to the underlying issue.
The issue was related to my server configuration not having the proper amount of memory allocated to Apache/PHP.
If anyone has this same problem, please try verifying that you have enough (64 MB+) server memory allocated to Apache/PHP in your server configuration settings. You can also add this to your wp-config.php file:
define('WP_MEMORY_LIMIT', '64MB');
If the above solution does not work, read the article Image/Media Uploader problems? for further troubleshooting.
Try adding one by one or all of the following .htaccess tweaks to the .htaccess file in the root directory of your WordPress installation.
Seriously, try one of each of the solutions below so you know which one did the trick. Don't just paste them all in your .htaccess file immediately.
Try this line:
AddType x-mapp-php5 .php
mod_security might be causing problems. Disable it to see if that is the problem. To do this, make an .htaccess file in your wp-admin directory. Add this to it:
<IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule>
If you're using access control based on authentication on your Webserver (often known as htpasswd, basic authentication, password protected directory or similar), WordPress is not able to handle it for Flash Uploader, Cron, and XMLRPC. Related files need to be excluded to work. Keep in mind that this might break your security considerations.
# Exclude the file upload and WordPress CRON scripts from authentication <FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$"> Satisfy Any Order allow,deny Allow from all Deny from none </FilesMatch>
One final note: some have said that if using a lesser version of PHP 5.3.X you can try disabling PHP Safe Mode.
If you are running WordPress multi-site and are receiving HTTP errors or internal server errors, related to image uploading, please read Uploading Images to Multi-Site Causes Failure to HTTP Error) for other possible troubleshooting ideas and solutions.
-
好的...知道...您是否读过WP尝试分配最多256MB的内存,所以如果可能,此`define('WP_MEMORY_LIMIT','64MB');`应该更大.ok ... good to know ... did you read that WP tries to allocate up to 256MB of ram so this `define('WP_MEMORY_LIMIT', '64MB');`should be larger if possible.
- 0
- 2012-07-26
- Damien
-
如果您使用的是WP 4.1.1,则AddType x-mapp-php5 .php不再是可行的解决方案,因为它会强制页面将PHP代码简单地打印为纯文本.If you're using WP 4.1.1, the `AddType x-mapp-php5 .php` is no longer a viable solution as it forces the page to simply print the PHP code as plain text
- 1
- 2015-03-27
- cameronjonesweb
-
如果您使用的是nginx,则将其添加到您的网站配置文件中:```client_max_body_size 128m;```Or add this to your sites config file if you are using nginx: ```client_max_body_size 128m;```
- 1
- 2015-06-28
- Flatron
-
- 2014-04-30
我将以下代码放入我的
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' ); }
这有帮助的原因是因为它更改了用于处理用于WordPress的上载图像的PHP代码模块.
此处理过程包括将图像移到媒体库数据库中并生成WordPress始终希望主题可访问的大小不同的图像("缩略图","中","大").
因为它是第一个,所以将使用" GD"模块.在某些服务器设置中,对于某些图像场景(例如大像素尺寸),较新的" Imagick"库不能与其他库配合使用,因此,强制使用" GD"库是一个解决方法.
I put the following code into my
functions.php
file. It works!add_filter( 'wp_image_editors', 'change_graphic_lib' ); function change_graphic_lib($array) { return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); }
When this helps it is because it changes the PHP code module used for processing the uploaded image for use with WordPress.
This processing includes moving the image into the media library database and generating the different size images ("thumbnail", "medium", "large") that WordPress always wants available for themes to access.
It causes the "GD" module to be used, because it is first. In some server setups, the newer "Imagick" library isn't playing well with others for certain image scenarios, such as large pixel dimensions, so forcing the "GD" library to be used is a fix.
-
创建一个小插件比将其放入`functions.php`中更好,因为如果更改主题,则会丢失代码.而且我确定您希望在更改主题后可以使用此功能It's better to create a little plugin than putting it in the `functions.php`, because if you change the theme, you lose the code. And I'm sure you want this working after a theme change
- 0
- 2018-01-15
- EliasNS
-
+1在新HostGator帐户上使用现成的WP 4.9.4设置解决此问题时,这对我有用.@EliasNSnoob在这里;为此制作一个小插件的正确方法是什么?+1 This worked for me when running in to this problem with an out-of-the-box WP 4.9.4 setup on a new HostGator account. @EliasNS noob here; what's the right way to make a little plugin for this?
- 1
- 2018-02-27
- Andrew Janke
-
@AndrewJanke,您可以使用插件https://es.wordpress.org/plugins/pluginception/@AndrewJanke, you could use a plugin https://es.wordpress.org/plugins/pluginception/
- 0
- 2018-02-27
- EliasNS
-
*"想像" *?不是*" ImageMagick" *吗?*"Imagick"*? Not *"ImageMagick"*?
- 0
- 2019-06-08
- Peter Mortensen
-
- 2014-05-30
当尝试在wordpress中上载媒体时,我遇到了相同的错误.在Chrome中,它显示为http:错误;在Firefox中,错误看起来大不相同.网络上有很多人花了很多时间来追查该错误的故事(I :-().解决方案比比皆是,但没人能解释原因,至少不是以与症状相符的方式.
我的杰出贡献:我注意到该问题与apache2日志文件中指示的分段错误有关.这使我不安,因为很难诊断.
重新启动整个服务器消除了所有症状,突然之间,我可以在Wordpress中再次上传媒体.令人沮丧的是,我不知道为什么会这样.重新启动实际上使我无法进行任何进一步的研究,而现在我必须等待(几周或几个月?),问题才能再次出现.我希望这将有助于其他人寻找此问题的原因.不过,我的妻子很高兴,因为我再也无法花时间追求这个问题了……
I ran into the same error, when trying to upload media in wordpress. In Chrome, it shows up as a http: error; in Firefox, the error looks quite different. The web is full stories of people who have spent days to chase the bug (so have I :-( ). Solutions abound, but nobody explains why, at least not in a way that is consistent with the symptoms.
My tuppence worthy contribution: I noticed that the problem correlates with a segmentation fault signalled in the log file of apache2. That disturbs me, because it is difficult to diagnose.
Rebooting the entire server took away all symptoms and all of a sudden I could upload media again in Wordpress. Frustratingly, I have no clue as to why this occurs. The reboot effectively stopped me from any further research, and I will now have to wait (weeks? months?) for the problem to reappear. I hope this will help others in their quest for the cause of this problem. My wife is happy, though, because I can no longer spend nights chasing this problem...
-
- 2013-10-29
我通过将所有者从
root
更改为apache
来解决此问题.chown -R apache:apache /var/www/html/mydomain
然后我将
wp-content/uploads/
的权限更改为775
.之后,我尝试将图像上传到媒体中.我成功上传了图片.
I have resolved this issue by changing my owner from
root
toapache
as below.chown -R apache:apache /var/www/html/mydomain
And then I have change the permission of the
wp-content/uploads/
to775
.After that, I have tried to upload an image in the media. I was successful to upload the image.
-
- 2018-03-29
我有同样的问题.我尝试了各种修复程序,包括使用 Force Image Magick插件将默认图像处理器从PHP GD更改为ImageMagick
这有助于解决HTTP错误/500错误,但不再生成缩略图.然后,我再次停用了该插件,然后对 answer 的回答帮助了我://wordpress.stackexchange.com/q/17526/103228">看起来像图像调整大小无法正常工作.我的
PHP_MEMORY_LIMIT
设置为160MB
,这是托管人允许的绝对最大值.对于上传图像,使用PHP GD并生成缩略图时,图像的最大可能尺寸约为
6000 x 6000 px
.因此,不仅要检查文件大小,而且还要检查图像的大小,这一点很重要.上载较大尺寸的图像会导致HTTP错误/错误500,即使文件很小.I had the same issue. I tried various fixes, including changing the default image processor from PHP GD to ImageMagick using the Force Image Magick Plugin
This helped with the HTTP Error / the 500 error but thumbnails were no longer being generated. I then deactivated the plugin again and what then helped me was this answer on the question Looks like image resize is not working well. My
PHP_MEMORY_LIMIT
was set to160MB
which is the absolute maximum my hoster allows.For uploading images this resulted in maximum possible dimensions of the image of around
6000 x 6000 px
when using PHP GD and generating thumbnails. So it's important to not only check the file size but also the dimensions of the image. Uploading an image with higher dimensions resulted in an HTTP Error / error 500 even with small file sizes. -
- 2019-10-07
我已经经历过多次这样的问题,并通过在php.ini中增加
memory_limit = 256M
或在其中添加define( 'WP_MEMORY_LIMIT', '256M' );
wp-config.php
文件(*如果需要,可以将内存增加到256M
以上).另一种可能的解决方案是授予
\wp-content\uploads\
文件夹权限;命令:chmod -R 0755 wp-content\uploads\
.希望对您也有帮助.
I've experienced such issue many times and solved by increasing
memory_limit = 256M
in php.ini OR addingdefine( 'WP_MEMORY_LIMIT', '256M' );
inwp-config.php
file (*If needed you can increase memory more than256M
) most of the time.Another possible solution could be giving permission to
\wp-content\uploads\
folder; command:chmod -R 0755 wp-content\uploads\
.Hope it may help you too.
我正在使用Apache和PHP 5.3.X在Ubuntu 12.04上使用WordPress 3.4.1
当我登录到仪表板并添加新帖子时.然后尝试上传图片以设置为特色图片,我会看到一个红色框,显示一条消息" HTTP错误".
我已经读到有人说不要使用Flash上传器,而只是使用浏览器上传器,但是当我尝试这样做时,我只会收到500 Internal Server Error.
我尝试在.htaccess文件的顶部添加
AddType x-mapp-php5 .php
,但没有任何变化.禁用所有插件均无效. 我尝试重新安装.没有运气.
更新10/17/2016- 如果您使用的是自定义角色或功能,请尝试使用本机角色/功能,然后重试.
要检查的内容:
如果要在代理后面进行操作,请确保正确配置了代理服务器超时.