簡體   English   中英

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

[英]enable php on apache2 (using Ubuntu 16.04)

我已經在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。

我到處都在尋找解決方案。

請幫助

當您需要安裝php7時,只需使用-

sudo apt-get purge php*

然后運行

sudo apt-get -y install php7.0 libapache2-mod-php7.0

然后,您可以根據需要使用以下方法安裝其他模塊:

apt-get -y install 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重新啟動apache2

錯誤“ [[Mon Jan 30 12:19:58.942761 2017] [:crit] [pid 29935:tid 140264661432192] Apache正在運行線程化的MPM,但您的PHP模塊未編譯為具有線程安全性。” 描述您使用的是線程MPM (即事件或工作程序) ,但是您的mod_php模塊取決於不是線程安全的php安裝,因此只能與prefork一起使用。

如果要使用線程MPM(這很好,這也是個好主意,我也建議這樣做),則不應使用mod_php,而應使用php-fpm

您將在官方Apache Wiki中找到如何配置它

您可以使用以下命令直接執行此操作

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM