我无法使用PHP连接到远程EC2服务器,因为我拒绝了权限。 不过,我可以通过命令行从同一台服务器远程连接,所以看起来防火墙设置是好的,bindIp也是正确的,所以似乎只有PHP有这个连接问题。 服务器是:
CentOS Linux release 7.1.1503 (Core) NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7" CentOS Linux release 7.1.1503 (Core) CentOS Linux release 7.1.1503 (Core)
我find了解决scheme。 看来httpd_can_network_connect默认是closures的。
运行以下命令启用:
$ sudo /usr/sbin/setsebool -P httpd_can_network_connect 1
并重新启动Apache:
$ sudo apachectl restart