简体   繁体   English

imagecreate函数在Amazon EC2环境中不起作用

[英]imagecreate function not working on amazon ec2 environment

I have created an amazon machine running linux installed apache php gd and i was running this php code it was like this 我已经创建了一个运行Linux的亚马逊机器,安装了apache php gd,我正在运行这个php代码,就像这样

<?php
create_image();
print "<img src=image.png>";

function  create_image(){
        $im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream");
        $background_color = imagecolorallocate($im, 255, 255, 0);   // yellow

        $red = imagecolorallocate($im, 255, 0, 0);                  // red
        $blue = imagecolorallocate($im, 0, 0, 255);                 // blue
        imageline ($im,   5,  5, 195, 5, $red);
        imageline ($im,   5,  5, 195, 195, $blue); 

        imagepng($im,"image.png");
        imagedestroy($im);
}
?>

works fine on my local machine but i get 500 internal server error when i uploaded it to ec2 instance after i did some research i installed automake19 on the machine and this time php codes are running but the image is not being made i even tried several other codes which make image file but none of them made image can any body tell me whats wrong im doing and what more should ps notei install permissions of the directory is set to 755 在我的本地机器上可以正常工作,但是当我做了一些研究之后将其上传到ec2实例时,我得到了500个内部服务器错误,我在机器上安装了automake19,这一次php代码正在运行,但是图像没有被制作,我什至尝试了其他几个可以生成映像文件但没有一个可以生成映像的代码,任何人都可以告诉我即时通讯做错了什么,并且该目录的ps notei安装权限还应该设置为755

Try to install libgd extension. 尝试安装libgd扩展名。

sudo yum install php-gd

Restart your server after installation. 安装后重新启动服务器。

Default Amazon EC2 Linux PHP config does not come with GD library installed. 默认的Amazon EC2 Linux PHP配置未安装GD库。 Run command as per Stanley's suggestion. 按照史丹利的建议运行命令。 See PHP documentation , GD lib is required to create and manipulate images. 请参阅PHP文档 ,创建和处理映像需要GD lib。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM