Upgrade php 5.5.* to php 5.6.* using apt-get - php

I installed a new local server, when I installed php5 package with apt-get install php5 it got the version 5.6.
My production server is still with php 5.5 and I would like to upgrade it to php 5.6 like in my dev environment.
Can I do it easily using apt-get ? tell to apt-get to switch to the branch 5.6 ?
Thx

Enter the following commands in the order shown:
apt-get -y update
add-apt-repository ppa:ondrej/php
apt-get -y update
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
Enter the following command to verify PHP 5.6 installed properly:
php -v
Following is a sample response that indicates PHP 5.6 is installed:
PHP 5.6.22-4+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Done+

To upgrade to a newer version of PHP 5.6 on Ubuntu 14.04, you can use Ondřej Surý's PPA. He is one of the Debian maintainers of the php5 package. To add the PPA and upgrade your packages, run:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5

For PHP 5.6
sudo add-apt-repository ppa:ondrej/php5-5.6
For PHP 5.5
sudo add-apt-repository ppa:ondrej/php5
Reference

I know that it's a little late to answer this question , but for anyone like me who is confused when upgrading php , I should say please note that before installing new version of php remove it completely from your system, even remove config files and extensions, It caused me so many errors and problems.
sudo apt-get purge php.*
sudo rm -rf /etc/php5
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5

Related

Fail to install xdebug in Ubuntu with php7.2

I'm trying to install xdebug in my recently upgraded Ubuntu 20.04.1
When I place the output of phpinfo() in https://xdebug.org/wizard
I get:
Installation Wizard
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: no
Zend Server: no
PHP Version: 7.2.34
Zend API nr: 320170718
PHP API nr: 20170718
Debug Build: no
Thread Safe Build: no
OPcache Loaded: no
Configuration File Path: /opt/lampp/etc
Configuration File: /opt/lampp/etc/php.ini
Extensions directory: /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
The installation recommends me to install the version: xdebug-3.0.1
But when I follow the instructions I get this error from the terminal:
The following packages have unmet dependencies:
php-dev : Depends: php7.4-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
How can I solve this problem?
Should I install an older package of xdebug to be compatible with my php7.2 version?
Thanks in advance.
I solved the problem by installing php7.2-dev in my Ubuntu 20.04.1
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.2-dev
After that I could run phpize and still use XDebug 3.
set php v7.2(optional)
update-alternatives --set php /usr/bin/php7.2
then set and update all needed for php7.2:
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install -y php7.2 php7.2-xdebug

How can i downgrade the PHP 7.2.xx version to 7.1.XX or 7.0.xx on EC2 Linux 2

I am new to EC2. I have installed the latest php version which 7.2.22 . But my php files are in supported in latest version. So whether running the file in php in ec2 linux 2 its not working. So i have decide to downgrade php 7.2 to php 7.1.xx or php 7.0.xx.
How to Downgrade it. or else How can i uninstall php 7.2.xx and reinstall php 7.1.xx or php 7.0.xx
Please give the command to better understands and execute the commands to check.
Thanks in Advance...
I am instructing the command in ubuntu,
Command will differ wrt. to OS
Please purge the 7.2 php than Re-install 7.0 or 7.1
sudo apt-get purge php7.0-common
Install php 7.1
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.1
Install php 7.0
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.0
Hope it helps .....!!!

Ubuntu PHP 5 Install Curl Cannot Find Package

