【问题标题】:POST https://kayaindia.in/kaya/sendNotificationB.php 500 (Internal Server Error)POST https://kayaindia.in/kaya/sendNotificationB.php 500(内部服务器错误)
【发布时间】:2019-07-16 16:00:00
【问题描述】:

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

检查here我的phpinfo文件。

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

当我调用通知文件时,我收到了 503 响应。我安装了作曲家,安装了一切。我使用了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

<?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:我还尝试在php.ini 中添加gmp 扩展名/etc/php.ini,但仍未添加。

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

【问题讨论】:

    标签: php linux amazon-ec2 gmp


    【解决方案1】:

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

    问题是,在 linux 中,PHP 有不同的配置文件。主要的配置文件是 php.ini。它在加载此文件并覆盖邮件文件后包括其他扩展名。这些附加配置位于/etc/php.d/(在我的情况下,这在大多数情况下很常见)。

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

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

    您可以查看更多here

    【讨论】:

      【解决方案2】:

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

      sudo service php-fpm restart
      sudo apachectn restart
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-01-06
        • 1970-01-01
        • 1970-01-01
        • 2011-11-27
        • 1970-01-01
        • 2014-09-24
        • 2020-10-01
        • 2018-01-15
        相关资源
        最近更新 更多