如果剛安裝好CentOS需要檢查一下SELinux設定,如為Enforcing則除了本地端以為其他外連都無法連入主機需要修改才行,方法如下!
先用SSH連線進入主機,輸入以下查詢指令觀看目前的SELinux設定狀態!
# getenforce
SELinux 共有三種模式如下:
Enforcing:強制模式,依據設定來限制檔案資源存取。
Permissive:寬容模式,不限制檔案資源存取,但仍會依據設定檢查並記錄相關訊息。
Disabled:停用模式,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=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
#SELINUXTYPE=targeted //註解掉
然後再重新啟用CentOS,這樣外部連線就能進入網站主機了!!
重啟CentOS指令:# reboot
要檢查 SELinux 的狀態, 執行 sestatus 指令便可以看到:
# sestatus
關閉 Firewalld 防火牆:
關閉 Firewalld 防火牆指令:
# systemctl stop firewalld.service
設定下次開機不會啟動 Firewalld 防火牆
# systemctl disable firewalld.service
教學撰寫:徐嘉裕 Neil hsu
先用SSH連線進入主機,輸入以下查詢指令觀看目前的SELinux設定狀態!
# getenforce
SELinux 共有三種模式如下:
Enforcing:強制模式,依據設定來限制檔案資源存取。
Permissive:寬容模式,不限制檔案資源存取,但仍會依據設定檢查並記錄相關訊息。
Disabled:停用模式,SELinux 已被停用。
預設是Enforcing,要將其修改為Disabled
找到以下檔案/etc/selinux/config 打開編輯
# 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=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
#SELINUXTYPE=targeted //註解掉
修改紅字那一段,改成disabled
要檢查 SELinux 的狀態, 執行 sestatus 指令便可以看到:
# sestatus
關閉 Firewalld 防火牆:
關閉 Firewalld 防火牆指令:
# systemctl stop firewalld.service
設定下次開機不會啟動 Firewalld 防火牆
# systemctl disable firewalld.service
留言
張貼留言