啟用selinux後,php訪問網路異常

來源:互聯網
上載者:User

標籤:selinux   getenforce   php   centos7   

apache03的訪問測試連接http://admin.lt.mopgaming.com/auth/admin/login

ping和telnet指定相應連接埠測試能夠成功,

但是在防火牆開通,memcached和redis相應連接埠都已經放通的情況下,仍然測試連接不成功。

報錯:{"message":"Permission denied [tcp:\/\/198.44.240.242:6379]","code":5000,"data":null}{"message":"Undefined index: _sf2_meta","code":5000,"data":null}


問題原因開啟selinux

getsebool -a |grep httpd

[[email protected] ~]$ getsebool -a |grep -i httpd

httpd_anon_write --> off

httpd_builtin_scripting --> on

httpd_can_check_spam --> off

httpd_can_connect_ftp --> off

httpd_can_connect_ldap --> off

httpd_can_connect_mythtv --> off

httpd_can_connect_zabbix --> off

httpd_can_network_connect --> off

httpd_can_network_connect_cobbler --> off

httpd_can_network_connect_db --> off

httpd_can_network_memcache --> off

httpd_can_network_relay --> off

httpd_can_sendmail --> off

httpd_dbus_avahi --> off

httpd_dbus_sssd --> off

。。。

可以看到selinux限制httpd對外訪問的許可權

setsebool -P httpd_can_network_connect=1

即時生效,可以訪問


或者,對selinux不熟悉,直接關閉selinux

setenforce 0    即時生效

getenforce 

或者

/etc/sysconfig/selinux

    SELINUX=disabled直接關閉,重啟生效




啟用selinux後,php訪問網路異常

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.