在 Ubuntu 服务器 18.04 中将 php 版本从 7.0 降级到 5.6 后无法启动 apache2

在 Ubuntu 服务器 18.04 中将 php 版本从 7.0 降级到 5.6 后无法启动 apache2

今天我参考这个将 PHP 版本 7.0 降级到 5.6博客: 现在每次我输入 apache2 restart 命令时sudo service apache2 start都会显示

    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它只显示一些代码退出和状态 139

root@server:~# systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Fri 2020-01-10 11:24:15 UTC; 2min 29s ago
  Process: 2708 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)

Jan 10 11:24:15 server.mypcbd.xyz systemd[1]: Starting The Apache HTTP Server...
Jan 10 11:24:15 server.mypcbd.xyz apachectl[2708]: Segmentation fault (core dumped)
Jan 10 11:24:15 server.mypcbd.xyz apachectl[2708]: Action 'start' failed.
Jan 10 11:24:15 server.mypcbd.xyz apachectl[2708]: The Apache error log may have more information.
Jan 10 11:24:15 server.mypcbd.xyz systemd[1]: apache2.service: Control process exited, code=exited s
Jan 10 11:24:15 server.mypcbd.xyz systemd[1]: apache2.service: Failed with result 'exit-code'.
Jan 10 11:24:15 server.mypcbd.xyz systemd[1]: Failed to start The Apache HTTP Server.

我到处搜索,但我不知道该怎么办。请帮帮我,我的服务器刚刚宕机了。

root@server:~# journalctl -xe
Jan 10 12:13:41 server.mypcbd.xyz sshd[3306]: Failed password for root from 222.186.30.12 port 48781
Jan 10 12:13:41 server.mypcbd.xyz sshd[3306]: Received disconnect from 222.186.30.12 port 48781:11:
Jan 10 12:13:41 server.mypcbd.xyz sshd[3306]: Disconnected from authenticating user root 222.186.30.
Jan 10 12:13:41 server.mypcbd.xyz sshd[3306]: PAM 2 more authentication failures; logname= uid=0 eui
Jan 10 12:13:42 server.mypcbd.xyz sshd[3312]: Failed password for invalid user wuv from 52.66.66.20
Jan 10 12:13:42 server.mypcbd.xyz sshd[3312]: Received disconnect from 52.66.66.20 port 48058:11: By
Jan 10 12:13:42 server.mypcbd.xyz sshd[3312]: Disconnected from invalid user wuv 52.66.66.20 port 48
Jan 10 12:13:51 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:13:52 server.mypcbd.xyz sshd[3311]: Connection closed by 114.220.176.106 port 60506 [preau
Jan 10 12:14:11 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:14:30 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:14:51 server.mypcbd.xyz sshd[3315]: pam_unix(sshd:auth): authentication failure; logname=
Jan 10 12:14:51 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:14:52 server.mypcbd.xyz sshd[3315]: Failed password for root from 80.173.177.76 port 43616
Jan 10 12:14:52 server.mypcbd.xyz sshd[3315]: Received disconnect from 80.173.177.76 port 43616:11:
Jan 10 12:14:52 server.mypcbd.xyz sshd[3315]: Disconnected from authenticating user root 80.173.177.
Jan 10 12:15:01 server.mypcbd.xyz CRON[3317]: pam_unix(cron:session): session opened for user root b
Jan 10 12:15:01 server.mypcbd.xyz CRON[3318]: (root) CMD (command -v debian-sa1 > /dev/null && debia
Jan 10 12:15:01 server.mypcbd.xyz CRON[3317]: pam_unix(cron:session): session closed for user root
Jan 10 12:15:10 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:15:30 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:15:52 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:16:11 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:16:31 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:16:42 server.mypcbd.xyz sshd[3320]: Invalid user arma3server from 149.126.32.23 port 59194
Jan 10 12:16:42 server.mypcbd.xyz sshd[3320]: pam_unix(sshd:auth): check pass; user unknown
Jan 10 12:16:42 server.mypcbd.xyz sshd[3320]: pam_unix(sshd:auth): authentication failure; logname=
Jan 10 12:16:44 server.mypcbd.xyz sshd[3320]: Failed password for invalid user arma3server from 149.
Jan 10 12:16:44 server.mypcbd.xyz sshd[3320]: Received disconnect from 149.126.32.23 port 59194:11:
Jan 10 12:16:44 server.mypcbd.xyz sshd[3320]: Disconnected from invalid user arma3server 149.126.32.
Jan 10 12:16:47 server.mypcbd.xyz sshd[3322]: pam_unix(sshd:auth): authentication failure; logname=
Jan 10 12:16:50 server.mypcbd.xyz sshd[3322]: Failed password for root from 222.186.30.35 port 23086
Jan 10 12:16:50 server.mypcbd.xyz kernel: [UFW BLOCK] IN=enp7s0 OUT= MAC=00:e0:2b:68:06:4d:8c:a6:df:
Jan 10 12:16:51 server.mypcbd.xyz sshd[3322]: Failed password for root from 222.186.30.35 port 23086
l

语法结果

root@server:~# cd /etc/apache2
root@server:/etc/apache2# apache2ctl configtest
Syntax OK
root@server:/etc/apache2#

结果:

root@server:~# sudo a2dismod php7.0 && sudo a2enmod php5.6 && sudo update-alternatives --set php /usr/bin/php5.6 && sudo service apache2 start
Module php7.0 already disabled
Considering dependency mpm_prefork for php5.6:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php5.6:
Module php5.6 already enabled
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
root@server:~# 

结果 2:

root@server:~# sudo a2dismod mpm_prefork && sudo a2dismod mpm_worker && sudo a2dismod mpm_event && sudo service apache2 start
ERROR: The following modules depend on mpm_prefork and need to be disabled first: php5.6 php7.2
root@server:~#

结果@Jos:/var/log/apache2/error.log:

[Fri Jan 10 06:25:05.000345 2020] [mpm_prefork:notice] [pid 1551] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Fri Jan 10 06:25:05.000380 2020] [core:notice] [pid 1551] AH00094: Command line: '/usr/sbin/apache2'
[Fri Jan 10 10:45:08.905835 2020] [mpm_prefork:notice] [pid 1551] AH00169: caught SIGTERM, shutting down
[Fri Jan 10 10:45:09.032788 2020] [mpm_prefork:notice] [pid 11277] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Fri Jan 10 10:45:09.032844 2020] [core:notice] [pid 11277] AH00094: Command line: '/usr/sbin/apache2'
[Fri Jan 10 11:01:06.665145 2020] [mpm_prefork:notice] [pid 11277] AH00169: caught SIGTERM, shutting down

相关内容