从PHP执行git时无法使用代理?

We are calling a bash script from PHP that will do a simple git pull. When we run this script from terminal using root or the apache user it executes fine. However, when php excecutes the script using exec it outputs this error:

error: Failed to connect to XX.XX.XX.XX: Permission denied while accessing https://someuser@bitbucket.org/somecompany/testproject.git/info/refs

XX.XX.XX.XX is the IP address our http proxy resolves to

It also prints out the user and proxy config (as you will see in the bash script below)

PHP:

chdir('/var/www/scripts');
$cmd = './gitBranch.sh 2>&1';
exec($cmd,$currentOutput,$err);
print_r($currentOutput);

BASH:

#!/bin/bash

cd /var/www/gitManagedPackages/testproject

whoami #to verify it's the apache user
git config --get http.proxy #to verify it has the proper proxy setting
git pull

When running the script as the apache user [su -c ./gitBranch.sh -s /bin/sh apache]

apache
http://someproxy.somecompany.net:8181
Already up-to-date.

Why does it fail when running from PHP? It's executing as the apache user and has the correct proxy set.

As it turns out, httpd is not allowed to make outgoing connections by default. The outputted error is actually from git's use of curl.

running this fixed it:

setsebool -P httpd_can_network_connect 1