linux 中apache服务启动相关分析

apache服务不能启动一般有二种可能:

1.

启动apache时出现

[[email protected] apache2]# /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server‘s fully qualified domain name, using 121.10.40.155 for ServerName

现在提供该问题的解决方法

1)进入apache配置文件的目录:(视个人安装情况而不同)

[[email protected] /]# cd /etc/httpd //我安装时配置文件所在的目录为/etc/httpd

2)编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80

[[email protected] httpd]# ls
conf.d  extra  httpd.conf  magic  mime.types  original

[[email protected] httpd]# vi httpd.conf

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn‘t have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
更改为:

ServerName localhost:80

3)再重新启动apache 即可。

[[email protected] httpd]# /usr/local/apache2/bin/apachectl restart

OK,启动成功啦!

2.如果上面的方法还是不能解决,还是提示faild,那么请看下面的方法

查看日志:

root账号下查看httpd的日志, 例如 /etc/httpd/logs/nss_error_log .

[Mon Jun 15 18:11:47 2015] [error] Unable to verify certificate ‘Server-Cert‘. A
dd "NSSEnforceValidCerts off" to nss.conf so the server can start until the prob
lem can be resolved.
[Mon Jun 15 18:13:23 2015] [error] Certificate not verified: ‘Server-Cert‘
[Mon Jun 15 18:13:23 2015] [error] SSL Library Error: -8181 Certificate has expi
red

根据提示,是证书过期导致。

问题分析

1> 上述日志中已经提示,可加入NSSEnforceValidCerts off 禁止校验证书的参数来避免该问题。经确认,这是可行的。

查看证书的有效时间

[[email protected] ~]# certutil -d /etc/httpd/alias -L -n Server-Cert
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 3 (0x3)
Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
Issuer: "CN=Certificate Shack,O=example.com,C=US"
Validity:
Not Before: Wed Jun 08 17:51:54 2011
Not After : Mon Jun 08 17:51:54 2015

看来证书的有效时间是4年

这是在安装mod_nss 包时生成的:

# rpm -q mod_nss --scripts
postinstall scriptlet (using /bin/sh):
umask 077

if [ "$1" -eq 1 ] ; then
    if [ ! -e /etc/httpd/alias/key3.db ]; then
        /usr/sbin/gencert /etc/httpd/alias > /etc/httpd/alias/install.log 2>&1
        echo ""
        echo "mod_nss certificate database generated."
        echo ""
    fi
fi

2> 由于这台机器部署的时间很早,证书在2012年12月1日到期了。但之前没有重启HTTPD服务,没发现问题。而在最近重启机器时,故障才显现出来。

 解决问题
既然原因已知道,解决就很简单了,方法也很多:
1. 如果不需要用到mod_nss 模块的,那直接把/etc/httpd/conf.d/nss.conf 文件改名或删掉(此方法最方便)
2. 不验证证书过期时间的,那就在nss.conf 中加入NSSEnforceValidCerts off 配置即可;
3. 最佳的方式,是重新生成新的证书。如下。此方法不建议
生成新证书前,务必先删除旧证书数据库文件

# cd /etc/httpd/alias
# rm -f *.db
# /usr/sbin/gencert /etc/httpd/alias > /etc/httpd/alias/install.log 2>&1
# certutil -d /etc/httpd/alias -L -n Server-Cert
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 3 (0x3)
        Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
        Issuer: "CN=Certificate Shack,O=example.com,C=US"
        Validity:
            Not Before: Thu Feb 07 07:02:53 2013
            Not After : Tue Feb 07 07:02:53 2017

时间: 2024-12-26 10:05:58

linux 中apache服务启动相关分析的相关文章

linux中apache服务的三种不同访问方式

