尝试在 Web 服务器关闭后从终端启动 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.
我尝试运行journalctl -xe
,它说
Nov 11 15:39:39 sd-101534 sshd[7011]: PAM service(sshd) ignoring max retries; 6 > 3
Nov 11 15:39:39 sd-101534 sshd[7013]: Failed password for root from 58.218.198.169 port 61692 ssh2
Nov 11 15:39:39 sd-101534 sshd[7013]: Received disconnect from 58.218.198.169 port 61692:11: [preauth]
Nov 11 15:39:39 sd-101534 sshd[7013]: Disconnected from 58.218.198.169 port 61692 [preauth]
Nov 11 15:39:39 sd-101534 sshd[7013]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.169 user=root
Nov 11 15:39:40 sd-101534 sshd[7015]: Failed password for root from 58.242.83.32 port 58820 ssh2
Nov 11 15:39:43 sd-101534 sshd[7035]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.20 user=root
Nov 11 15:39:43 sd-101534 sshd[7015]: Failed password for root from 58.242.83.32 port 58820 ssh2
Nov 11 15:39:43 sd-101534 sshd[7015]: error: maximum authentication attempts exceeded for root from 58.242.83.32 port 58820 ssh2 [preauth]
Nov 11 15:39:43 sd-101534 sshd[7015]: Disconnecting: Too many authentication failures [preauth]
Nov 11 15:39:43 sd-101534 sshd[7015]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.32 user=root
Nov 11 15:39:43 sd-101534 sshd[7015]: PAM service(sshd) ignoring max retries; 6 > 3
Nov 11 15:39:45 sd-101534 sshd[7035]: Failed password for root from 58.242.83.20 port 37618 ssh2
Nov 11 15:39:48 sd-101534 sshd[7035]: Failed password for root from 58.242.83.20 port 37618 ssh2
Nov 11 15:39:48 sd-101534 sshd[7039]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.32 user=root
Nov 11 15:39:50 sd-101534 sshd[7039]: Failed password for root from 58.242.83.32 port 17432 ssh2
Nov 11 15:39:50 sd-101534 sshd[7035]: Failed password for root from 58.242.83.20 port 37618 ssh2
Nov 11 15:39:51 sd-101534 sshd[7037]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.169 user=root
Nov 11 15:39:52 sd-101534 sshd[7037]: Failed password for root from 58.218.198.169 port 48911 ssh2
Nov 11 15:39:52 sd-101534 sshd[7039]: Failed password for root from 58.242.83.32 port 17432 ssh2
Nov 11 15:39:53 sd-101534 sshd[7035]: Failed password for root from 58.242.83.20 port 37618 ssh2
Nov 11 15:39:55 sd-101534 sudo[7041]: jazuly : TTY=pts/0 ; PWD=/home/jazuly ; USER=root ; COMMAND=/bin/journalctl -xe
Nov 11 15:39:55 sd-101534 sudo[7041]: pam_unix(sudo:session): session opened for user root by jazuly(uid=0)
然后我跑nano /var/log/apache2/error.log
我懂了
$[Sat Nov 11 15:31:10.188122 2017] [mpm_prefork:notice] [pid 797] AH00169: caught SIGTERM, shutting down
我跑sudo 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 Sat 2017-11-11 15:42:06 CET; 16min ago
Docs: man:systemd-sysv-generator(8)
Process: 6744 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 25897 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
Process: 7132 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
Nov 11 15:42:06 sd-101534 apache2[7132]: * The apache2 configtest failed.
Nov 11 15:42:06 sd-101534 apache2[7132]: Output of config test was:
Nov 11 15:42:06 sd-101534 apache2[7132]: AH00526: Syntax error on line 12 of /etc/apache2/mods-enabled/mpm_prefork.conf:
Nov 11 15:42:06 sd-101534 apache2[7132]: Invalid command 'MazClients', perhaps misspelled or defined by a module not included in the server configuration
Nov 11 15:42:06 sd-101534 apache2[7132]: Action 'configtest' failed.
Nov 11 15:42:06 sd-101534 apache2[7132]: The Apache error log may have more information.
Nov 11 15:42:06 sd-101534 systemd[1]: apache2.service: Control process exited, code=exited status=1
Nov 11 15:42:06 sd-101534 systemd[1]: Failed to start LSB: Apache2 web server.
Nov 11 15:42:06 sd-101534 systemd[1]: apache2.service: Unit entered failed state.
Nov 11 15:42:06 sd-101534 systemd[1]: apache2.service: Failed with result 'exit-code'.
我要怎么做才能让我的网络恢复正常。
答案1
您的配置选项无效,这就是 Apache 无法启动并显示 的原因'configtest' failed
。实际上,阅读输出systemctl status
通常足以识别此类问题,并确定软件无法正常运行的核心原因。我经常看到这种情况。
也就是说,这是systemctl
状态输出中详细说明的具体错误:
Nov 11 15:42:06 sd-101534 apache2[7132]: AH00526: Syntax error on line 12 of /etc/apache2/mods-enabled/mpm_prefork.conf:
Nov 11 15:42:06 sd-101534 apache2[7132]: Invalid command 'MazClients', perhaps misspelled or defined by a module not included in the server configuration
编辑它引用的文件 ( /etc/apache2/mods-enabled/mpm_prefork.conf
),并尝试MazClients
用替换MaxClients
,然后尝试再次启动 Apache。在我看来,您的实际问题出在 MPM Prefork 而不是 MySQL。