【问题标题】:Reload apache within a python script on linux在 Linux 上的 python 脚本中重新加载 apache
【发布时间】:2021-11-29 12:55:13
【问题描述】:

您好,我正在尝试创建一个重新加载 apache2 的 python 文件,该文件的代码是:

import os

os.system("service apache2 reload")

当我在终端中使用该命令时,一切正常,但是当我运行 python 脚本时出现此错误:

Job for apache2.service failed.
See "systemctl status apache2.service" and "journalctl -xe" for details.

所以我检查了journalctl 并得到了这个:

nov 29 13:50:19 gerrietech apachectl[37415]: Action 'graceful' failed.
nov 29 13:50:19 gerrietech apachectl[37415]: The Apache error log may have more information.

这来自错误日志:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.50.183. Set the 'ServerName' directive globally to suppress this message
[Mon Nov 29 13:37:35.533656 2021] [mpm_prefork:notice] [pid 36741] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:37:35.533672 2021] [core:notice] [pid 36741] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 29 13:38:23.180736 2021] [mpm_prefork:notice] [pid 36741] AH00169: caught SIGTERM, shutting down
[Mon Nov 29 13:38:45.809351 2021] [mpm_prefork:notice] [pid 37219] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:38:45.809422 2021] [core:notice] [pid 37219] AH00094: Command line: '/usr/sbin/apache2'

我该如何解决这个问题?

【问题讨论】:

  • 可以尝试使用apachectl 而不是systemd
  • 您是否在 conf 文件中添加了“ServerName”指令?

标签: python-3.x linux apache


【解决方案1】:

在我使用 /etc/init.d/apache2 reload 而不是 service apache2 restart 之后,我没有收到任何错误,并且脚本执行了它应该做的事情

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2020-08-21
  • 1970-01-01
  • 2015-02-18
  • 2017-04-14
  • 2021-09-20
  • 1970-01-01
  • 1970-01-01
  • 2019-08-16
  • 2011-12-16
相关资源
最近更新 更多