Ubuntu20.4启用php53模块后Apache2启动失败求助
问题描述
通过ppa:sergey-dryabzhinsky/php53安装PHP5.3,安装Apache2后执行sudo a2enmod php53,提示需重启Apache2,但执行sudo systemctl restart apache2后服务器停止且无法启动。
系统日志(journalctl -xe)输出
The job identifier is 5493. Mar 06 13:49:01 ip-172-31-39-129 apachectl[10817]: [Wed Mar 06 13:49:01.199228 2024] [:crit] [pid 10817:tid 140524561787968] Apache is running a threaded M> Mar 06 13:49:01 ip-172-31-39-129 apachectl[10817]: AH00013: Pre-configuration failed Mar 06 13:49:01 ip-172-31-39-129 apachectl[10814]: Action 'start' failed. Mar 06 13:49:01 ip-172-31-39-129 apachectl[10814]: The Apache error log may have more information. Mar 06 13:49:01 ip-172-31-39-129 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE -- Subject: Unit process exited -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- An ExecStart= process belonging to unit apache2.service has exited. -- -- The process' exit code is 'exited' and its exit status is 1. Mar 06 13:49:01 ip-172-31-39-129 sudo[10806]: pam_unix(sudo:session): session closed for user root Mar 06 13:49:01 ip-172-31-39-129 systemd[1]: apache2.service: Failed with result 'exit-code'. -- Subject: Unit failed -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- The unit apache2.service has entered the 'failed' state with result 'exit-code'. Mar 06 13:49:01 ip-172-31-39-129 systemd[1]: Failed to start The Apache HTTP Server. -- Subject: A start job for unit apache2.service has failed -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- A start job for unit apache2.service has finished with a failure. -- -- The job identifier is 5493 and the job result is failed.
Apache2错误日志输出
[Wed Mar 06 13:48:07.632271 2024] [mpm_event:notice] [pid 10483:tid 140403607956544] AH00489: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations [Wed Mar 06 13:48:07.632364 2024] [core:notice] [pid 10483:tid 140403607956544] AH00094: Command line: '/usr/sbin/apache2' [Wed Mar 06 13:49:01.156933 2024] [mpm_event:notice] [pid 10483:tid 140403607956544] AH00491: caught SIGTERM, shutting down
补充说明:已安装mysql-server、php53、libapache2-mod-php53、php53-xml、php53-mbstring,因无可用包未安装php53-mysql。
原因分析
关键报错Apache is running a threaded MPM指向核心问题:PHP5.3的Apache模块libapache2-mod-php53仅支持非线程化的prefork MPM,而当前Apache默认启用的是线程化的event MPM,两者不兼容,导致启动失败。
解决步骤
切换Apache的MPM为prefork
先禁用当前的event MPM:sudo a2dismod mpm_event启用prefork MPM:
sudo a2enmod mpm_prefork确保PHP5.3模块已启用
重新执行启用命令,避免状态异常:sudo a2enmod php53重启Apache服务
sudo systemctl restart apache2验证服务状态
执行命令确认服务运行状态:sudo systemctl status apache2也可以在
/var/www/html/目录下创建info.php文件,内容如下:<?php phpinfo(); ?>通过浏览器访问该文件,检查PHP5.3是否正常加载。
内容的提问来源于stack exchange,提问作者Nichm
相关产品推荐
相关产品推荐

