【问题标题】:Apache2 Internal Server Error 500Apache2 内部服务器错误 500
【发布时间】:2016-08-31 13:02:39
【问题描述】:

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

PHP 版本 5.5.9 阿帕奇 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 Server Apache2 2-更改图像文件以验证文件是否已损坏 3- 在 php5 中安装一些与图像相关的组件,例如 php5-imagick 或 php5-exactimage 4- 在 apache2.conf 中将 EnableSendFile 设置为 Off 5-尝试将代码放入try catch但无法捕获异常

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

谢谢,

问候,

【问题讨论】:

    标签: php apache ubuntu webserver apache2.4


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-08-08
      • 2015-09-30
      • 1970-01-01
      • 1970-01-01
      • 2023-02-23
      • 2019-11-25
      • 1970-01-01
      • 2018-11-23
      • 2019-01-17
      相关资源
      最近更新 更多