Question

Why I can't install php5 modules on Ubuntu 16.04?

Posted September 24, 2016 87.2k views
PHPUbuntu 16.04

Hello,

I have just finished setting up my Ubuntu 16.4 server. I have installed php5.6.26 because I am going to use Wordpress and I am not sure if all plugins are compatible with php7.

I need to install some php modules like php-xmlrpc or another module. When I type

sudo apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc

This command is from this article on DO [How To Install WordPress with LAMP on Ubuntu 16.04]
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04
I get this message

 sudo apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-gd is already the newest version (1:7.0+44+deb.sury.org~xenial+1).
The following additional packages will be installed:
  libcurl3 libxmlrpc-epi0 php7.0-curl php7.0-mbstring php7.0-mcrypt php7.0-xml php7.0-xmlrpc
The following NEW packages will be installed:
  libcurl3 libxmlrpc-epi0 php-curl php-mbstring php-mcrypt php-xml php-xmlrpc php7.0-curl php7.0-mbstring
  php7.0-mcrypt php7.0-xml php7.0-xmlrpc
0 upgraded, 12 newly installed, 0 to remove and 11 not upgraded.
Need to get 869 kB of archives.
After this operation, 2,943 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Honestly I don’t want to use php7 and I have already explained why.
How can I install the modules of php5, not php7?

What is the difference between modules for php7 and for php5?
Can I still use php5 while the modules are for php7?

Thank you very much :)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

As of Ubuntu 16.04.x default PHP version is PHP7. You should add PHP5 repository and you will be able to install it.

First of all add repository :

  • sudo add-apt-repository ppa:ondrej/php

When it finishes update apt:

  • sudo apt-get update

After that executing

  • sudo apt-get install php5.6

You can also install any php package, but you need to refer as php5.6 instead of php, e.g. php5.6-mbstring instead of php-mbstring.

Also note: remove all php7 packages

  • Hi @xMudrii

    Thanks for your answer. I have already installed php5.6 the same way you have described.
    But writing php5.6-(module name) did the trick. I was always thinking that ubuntu will take the installed version of php on the system when I call php-xmlrpc, but apparently not!
    I could install all packages by adding 5.6- to the names.

    sudo apt-get install php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-xml php5.6-xmlrpc
    

    PS: I have already removed all php7 packages.

I have 404 error on ppa:ondrej/php ppa. Is it some other way to install php5.5 on ubuntu 16..04?

Submit an Answer