Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

解決 Apache 啟動報錯:Cannot load libphp5.so Permission denied

編輯:Linux 教學

重啟 Apache 時遇到 Cannot load /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied,根因通常是 SELinux 安全策略阻止了共享庫的內存映射權限。

方案一:永久禁用 SELinux(需重啟)

vi /etc/selinux/config
# 將 SELINUX=enforcing 改為 SELINUX=disabled
reboot

方案二:保持 SELinux 啟用,僅放行該庫(推薦,無需重啟)

setenforce 0                              # 臨時切許可模式
chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
service httpd restart                     # 驗證啟動
setenforce 1                              # 恢復強制模式

核心說明:chcon 將庫文件的安全上下文類型改為 textrel_shlib_t,允許共享庫在需要文本重定位時修改代碼段,從而通過 SELinux 檢查。此法精準解決問題,避免完全關閉 SELinux 降低系統安全性。

Copyright © Windows教程網 All Rights Reserved