centos安装php后apache不能启动的解决办法:1、编辑“/etc/sysconfig/selinux”,添加“SELINUX=disabled”;2、不关闭SELINUX即可。
本文操作环境:centOS6.8系统、PHP5版,DELL G3电脑
在安装完成PHP后, 重新启动apache报如下错误
原因是Linux有一个SELinux保护模式引起的。
立即学习“PHP免费学习笔记(深入)”;
Syntax error on line 268 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
解决办法
1.编辑/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 - SELinux is fully disabled. SELINUX=enforcing
如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。
2.不关闭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
推荐学习:《PHP视频教程》
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号