apache,httpd服务启动报错解决方法【linux用日志排错方法】

  • systemctl status httpd.service:既然服务起不来,那么看的这个状态肯定是failed的。

  • journalctl -xe:这是直接查看日志,这里面可能会有关键字

这个呢,就注意看有没有:invalid value这个开头的关键字,如果有的话,一般后面就是报错内容了

可以这样:journalctl -xe | grep "invalid value"过滤哦。

但这个不适用于http,因为http配置文件太多,过滤出来看不出是哪行,所以就pass了,但日志有行号哦。

在这里插入图片描述

方式二【messages】

  • 可以用这个来过滤:cat /var/log/messages |grep "invalid value"

但我这不用过滤,用查看动态的形式来展示吧。

  • 看日志,日志中有详细说明

  • cd /var/log

  • tail -f messages

简单说明一下:messages是系统日志,启动报错这里会有提示,tail -f 是动态查看的意思

在这里插入图片描述

  • 然后重新打开一个窗口,重启或启动httpd服务:systemctl restart httpd,然后回到日志窗口看最新日志

在这里插入图片描述

报错处理【带行号】

  • 这种有说行号的处理就比较简单了

  • 上图中看到 说配置文件中 /etc/httpd/conf/httpd.conf中265行错误,所以,现在打开文件,定位到265行

在这里插入图片描述

  • 问题定位到了,把265行注释掉,重启试试

在这里插入图片描述

  • 启动服务:systemctl start httpd, 成功

在这里插入图片描述

  • 说明一下,我之前以为把配置文件改了重启就会报错,然而发现配置文件不是关键,而是 mod_wsgi 服务,我把mon_wsgi卸载以后重启就报错了,把 mon_wsgi装上以后就重启正常了,这里这么做,只是 测试 如何看日志 以及 如果通过日志 处理报错问题。

在这里插入图片描述

  • wsgi 正确路径建议指定如下图哦:

在这里插入图片描述

etcd启动报错【journalctl定位】

=====================================================================================

  • 报错内容如下:

[root@vms160 ~]# systemctl restart etcd

Job for etcd.service failed because the control process exited with error code. See “systemctl status etcd.service” and “journalctl -xe” for details.

[root@vms160 ~]#

解决步骤


方式一【journalctl】

  • 启动报错的时候下面会提醒你输入 systemctl status httpd.servicejournalctl -xe查看详细

[root@vms160 ~]# systemctl restart etcd

Job for etcd.service failed because the control process exited with error code. See “systemctl status etcd.service” and “journalctl -xe” for details.

[root@vms160 ~]#

  • 说明

  • systemctl status httpd.service:既然服务起不来,那么看的这个状态肯定是failed的。

  • journalctl -xe:这是直接查看日志,这里面可能会有关键字

这个呢,就注意看有没有:invalid value这个开头的关键字,如果有的话,一般后面就是报错内容了

可以这样:journalctl -xe | grep "invalid value"过滤哦。

这种更实用于你知道这个配置文件,且知道这行内容是啥的情况。

如下:

[root@vms160 ~]# journalctl -xe | grep “invalid value”

7月 13 16:44:03 etcd1 bash[2559]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:44:04 etcd1 bash[2570]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:44:04 etcd1 bash[2580]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:44:44 etcd1 bash[2604]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:44:44 etcd1 bash[2615]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:44:45 etcd1 bash[2625]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:44:45 etcd1 bash[2635]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:44:45 etcd1 bash[2646]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:45:35 vms160 bash[2707]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:45:35 vms160 bash[2722]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:45:36 vms160 bash[2733]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:45:36 vms160 bash[2744]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:45:36 vms160 bash[2755]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:

7月 13 16:47:21 vms160 bash[2789]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:47:21 vms160 bash[2800]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:47:21 vms160 bash[2811]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:47:22 vms160 bash[2821]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:47:22 vms160 bash[2832]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:48:00 vms160 bash[2862]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:48:00 vms160 bash[2873]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:48:00 vms160 bash[2884]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:48:00 vms160 bash[2895]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:48:01 vms160 bash[2905]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:55:11 vms160 bash[2947]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:55:11 vms160 bash[2957]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:55:12 vms160 bash[2968]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:55:12 vms160 bash[2978]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:55:12 vms160 bash[2989]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:58:07 vms160 bash[3012]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:58:07 vms160 bash[3023]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:58:07 vms160 bash[3034]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:58:07 vms160 bash[3045]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 16:58:08 vms160 bash[3055]: invalid value “http://localhost:2379,192.168.59.160:2379” for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon

7月 13 17:25:46 vms160 bash[3244]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:25:47 vms160 bash[3254]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:25:47 vms160 bash[3265]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:25:47 vms160 bash[3275]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:25:48 vms160 bash[3286]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:37:00 vms160 bash[3310]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:37:00 vms160 bash[3320]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:37:00 vms160 bash[3330]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:37:01 vms160 bash[3341]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

7月 13 17:37:01 vms160 bash[3352]: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

[root@vms160 ~]#

  • 如上,上面已经告诉我:invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379是这行代码出错了

