gpt4 book ai didi

php - Apache2 内部服务器错误 500

转载 作者:太空宇宙 更新时间:2023-11-03 17:10:52 26 4
gpt4 key购买 nike

我的 imagecreatefrompng 函数有问题,它之前在共享主机上工作但是当我将它迁移到安装在 ubuntu 上的 apache2 和 php5 时它没有加载内部服务器错误 500

PHP 版本 5.5.9 Apache 2.4托管在 Ubuntu 上

<?php
//Set the Content Type
header('Content-type: image/jpeg');

// Create Image From Existing File
$jpg_image = imagecreatefrompng('icon.png');

// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 0, 0, 0);

// Set Path to Font File
$font_path = 'OpenSans-Bold.ttf';

// Set Text to Be Printed On Image
$text = "1";

// Print Text On Image
imagettftext($jpg_image, 10, 0, 18, 20, $white, $font_path, $text);
imagesavealpha($jpg_image, true);
// Send Image to Browser
imagepng($jpg_image);

// Clear Memory
imagedestroy($jpg_image);
?>

我试过了

1- 多次重启 Web 服务器 Apache22- 更改图像文件以验证文件是否已损坏3- 在 php5 中安装一些与图像相关的组件,如 php5-imagick 或 php5-exactimage4- 在 apache2.conf 中将 EnableSendFile 设置为 Off5- 尝试将代码放入 try catch 但未能捕获异常

我无法解决这个问题?我需要安装任何 php 组件或升级任何东西吗?

谢谢,

问候,

最佳答案

我明白了,其实我并没有安装PHP5的GD组件。要将此库用于 PNG 和 JPEG 文件,必须安装 GD 组件。

关于php - Apache2 内部服务器错误 500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37055716/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com