sudo systemctl restart apache2 失败

sudo systemctl restart apache2 失败

我在 ubuntu16.04 上尝试了 web aparch2。一开始,它运行良好。我安装了 aparch2、mysql、php,并尝试了 info.php,它运行良好。然后我安装了 wordpress,并将 /etc/apache2/mods-enabled/dir.conf 更改为:

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

我还更改了 mysql(创建 wordpress 数据库)和 wp-config.php(sudo mv wp-config-sample.php wp-config.php)我遵循: https://www.tecmint.com/install-wordpress-on-ubuntu-16-04-with-lamp/ 但是我无法重新启动apache2。消息如下:

liwenz@ubuntu:/var/www/html$ sudo systemctl restart apache2.service
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
liwenz@ubuntu:/var/www/html$ 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 2020-08-04 10:28:31 EDT; 28s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 22757 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCES
  Process: 18640 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SU
  Process: 24828 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAIL

Aug 04 10:28:31 ubuntu apache2[24828]:  *
Aug 04 10:28:31 ubuntu apache2[24828]:  * The apache2 configtest failed.
Aug 04 10:28:31 ubuntu apache2[24828]: Output of config test was:
Aug 04 10:28:31 ubuntu apache2[24828]: apache2: Syntax error on line 141 of /etc
Aug 04 10:28:31 ubuntu apache2[24828]: Action 'configtest' failed.
Aug 04 10:28:31 ubuntu apache2[24828]: The Apache error log may have more inform
Aug 04 10:28:31 ubuntu systemd[1]: apache2.service: Control process exited, code
Aug 04 10:28:31 ubuntu systemd[1]: Failed to start LSB: Apache2 web server.
Aug 04 10:28:31 ubuntu systemd[1]: apache2.service: Unit entered failed state.
Aug 04 10:28:31 ubuntu systemd[1]: apache2.service: Failed with result 'exit-cod

liwenz@ubuntu:/var/www/html$ journalctl -xe
Aug 04 10:28:31 ubuntu apache2[24828]: The Apache error log may have more inform
Aug 04 10:28:31 ubuntu systemd[1]: apache2.service: Control process exited, code
Aug 04 10:28:31 ubuntu 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.
Aug 04 10:28:31 ubuntu systemd[1]: apache2.service: Unit entered failed state.
Aug 04 10:28:31 ubuntu systemd[1]: apache2.service: Failed with result 'exit-cod
Aug 04 10:28:31 ubuntu sudo[24825]: pam_unix(sudo:session): session closed for u
Aug 04 10:28:45 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:28:53 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:29:06 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:29:18 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:29:35 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:29:42 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:29:56 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:30:05 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:30:19 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
Aug 04 10:30:27 ubuntu dhclient[1078]: DHCPREQUEST of 192.168.0.13 on ens33 to 2
lines 1088-1110/1110 (END)

答案1

/etc/apache2/apache2.conf 中的第 139-141 行是:

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

我认为错误应该出现在 mods-enabled/*.conf 中。我曾经修改过 /etc/apache2/mods-enabled/dir.conf,所以我在文件中找到了错误。现在我可以重新启动了。谢谢你的帮助!

相关内容