在apache2上启用php(使用Ubuntu 16.04)

在apache2上启用php(使用Ubuntu 16.04),php,apache,ubuntu,Php,Apache,Ubuntu,我已经在我的Ubuntu 16.04.1系统上安装了Apache2 我也想在我的Web服务器上安装并激活PHP7.0 我安装了php并尝试在Apache2中激活该模块 重新启动服务器时,我得到: Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for detai

我已经在我的Ubuntu 16.04.1系统上安装了Apache2

我也想在我的Web服务器上安装并激活PHP7.0

我安装了php并尝试在Apache2中激活该模块

重新启动服务器时,我得到:

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”时,我得到:

-- Unit apache2.service has begun starting up.
Jan 30 12:19:58 tom-450-a141ng apache2[29920]:  * Starting Apache httpd web server apache2
Jan 30 12:19:58 tom-450-a141ng apache2[29920]:  *
Jan 30 12:19:58 tom-450-a141ng apache2[29920]:  * The apache2 configtest failed.
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: Output of config test was:
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: [Mon Jan 30 12:19:58.942761 2017] [:crit] [pid 29935:tid 140264661432192] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. 
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: AH00013: Pre-configuration failed
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: Action 'configtest' failed.
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: The Apache error log may have more information.
Jan 30 12:19:58 tom-450-a141ng systemd[1]: apache2.service: Control process exited, code=exited status=1
Jan 30 12:19:58 tom-450-a141ng 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.
Jan 30 12:19:58 tom-450-a141ng systemd[1]: apache2.service: Unit entered failed state.
Jan 30 12:19:58 tom-450-a141ng systemd[1]: apache2.service: Failed with result 'exit-code'.
Jan 30 12:19:58 tom-450-a141ng sudo[29892]: pam_unix(sudo:session): session closed for user root
所以我不能再启动Apache了

我到处寻找解决办法


Plz帮助

您可以使用下面的命令直接执行此操作

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

由于需要安装php7,只需使用-

sudo apt get purge php*

然后跑

sudo apt get-y安装php7.0 libapache2-mod-php7.0

然后,您可以根据需要使用安装其他模块-

apt get-y安装php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php pear php imagick php7.0-imap php7.0-mcrypt php memcache

systemctl restart apache2

错误“[Mon Jan 30 12:19:58.942761 2017][:crit][pid 29935:tid 140264661432192]Apache正在运行线程化MPM,但您的PHP模块未编译为线程安全的。“说明您使用的是线程化MPM,即事件或工作者,但您的mod_php模块依赖于一个非线程安全的php安装,因此您只能与预工作一起使用

如果您想使用线程化MPM(这很好,也是一个好主意,我也推荐它),您不应该使用mod_php,您应该使用php fpm


您将在

中找到如何配置它。我建议您查看哦,耶。他/她想使用PHP7.0而不是PHP5。我无法再从apt安装PHP5。抱歉。我不明白。如何安装带有16.04 Repository的PHP5?它们不在其中。可能是添加了一个包含它们的存储库,不确定它们是否会与您的实际分发库发生冲突。我刚才是在回答您的ApacheHTTPD错误以及它发生的原因。