【发布时间】: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