【问题标题】:Why stomp can't run in apache?为什么stomp不能在apache中运行?
【发布时间】:2014-09-01 07:04:11
【问题描述】:
  • 简介

我现在正在使用 stomp 连接基于在 apache 服务器上运行的 PHP 站点的 ActiveMQ。 Stomp 可以在 bash 中运行,但不能在 apache 中运行。

  • 准备

我通过

安装 stomp
pecl install stomp

并用

修改php.ini
extension=stomp.so

我有一个像这样的“index.php”:

<?php
echo 'runing-';
/* connection */
try {
    $stomp = new Stomp('tcp://localhost:61613');
    echo 'connecting-';
} catch(StompException $e) {
    die('Error! Connection failed: ' . $e->getMessage());
}
$stomp->send('/queue/test', 'Hello from PHP');
echo 'finished.';
/* close connection */
unset($stomp);
?>
  • 开始工作

首先,我运行

$ php index.php

这和我的预期一致:

$ php index.php
runing-connecting-finished.

然后我在浏览器中打开它:

http://localhost/index.php

它报告

runing-Error! Connection failed: Unable to connect to localhost:61613
  • 问题

我整天都在寻找解决此错误的方法... 我猜 apache 会阻止来自 stomp 的请求,因为它在 bash 中成功运行。

我应该怎么做才能修复这个错误?

真的谢谢。

【问题讨论】:

    标签: php apache stomp selinux


    【解决方案1】:

    一个叫贾斯汀的有经验的同事把事情做好! 虽然不是很了解这种情况, 我在这里发布我的解决方案:

    首先,我运行 sestatus

    $ sestatus
    SELinux status:                 enabled
    SELinuxfs mount:                /selinux
    Current mode:                   enforcing
    Mode from config file:          enforcing
    Policy version:                 24
    Policy from config file:        targeted
    

    贾斯汀告诉我将 /etc/sysconfig/selinux 中的设置更改为

    SELINUX=permissive
    

    然后我重新启动并再次运行 sestatus

    $ sestatus
    SELinux status:                 enabled
    SELinuxfs mount:                /selinux
    Current mode:                   permissive
    Mode from config file:          permissive
    Policy version:                 24
    Policy from config file:        targeted
    

    终于成功了!

    Linux 的东西对我来说仍然有点神奇。 哪位大神能解释一下。

    非常感谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 2012-09-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-18
      相关资源
      最近更新 更多