今天終於有時間想自己撘一套LNMP開發環境,由於之前的開發環境都是公司現有的,用的時候改改配置就OK了,感覺很輕鬆的,但是自己親自動手從安裝虛擬機器到最後一步步搭建LNMP,竟然困難重重,務必腳踏實地,絕對不能眼高於頂。
言歸正傳,就在按照前輩的博文,一步步yum完了nginx和php-fpm之後,想要將項目用的fastcgi連接埠改為非預設的90001的時候,詭異的事情出現了
[root@localhost ~]# service php-fpm start Starting php-fpm: [18-Nov-2015 22:41:44] ERROR: unable to bind listening socket for address '127.0.0.1:9001': Permission denied (13)[18-Nov-2015 22:41:44] ERROR: FPM initialization failed [FAILED]
明明是root使用者,明明9001連接埠沒被佔用,怎麼會沒有許可權。百思不得其解
原因竟然是Centos核心中啟用了SELinux
[root@localhost ~]# cat /etc/sysconfig/selinux # This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=enforcing#SELINUX=disabled# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targeted
將SELINUX=enforcing改為SELINUX=disabled並重啟系統 就可以了
何為SELinux。什麼時候需要啟用SELinux,什麼時候不啟用。