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

前端 未结 4 960
灰色年华
灰色年华 2021-01-31 04:22

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 gettin

4条回答
  •  广开言路
    2021-01-31 05:08

    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.

提交回复
热议问题