PHP 无法在 ubuntu 14 上运行

PHP 无法在 ubuntu 14 上运行

我正在尝试在我的 ubuntu 机器上安装 php。首先我在机器上安装 apache2....然后我安装 php7

sudo apt-get -y update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get -y update
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv

之后我重新启动了我的 apache2service apache2 restart

但是当我尝试从本地主机浏览 php 页面时,php 仍然不起作用。

php -v

还显示输出...并告诉我 php 版本。

在 apche2 的错误日志文件中我收到错误

restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
[Thu May 19 07:53:16.813504 2016] [mpm_prefork:notice] [pid 12487] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.16 configured -- resuming normal operations
[Thu May 19 07:53:16.813518 2016] [core:notice] [pid 12487] AH00094: Command line: '/usr/sbin/apache2'
[Thu May 19 08:05:24.435502 2016] [mpm_prefork:notice] [pid 12487] AH00169: caught SIGTERM, shutting down
[Thu May 19 08:05:25.513275 2016] [mpm_prefork:notice] [pid 14456] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.16 configured -- resuming normal operations
[Thu May 19 08:05:25.513343 2016] [core:notice] [pid 14456] AH00094: Command line: '/usr/sbin/apache2'
[Thu May 19 08:26:11.093404 2016] [mpm_prefork:notice] [pid 14456] AH00169: caught SIGTERM, shutting down
[Thu May 19 08:26:12.166600 2016] [mpm_prefork:notice] [pid 20497] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.16 configured -- resuming normal operations
[Thu May 19 08:26:12.166640 2016] [core:notice] [pid 20497] AH00094: Command line: '/usr/sbin/apache2'

答案1

如果您libapache2-mod-php7.0另外安装libapache2-mod-php5它,它将不会自行启用(您应该在 {apt,dpkg}.log 中看到此信息),因此您需要禁用php5模块并启用php7.0模块:

a2dismod php5
a2enmod php7.0
apache2ctl restart

PS:您应该在安装时阅读软件包中的内容。运行 apt-get-y肯定会错过重要内容。

相关内容