我正在尝试重新启动 apache2 服务器,并使用下面的命令,但出现了这个错误
$ sudo service apache2 restart
输出
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
之后,我输入了上面给出的命令“systemctl status apache2.service”和“journalctl -xe”并得到了这些输出,但我无法理解它。
$ systemctl status apache2.service
输出
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Tue 2017-02-07 11:38:36 IST; 19s ago
Docs: man:systemd-sysv-generator(8)
Process: 9552 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: * The apache2 configtest failed.
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: Output of config test was:
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: AH00526: Syntax error on line 9 of /etc/apache2/mods-enabled/php5.6.conf:
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: Invalid command 'Require', perhaps misspelled or defined by a module not included in the server con
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: Action 'configtest' failed.
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: The Apache error log may have more information.
Feb 07 11:38:36 Aspire-5742Z systemd[1]: apache2.service: Control process exited, code=exited status=1
Feb 07 11:38:36 Aspire-5742Z systemd[1]: Failed to start LSB: Apache2 web server.
Feb 07 11:38:36 Aspire-5742Z systemd[1]: apache2.service: Unit entered failed state.
Feb 07 11:38:36 Aspire-5742Z systemd[1]: apache2.service: Failed with result 'exit-code'.
输入
$ journalctl -xe
输出
-- Subject: Unit apache2.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apache2.service has begun starting up.
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: * Starting Apache httpd web server apache2
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: *
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: * The apache2 configtest failed.
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: Output of config test was:
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: AH00526: Syntax error on line 9 of /etc/apache2/mods-enabled/php5.6.conf:
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: Invalid command 'Require', perhaps misspelled or defined by a module not included in the server con
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: Action 'configtest' failed.
Feb 07 11:38:36 Aspire-5742Z apache2[9552]: The Apache error log may have more information.
Feb 07 11:38:36 Aspire-5742Z systemd[1]: apache2.service: Control process exited, code=exited status=1
Feb 07 11:38:36 Aspire-5742Z systemd[1]: Failed to start LSB: Apache2 web server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apache2.service has failed.
--
-- The result is failed.
Feb 07 11:38:36 Aspire-5742Z systemd[1]: apache2.service: Unit entered failed state.
Feb 07 11:38:36 Aspire-5742Z systemd[1]: apache2.service: Failed with result 'exit-code'.
Feb 07 11:38:36 Aspire-5742Z sudo[9546]: pam_unix(sudo:session): session closed for user root
Feb 07 11:39:01 Aspire-5742Z CRON[9571]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 07 11:39:01 Aspire-5742Z CRON[9572]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/s
Feb 07 11:39:01 Aspire-5742Z CRON[9571]: pam_unix(cron:session): session closed for user root
Feb 07 11:39:17 Aspire-5742Z systemd[1]: Starting Clean php session files...
-- Subject: Unit phpsessionclean.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit phpsessionclean.service has begun starting up.
Feb 07 11:39:18 Aspire-5742Z systemd[1]: Started Clean php session files.
-- Subject: Unit phpsessionclean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit phpsessionclean.service has finished starting up.
--
-- The start-up result is done.
输入
$ apachectl -t
输出
AH00526: Syntax error on line 9 of /etc/apache2/mods-enabled/php5.6.conf:
Invalid command 'Require', perhaps misspelled or defined by a module not included in the server configuration
Action '-t' failed.
The Apache error log may have more information.
我该如何纠正这个问题?提前谢谢您。
答案1
似乎您正在从 Apache 2.2 升级到 2.4,如所述这里,mod_access_compat
启用
sudo a2enmod access_compat && sudo service apache2 restart
或将指令更新至 2.4 版本。
答案2
在启动 apache 之前,您应该apachectl -t
确保您的配置通过语法检查 - 这似乎是目前的问题。
考虑到您的错误消息,我猜您缺少了mod_authz_core
。您也许可以使用来修复a2enmod authz_core
。您可能缺少其他模块,请检查apachectl -t
输出并向 Google 询问与语法检查失败的 apache 指令匹配的指令,...