方式二【messages】

  • 可以用这个来过滤:cat /var/log/messages |grep "invalid value"

我这就以过滤的形式来展示了

如下

[root@vms160 log]# systemctl restart etcd

Job for etcd.service failed because the control process exited with error code. See “systemctl status etcd.service” and “journalctl -xe” for details.

[root@vms160 log]#

[root@vms160 log]# pwd

/var/log

[root@vms160 log]# cat /var/log/messages |grep “invalid value”

Jul 13 17:42:45 vms160 bash: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

Jul 13 17:42:45 vms160 bash: invalid value “http://localhost:2379,http:/192.168.59.160:2379” for flag -listen-client-urls: URL address does not have the form “host:port”: http:/192.168.59.160:2379

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注Java)
img

最后

文章中涉及到的知识点我都已经整理成了资料,录制了视频供大家下载学习,诚意满满,希望可以帮助在这个行业发展的朋友,在论坛博客等地方少花些时间找资料,把有限的时间,真正花在学习上,所以我把这些资料,分享出来。相信对于已经工作和遇到技术瓶颈的朋友们,在这份资料中一定都有你需要的内容。

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
img

文章中涉及到的知识点我都已经整理成了资料,录制了视频供大家下载学习,诚意满满,希望可以帮助在这个行业发展的朋友,在论坛博客等地方少花些时间找资料,把有限的时间,真正花在学习上,所以我把这些资料,分享出来。相信对于已经工作和遇到技术瓶颈的朋友们,在这份资料中一定都有你需要的内容。

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[外链图片转存中…(img-4aNFI8lf-1712837536803)]

  • 22
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 如果 Linux httpd 启动失败,可能有以下原因: 1. Apache 的配置文件存在语法错误 2. Apache 不能监听到已被其他程序占用的端口 3. Apache 缺少所需的权限 4. 系统其他服务占用了 Apache 所需的端口 5. Apache 所需的库文件或模块没有安装 建议检查 Apache 的配置文件,确保没有语法错误,并检查端口是否被占用。查看 Apache日志文件以获取更多详细信息。 ### 回答2: Linuxhttpd是ApacheHTTP服务器,是一款由自由软件社区维护的开放源代码的Web服务器。如果httpd启动失败,往往是由于以下几个方面的原因: 1. 配置文件错误 httpd的配置文件是由Apache配置文件配置包括主配置文件和许多模块配置文件组成的。如果在配置文件出现语法错误、权限问题或者服务器名字不一致等问题,都会导致httpd启动失败。要解决这些问题,可以使用httpd的启动命令加上配置文件路径的选项来找到错误,并进行修正。 2. 端口被占用 httpd需要使用端口来进行网络访问,如果端口被占用,就会使httpd启动失败。可以使用lsof命令查看当前系统的所有打开的文件和网络套接字,通过端口号查找被占用的端口。然后关闭或重启占用该端口的程序,释放该端口。 3. 资源不足 如果系统资源紧张,例如内存、磁盘空间等资源不足,也会导致httpd启动失败。此时只需要释放或增加资源,让系统能够正常运行。 4. 未安装必要的软件包 httpd启动失败也可能是没有正确安装httpd所需的软件包。这时只需要安装缺失的软件包即可解决问题。 总之,要解决httpd启动失败问题,需要对其配置文件进行检查和修复,解决占用端口的问题,并增加系统资源。只有保持系统的稳定性和足够资源,才能保证httpd的正常启动和运行。 ### 回答3: 当您在Linux上尝试启动HTTPD时,可能会遇到各种问题导致HTTPD启动失败。以下是一些常见的问题,以及您可以尝试的解决方法: 1. 端口被占用:HTTPD尝试使用80或443端口,这些端口可能正在被其他进程使用,这可能会导致HTTPD启动失败。您可以尝试使用以下命令检查端口占用情况: ``` netstat -tulnp | grep 80 ``` 如果看到输出有其他进程占用了80端口,您需要停止该进程,或更改HTTPD的端口号。 2. 权限不足:如果您尝试使用非root用户启动HTTPD,您可能会遇到权限不足的问题。您可以尝试使用以下命令以root用户身份启动HTTPD: ``` sudo service httpd start ``` 如果还是无法启动,您可以检查HTTPD的日志文件,通常位于/var/log/httpd/目录,以查找有关权限问题的更多信息。 3. 配置文件错误:如果您在HTTPD的配置文件设置了错误的选项,例如语法错误或无效路径,这可能会导致启动失败。您可以尝试运行以下命令检查配置文件的错误: ``` sudo apachectl configtest ``` 如果输出提示有错误,请检查您的配置文件并进行修改以纠正错误。 4. 服务未安装:如果您未安装HTTPD服务(例如在CentOS或RedHat上),则无法启动HTTPD。您可以尝试使用以下命令安装HTTPD服务: ``` sudo yum install httpd ``` 一旦安装HTTPD服务,您可以使用上述方法检查并解决其他问题。 上述是一些常见的问题和可能的解决方法,但具体问题取决于您的情况。如果您遇到困难,您可以查看HTTPD的文档或在线社区以获取更多信息和指导。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值