使用 Curl 发布 xml 时获得权限被拒绝?

Pun*_*eet 3 php xml curl

我必须将 xml 发布到某个 Web 服务要使用的 url。我使用 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);
Run Code Online (Sandbox Code Playgroud)

它给了我 curl 错误permission denied。知道为什么我从代码中得到这个,同时能够使用curl -d. 提前致谢

Pun*_*eet 5

setsebool -P httpd_can_network_connect 1 解决我的问题