首页 > 解决方案 > 无法在 ubuntu 18.04 中更改 php 版本

问题描述

我正在尝试在我的 ubuntu 18.04 中更改我的 php 版本。我想从 7.0 更改为 7.2。我已将 php 更新到 7.2。将 php 版本从sudo a2enmod php7.2.

在终端:

$ php --ini
  Configuration File (php.ini) Path: /etc/php/7.2/cli
  Loaded Configuration File:         /etc/php/7.2/cli/php.ini
  Scan for additional .ini files in: /etc/php/7.2/cli/conf.d

在本地主机中:

<?php phpinfo();?>

PHP Version 7.0.30-1+ubuntu18.04.1+deb.sury.org+1
System  Linux linux 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 
06:16:15 UTC 2018 x86_64
Build Date  May 2 2018 12:44:20
Server API  Apache 2.0 Handler
Virtual Directory Support   disabled
Configuration File (php.ini) Path   /etc/php/7.0/apache2
Loaded Configuration File   (none)
Scan this dir for additional .ini files /etc/php/7.0/apache2/conf.d

在终端:

 php -version
 PHP 7.2.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May  5 2018 
 05:00:15) ( NTS )
 Copyright (c) 1997-2018 The PHP Group
 Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
 with Zend OPcache v7.2.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright 
 (c) 1999-2018, by Zend Technologies

我无法确定问题出在哪里。在我清除 php 7.0 后也没有解决问题。

标签: phplocalhostapache2

解决方案


请试试:

sudo apt install libapache2-mod-php7.2
sudo service apache2 restart

推荐阅读