Apache and PHP are installed on the Linux machine.

In a third-party (obviously good) PHP code, there is a socket call to an external service. A service from the host where PHP is running is available (you can, for example, touch it with a telnet), but PHP cannot reach it:

Warning: fsockopen () [function.fsockopen]: unable to connect to example.net:43 (Permission denied)

Other hosts / ports are also unavailable.

allow_url_fopen in php.ini allowed.

I looked at tcpdump ohm - when executing a problem PHP code, no traffic towards the target host takes off at all.

Firewall is disabled.

Where to dig?

    1 answer 1

    The problem may be in SElinux, which controls the access to the network of various applications.

    Check if SELinux is enabled:

     /usr/sbin/sestatus -v 

    Allow network access:

     setsebool httpd_can_network_connect=1 

    or so:

     setsebool -P httpd_can_network_connect 1 

    If the command does not apply, you should try to execute it while the Apache daemon is stopped. After its successful execution and launch of Apache, external connections via sockets in PHP will work.