gpt4 book ai didi

php 页面给出 500 错误,但通过 ssh 执行有效

转载 作者:太空宇宙 更新时间:2023-11-04 05:15:09 25 4
gpt4 key购买 nike

我认为我错过了一些简单的事情:

在 EC2 Linux 实例上测试 mailgun 安装。

当我使用 putty session 时,以下代码有效:

php /var/www/html/[thefilebelow.php]

但是当我转到浏览器并使用时失败

http://myexample.com/[thefilebelow.php]

这会产生 500 错误

[thefilebelow.php]:

 # Include the Autoloader (see "Libraries" for install instructions)
require '/home/ec2-user/vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('kxxxxxxxxxx');
$domain = "mg.myexample.com";

# Make the call to the client.
$result = $mgClient->sendMessage($domain, array(
'from' => 'bob <info@lxxxxx.com>',
'to' => 'Steve <xxxxx@gmail.com>',
'subject' => 'Hello',
'text' => 'Testing some Mailgun awesomness!'
));

错误日志:

PHP Fatal error: require(): Failed op ning required '/home/ec2-user/vendor/autoload.php' (include_path='.:/usr/share/pear7:/usr/share/php7') in /var/www/html/myfilebelow.php on line 3

需要明确的是 - 所需文件的位置是正确的。

/var/www/htmlmyfilebelow.php ec2-user:www 的权限

/home/ec2-user/vendor/ec2-user:www 的权限

(包含文件和脚本的权限相同)

最佳答案

所以答案是,在 ec2 实例(通常在其他服务器上)上安装 Composer 时,如果登陆目录是您的用户目录,请确保在 putty 中打开 ec2-user session 时导航出登陆目录。

移动到/var/www/或 www 组拥有的其他目录。

关于php 页面给出 500 错误,但通过 ssh 执行有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50340796/

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