首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >POST https://kayaindia.in/kaya/sendNotificationB.php 500 (内部服务器错误)

POST https://kayaindia.in/kaya/sendNotificationB.php 500 (内部服务器错误)
EN

Stack Overflow用户
提问于 2019-04-26 14:39:37
回答 2查看 86关注 0票数 0

我正在创建一个PWA应用程序,它工作得很好,但当我试图上传到服务器时,我卡住了错误。在windows本地服务器上,一切都很好,即使是通知,我也不知道多少putty/linux命令。

检查here我的phpinfo文件。

我正在尝试上传到亚马逊ec2服务器。我安装了apache,php,ssl和其他所需的东西。及其除通知之外的工作文件。

当我调用我的通知文件时,我得到了503响应。我安装了composer,安装了所有东西。我使用的是this github库。

据我所知,我坚持使用gmp扩展,当我打开phpinfo()时,我没有看到那里有gmp。我使用sudo yum install php-gmp安装了gmp,我还在php.d中看到了一个名为20-gmp.ini的文件,其中包含extension=gmp。还使用sudo apachectl stopsudo apachectl start重启了apache服务器。

但是我还是得到了错误。并且我在phpinfo()中看不到gmp。

notificationb.php

代码语言:javascript
复制
<?php
require __DIR__ . '/vendor/autoload.php';
use Minishlink\WebPush\WebPush;
use Minishlink\WebPush\Subscription;

$subscription = Subscription::create(json_decode(file_get_contents('php://input'), true));

print_r($subscription);

$auth = array(
    'VAPID' => array(
        'subject' => 'https://github.com/Minishlink/web-push-php-example/',
        'publicKey' => file_get_contents(__DIR__ . '/scripts/keys/public_key.txt'), // don't forget that your public key also lives in app.js
        'privateKey' => file_get_contents(__DIR__ . '/scripts/keys/private_key.txt'), // in the real world, this would be in a secret file
    ),
);

$webPush = new WebPush($auth);

$res = $webPush->sendNotification(
    $subscription,
    "Welcome to Kaya. You can book Appointments and many more."
);

foreach ($webPush->flush() as $report) {
    $endpoint = $report->getRequest()->getUri()->__toString();

    if ($report->isSuccess()) {
        echo "[v] Message sent successfully for subscription {$endpoint}.";
    } else {
        echo "[x] Message failed to sent for subscription {$endpoint}: {$report->getReason()}";
    }
}

?>

如果你需要什么,尽管跟我说。我会在这里更新。

编辑1:我也尝试在/etc/php.iniphp.ini中添加gmp扩展,但仍然没有添加。

我想我在$subscription = Subscription::create(json_decode(file_get_contents('php://input'), true));上遇到了错误

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-04-27 17:38:44

我知道我在评论我自己的问题,因为我已经搜索了3-4天这个答案,我想我应该和每个人分享这个信息。

问题是,在linux中,PHP有不同的配置文件。主配置文件是php.ini。并在加载此文件和覆盖邮件文件后包含其他扩展名。这些额外的配置位于/etc/php.d/中(在我的例子中,这对于大多数人来说是常见的)。

所以仅仅重新启动apache服务器是不够的。我们还需要重新启动php-fpm。

重启php-fpm:sudo service php-fpm restart,然后重启apache:sudo apachectn restart

您可以查看更多here

票数 0
EN

Stack Overflow用户

发布于 2019-07-16 16:00:01

要在php.ini中应用更改,您需要重新启动apache服务器,还需要重新启动php。

代码语言:javascript
复制
sudo service php-fpm restart
sudo apachectn restart

有时,将更改应用到服务器也需要一些时间。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55862087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档