使用Curl发布xml时获得权限被拒绝? [英] Getting permission denied while Posting xml using Curl?

查看:114
本文介绍了使用Curl发布xml时获得权限被拒绝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将xml发布到某个Web服务要使用的URL。我正在使用Cent OS 5.6 Apache / 2.2.3(CentOS)。当我使用 curl-d @ abc.xml http://example.com 从命令行发布时,它给了我结果。但是,当我使用curl从php发布

I have to post a xml to a url to be consumed by some web service. I am using Cent OS 5.6 Apache/2.2.3 (CentOS). When I post from command line using curl-d@"abc.xml" http://example.com It gives me result. But when I post from php using curl

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);

它给我卷曲错误权限被拒绝。知道为什么我能从代码中获得此内容,同时又能够使用 curl -d 从CLI访问url。在此先感谢

It gives me curl error permission denied. Any idea why I am getting this from code while able to access the url from CLI using curl -d. Thanks in Advance

推荐答案

setsebool -P httpd_can_network_connect 1解决我的问题

setsebool -P httpd_can_network_connect 1 solve my problem

这篇关于使用Curl发布xml时获得权限被拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