Linux下安装Apache和PHP报错

[root@ htdocs]# uname -a
Linux guidang.dns.com.cn 2.6.33.5 #1 SMP Tue Jun 8 20:38:22 CST 2010 i686 i686 i386 GNU/Linux

循规蹈矩的按操作步骤安装完之后,进行测试,就出现了如下报错:

[root@ php-5.2.3]# /usr/local/apache/bin/apachectl start
httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

在网上找了一些解决办法

1关闭SELINUX的方法:
vi /etc/selinux/config 将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

找到解决办法就尝试了一下:

[root@ conf]# /usr/sbin/setenforce 0
[root@ conf]# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
context of /usr/local/apache/modules/libphp5.so changed to system_u:object_r:textrel_shlib_t

再次启动apache,失败

[root@ conf]# /usr/local/apache/bin/apachectl start
httpd: bad user name vpopmail

这个apache是我们自己编译过的,是按照我们的生产要求来的,以vpopmail的身份进行启动的

[root@ conf]# /usr/sbin/adduser  vpopmail

第三次启动仍然失败

[root@ conf]#  /usr/local/apache/bin/apachectl start
httpd: bad group name vchkpw

原来是vpopmail用户属于vchkpw组

[root@ conf]#  /usr/sbin/groupadd vchkpw

启动成功:

[root@ conf]#  /usr/local/apache/bin/apachectl start

检查进程:

[root@ conf]# ps -aux |grep http|grep -v grep
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root     21103  0.0  0.2  19316  8424 ?        Ss   13:52   0:00 /usr/local/apache/bin/httpd -k start
vpopmail 22383  0.0  0.1  19316  7348 ?        S    14:03   0:00 /usr/local/apache/bin/httpd -k start
vpopmail 22384  0.0  0.1  19316  7328 ?        S    14:03   0:00 /usr/local/apache/bin/httpd -k start

还有之前遇到的一些apache启动问题,不过这个问题应该是比较少见的

[root@gbackup2 htdocs]# /usr/local/apache/bin/apachectl start
httpd: apr_sockaddr_info_get() failed for gbackup2.dns.com.cn
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

查看结果是:
[root@gbackup2 htdocs]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=gbackup2.dns.com.cn
GATEWAY=119.254.72.129


[root@gbackup2 htdocs]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1        gbackup.dns.com.cn gbackup localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6


以上两个配置文件中的主机名不一致,而运行一下命令可以得知hosts文件配置错了
[root@gbackup2 htdocs]# hostname
gbackup2.dns.com.cn

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywwsd.html