Cannot add PPA: 'ppa:ondrej/php5-5.6'

2020-05-16 04:17发布

I'm trying to update my php 5.5.9 to 5.6 in an Ubuntu machine.

But when I run:

sudo add-apt-repository ppa:ondrej/php5-5.6

I'm getting:

Cannot add PPA: 'ppa:ondrej/php5-5.6'.
Please check that the PPA name or format is correct.

How can I fix this?

EDIT

I ran:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5

But when I run:

php5 -v

I still get php 5.5.9:

PHP 5.5.9-1ubuntu4.20 (cli) (built: Oct  3 2016 13:00:37) 

标签: php ubuntu
4条回答
混吃等死
2楼-- · 2020-05-16 04:56

add the right ppa first, do the following

  1. sudo add-apt-repository ppa:ondrej/php
  2. sudo apt-get update
  3. sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip

i had the same issue in installing the php5.6 then i did the above steps.

查看更多
何必那么认真
3楼-- · 2020-05-16 04:57

This worked in my Ubuntu Server 14.04.5 LTS

a2dismod php5
a2enmod php5.6
apache2ctl restart
查看更多
我命由我不由天
4楼-- · 2020-05-16 05:04

This work for perfectly for me. Add the right PPA first, by doing the following

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl 
php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip

Disable php 5.5.3 or 5.5.9 module

a2dismod php5

Enable the just installed php5.6 module

a2enmod php5.6

Finally, you restart your apache

sudo service apache restart

@tanveer ahmad dar highlighted most of it.

查看更多
Animai°情兽
5楼-- · 2020-05-16 05:15

While the answer of @tanveerahmaddar provides crucial information, here is the correct way to install the PHP 5.6 on Ubuntu 12.04:

Important: If you plan to use PHP5.6 in websites (which you probably wish to), you have to upgrade to Apache 2.4, which does not ship with Ubuntu 12.04 (will cover the upgrade of Apache below)

Step 1: Check versions

# check PHP version
php -v
# check Apache version
apache2 -v

If your Apache version is 2.2, follow Step 2; if version is 2.4, skip to Step 3

Step 2: Add PHP5.6+ repository and update package list

add-apt-repository ppa:ondrej/apache2
apt-get update
apt-get upgrade

This step will upgrade Apache from 2.2 to 2.4. Re-configure your Apache if needed. Backup your existing Apache configurations, enabled sites and mods. You might need to re-install / upgrade some of the mods.

Step 3: Add PHP5.6+ Repository

add-apt-repository ppa:ondrej/php
apt-get update

Step 4: Install PHP 5.6

apt-get install -y php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip libapache2-mod-php5.6

This will install PHP 5.6 and some common packages such as cURL (php5.6-curl) and GD (lib5.6-gd), as well as enable PHP 5.6 in Apache 2.4 (libapache2-mod-php5.6).

Apache will be restarted during the process.

That's all steps you have to do.


Hint: If you want to upgrade to PHP 7 instead (off-topic), just issue the following command after Step 3 (skip Step 4):

apt-get dist-upgrade

Final words: Not recommend to upgrade to PHP 5.6 in Ubuntu 12.04, as it involves upgrading Apache to 2.4. Ubuntu 14.04 comes with Apache 2.4, which is a lot easier to upgrade PHP 5.6.

查看更多
登录 后发表回答