dongmimeng5500 2014-09-01 07:04
浏览 87
已采纳

为什么stomp不能在apache中运行?

  • Brief Intro

I'm now using stomp to connect with ActiveMQ based on a PHP site running on apache server. The Stomp can run in bash but can't run in apache.

  • Preparation

I install stomp by

pecl install stomp

and modify the php.ini with

extension=stomp.so

I have a 'index.php' like this:

<?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);
?>
  • Start Working

Firstly, I run with

$ php index.php

And it echo as my expectation:

$ php index.php
runing-connecting-finished.

Then I open it in browser:

http://localhost/index.php

It reports

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

I've searching resolution for this error all day... I guess apache block the request from stomp since it runs successfully in bash.

What should I do to fix this bug?

Thanks really.

  • 写回答

1条回答 默认 最新

  • duanfei9278 2014-09-01 09:29
    关注

    an experienced colleague called Justin get things done! Though not really understand this situation, I post my solution here:

    Firstly, I run sestatus:

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

    Justin told me to change settings in /etc/sysconfig/selinux to

    SELINUX=permissive
    

    Then I restart and run sestatus again:

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

    Finally things work!

    Linux stuff still seems a little magical for me. Who knows something about this please give an explanation about this.

    Thanks a lot.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 软件供应链安全是跟可靠性有关还是跟安全性有关?
  • ¥15 电脑蓝屏logfilessrtsrttrail问题
  • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)
  • ¥15 【求职】怎么找到一个周围人素质都很高不会欺负他人,并且未来月薪能够达到一万以上(技术岗)的工作?希望可以收到写有具体,可靠,已经实践过了的路径的回答?
  • ¥15 Java+vue部署版本反编译
  • ¥100 对反编译和ai熟悉的开发者。
  • ¥15 带序列特征的多输出预测模型
  • ¥15 Python 如何安装 distutils模块
  • ¥15 关于#网络#的问题:网络是从楼上引一根网线下来,接了2台傻瓜交换机,也更换了ip还是不行
  • ¥15 资源泄露软件闪退怎么解决?