我必须将 xml 发布到 url 以供某些 Web 服务使用。我正在使用 Cent OS 5.6 Apache/2.2.3 (CentOS)。当我使用 curl-d@"abc.xml"http://example.com
从命令行发布时,它给了我结果。但是当我使用 curl 从 php 发布时
$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 错误 permission denied
。知道为什么我从代码中获取这个同时能够使用 curl -d
从 CLI 访问 url。提前致谢
最佳答案
这解决了我的问题
setsebool -P httpd_can_network_connect 1
关于php - 使用 Curl 发布 xml 时获取权限被拒绝?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25338295/