Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';在PHP(Apache2)中呈现动态创建的图像_Php_Linux_Apache_Mime Types_Captcha - Fatal编程技术网

Can';在PHP(Apache2)中呈现动态创建的图像

Can';在PHP(Apache2)中呈现动态创建的图像,php,linux,apache,mime-types,captcha,Php,Linux,Apache,Mime Types,Captcha,我尝试在页面上呈现验证码图像,如下所示: <img src="part/captcha_image.php?rand=<?php echo rand(); ?>" id='captchaimg' alt="captcha image"> 在xampp上的windows机器上,它的显示没有任何问题,但在带有手动apache2安装映像的linux上,不会呈现,并且在浏览器的开发人员工具中,我看到以下错误: 加载资源失败:服务器响应状态为500(内部服务器错误)(显示在chr

我尝试在页面上呈现验证码图像,如下所示:

<img src="part/captcha_image.php?rand=<?php echo rand(); ?>" id='captchaimg' alt="captcha image">
在xampp上的windows机器上,它的显示没有任何问题,但在带有手动apache2安装映像的linux上,不会呈现,并且在浏览器的开发人员工具中,我看到以下错误:

加载资源失败:服务器响应状态为500(内部服务器错误)
(显示在chrome和firefox上)

http://localhost/app/part/captcha_image.php?rand=1653484771 未能加载资源:net::ERR\u CACHE\u MISS
(仅在chrome上显示)


我遗漏了什么?

这个问题似乎在评论中得到了回答。对于这样的问题,请确保在PHP的配置中打开详细的错误报告,并直接在浏览器地址栏中点击图像的URL


如果您这样做了,事实上问题是您需要
gd
,并且
gd
缺失,那么错误页面会告诉您。

正如@Cheery在评论中建议的那样,我缺失了
. 命令
sudo apt get install php5 gd&&sudo service apache2 restart
修复了我的问题。

您使用的是chrome,对吗?请参阅:&这是正确的。我已经在firefox上测试了我的页面,并编辑了我的问题,结果显示(firefox上没有显示ERR_CACHE_MISS)你是否安装了带有gd模块的php?@Cheery,好先生,你刚刚救了我一天
sudo apt get install php5 gd&sudo service apache2 restart
修复了我的问题。感谢您的建议!我是否更正了
错误报告(-1)函数调用打开详细报告?是的,这就是我的意思。但我只是在项目的开发实例中,使用
php.ini
中的适当设置全局地保持它。
header('Content-Type: image/jpeg'); // defining the image type to be shown in browser widow
imagejpeg($image); //showing the image