实验环境:使用Red Hat Linux-6.2 32位操作系统用于搭建apache服务,使用windows 7-32位作为客户机.下面是详细的操作步骤. 实验步骤:搭建好系统自带的httpd服务:①搭建httpd服务的虚拟目录,并访问:②搭建基于不同主机名的httpd访问服务,并访问:③搭建基于不同端口号的httpd访问服务,并验证. 首先是检查httpd服务的安装环境,一些必要的环境条件一定要有.然后直接启动httpd服务试试看,此时虽然可以启动服务但是会有一些提示,最好处理一下.Httpd

linux中apache和mysqld加入service系统服务中

linux中apache和mysqld加入service系统服务中 先我们把mysql增加到linux的系统服务中去 mysql:  代码如下 复制代码 cd /usr/local/mysql/share/mysql cp mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on service mysqld restart 现在你就可以使用:service mysqld start来启动mysql了 a

Linux中tomcat开机启动配置脚本【参考其他文章的总结备忘录】

参考文章http://blog.sina.com.cn/s/blog_a57562c80101ic47.html http://blog.csdn.net/cheng168520/article/details/4312828 http://blog.sina.com.cn/s/blog_7f395ece0100ti5y.html 以前在自己本机上安装过一个Linux,后台应为系统崩溃,以前配置的开机启动脚本.数据库主从双备份.负载均衡等都没了,所以现在在重新配置一次,赶紧做个笔记防止自己以后又

Apache服务启动失败couldn't start errorlog process, unable to open logs

在某用户环境下,Apache服务启动失败,报错信息如下 couldn't start errorlog process unable to open logs Apache是我们的产品组件,未防止日志过大 我们使用了Apache自带的切割滚存日志的组件rotatelogs.exe 在httpd.conf配置如下: ErrorLog "|bin/rotatelogs.exe logs/%Y%m%d%H%M%S_error.log 30M" 只要屏蔽这个设置,就可以正常启动Apache,谷

linux下apache服务搭建

实验拓扑:                          Linux Client -----RHEL5.9(vmnet1)----------(vmnet1)                          Win7 Client 实验一:查看默认HTTP配置     找到默认红帽欢迎页面 (/etc/httpd/conf/httpd.conf ---->Include ----> /etc/httpd/conf.d  ----> welcome.conf  ----> /

Atitit. 软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动、停止、重启

Atitit.   软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动.停止.重启 可以通过"netstat -anp" 来查看哪些端口被打开.定位到需要的apache...俄要的是80端口映射的apache Ps -aux查看进程命令行参数...三,字有个httpd,没看见参数....查询myusql,是能看见参数了.... 查看linux版本,cenos....查询httpd.conf文件位置... /etc/httpd

Linux中nginx服务器启动脚本

Linux中nginx服务器启动脚本,将此脚本放入/etc/init.d/目录下,进行启动和关闭,并用chkconfig命令将nginx加入到chkconfig管理中,设置开机自启动. 详细脚本如下: #!/bin/bash #author wangning #date 2017-7-14 #qq 1198143315 #Email [email protected] [ -f /etc/init.d/functions ] && . /etc/init.d/functions #chkc

Linux中Sshd服务配置文件优化版本(/etc/ssh/sshd_config)

Linux中Sshd服务配置文件优化版本(/etc/ssh/sshd_config) # $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm Exp $ # If you want to change the port on a SELinux system, you have to tell # SELinux about this change. # semanage port -a -t ssh_port_t -p tcp #PORTN

Linux系统中Apache服务的构建

下面给大家介绍一下Apache构架的操作方法,首先把宿主机上压缩包进行共享然后在用虚拟机进行扫描共享文件在虚拟机上创建一个挂载点,对扫描到的共享文件挂载挂载好之后,切换目录到挂载点下,会看到共享后的三个压缩包 然后依次进行解压缩这里解压第二个apr的压缩包解压第三个apr-util压缩包,然后为了是apr和apr-util能被httpd所使用,所以要复制apr和apr-util的软件包到httpd文件下然后使用yum仓库安装gcc和gcc-c++两个编译器 这里可以看到安装完成了 然后安装一些相