I'm getting a PHP Fatal error:
Call to undefined function curl_init() error while testing some PHP code on my server.
I assumed Curl needed to be installed so i found the PHP version first:
php --version
PHP 5.6.11-1ubuntu3.4 (cli)
I proceeded to install the package:
sudo apt-get install php5-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-curl
I then tried:
sudo apt install php-curl
and it appeared to install but I saw references to PHP 7 and it completed successfully.
Yet, the problem persists.
How do I get curl running to stop the init() error?
UPDATE: When I run this I get:
sudo apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
curl is already the newest version (7.47.0-1ubuntu2.13).
0 upgraded, 0 newly installed, 0 to remove and 172 not upgraded.
You are using Ubuntu#16.04. 16.04 does not ship with php#5 but with php#7.
If you need your older version of php and its dependencies, you have to install it differently.
There is a trustworthy (note: any external repository may still be a security thread) repository maintained by ondrej, namely:
ondrej/php
I have build a Dockerfile using 16.04 to showcase how you could install php#5.6 and php5.6-curl:
FROM ubuntu:16.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq update && \
apt-get -qq install software-properties-common > /dev/null && \
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php -y > /dev/null && \
apt-get -qq update && apt-get -qq install php5.6 php5.6-curl > /dev/null
RUN php -v && php -m | grep curl
This Dockerfile is not ideal, yet the last run prints:
PHP 5.6.40-8+ubuntu16.04.1+deb.sury.org+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
curl
showing that it has php#5.6 and php-curl#5.6 installed.
Try:
First Install CURL by typing sudo apt-get install curl.
Then Restart Apache by typing sudo service apache2 restart.
Install PHP5 CURL sudo apt-get install php5-curl.
Restart Apache by typing sudo service apache2.

Install php 5.3 or 5.4 on Ubuntu 16.04 Xenial and apache

I want to Install php 5.3 or 5.4 on Ubuntu 16.04 Xenial and Apache.
A tutorial points me to use PPA but they are not helping me in what I need.
I know that PHP 5.3 and 4 are obsolete but I need this for a project and is this possible? If yes then please teach me how in a step by step procedure with Apache2.
you can use this package ppa:sergey-dryabzhinsky/php53 to install php 5.3, i managed with this package on ubuntu 16.
sudo add-apt-repository ppa:sergey-dryabzhinsky/php53
sudo apt-get update
sudo apt-get install php5
Before installing PHP 5.4 you need to read this notice:
Security support for PHP 5.4 has ended. You are using this repository knowing that there might be and probably are unfixed security vulnerabilities. Please upgrade to PHP 5.6 or PHP 7.0 as found in the main repository: ppa:ondrej/php
After understanding the risks , to install PHP 5.4 ,add the PPA to your sources.list:
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update
Install it:
sudo apt-get install -y php5
To be safe , the PHP 5.6 version can be installed as follows:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart
Update
All version prior to PHP 5.6 are unsupported
This page lists the end of life date for each unsupported branch of PHP. If you are using these releases, you are strongly urged to upgrade to a current version, as using older versions may expose you to security vulnerabilities and bugs that have been fixed in more recent versions of PHP.
*reference for PHP 5.6 downgrade from PHP 7
Install add-apt-repository
sudo apt-get install python-software-properties
Add repository for PHP 5
sudo add-apt-repository -y ppa:ondrej/php
Update
sudo apt-get update
Install php5-fpm
sudo apt-get install php5.6-fpm
Move files
sudo mv /usr/bin/php /usr/bin/php7
sudo mv /usr/bin/php5.6 /usr/bin/php
Check PHP version
php -v
Restart Apache
sudo service apache2 restart
Try to use php version switcher: phpbrew.
Supported versions
While this may not answer your problem, but PHP-5 can be installed on ubuntu 14.04 (I have tried on Amazon EC2)
You can use
sudo apt‐get install php5 libapache2‐mod‐php5 php5‐mcrypt
sudo service apache2 restart
This will install 5.5.9 as on 25-Apr-2017.

brew install homebrew/php/php56 giving me an error

Hi I am trying to install homebrew php56 on ubuntu 14.04
I installed php 5.6 and apache2 and other dependencies of installation like perl, curl , etc.
But still I am getting this error.
That's rather a freaky way — install something on Ubuntu Linux through homebrew — it's actually should not work.
You'd better use apt package manager. You can install php-5.6 binaries from PPA:
sudo apt-get update && sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install php5

Categories