G
G
Glazzzz2016-12-06 11:05:19
PHP
Glazzzz, 2016-12-06 11:05:19

Two versions of PHP on the same server. How to install modules for one of them?

Hello!
On one local server, two versions of php are installed at once - 5.6 and 7.0. Two are needed for different projects. When I switch to version 5.6, phpinfo displays this version, but the php -v console still displays 7.0. Apparently for this reason, when I try to install a module (mbstring) for version 5.6 through the console, then there is an attempt to add this module to version 7.0 and 5.6 is ignored.
Can you please tell me how to correctly install modules for two different versions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Sundukov, 2016-12-06
@Glazzzz

Distribution and list of installed packages in the studio.
You can find out the distribution from the console:
list of packages:
An example of the output I have:

[email protected]:~$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="12.04.5 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.5 LTS)"
VERSION_ID="12.04"
[email protected]:~$ sudo dpkg --list | grep php
ii  dh-php                                      0.23+deb.sury.org~precise+1                             debhelper add-on to handle PHP PECL extensions
ii  dh-php5                                     0.2+deb.sury.org~precise+1                              debhelper add-on to handle PHP PECL extensions
ii  php-common                                  1:45+deb.sury.org~precise+1                             Common files for PHP packages
ii  php-gearman                                 2.0.2+1.1.2-1+deb.sury.org~precise+1                    PHP wrapper to libgearman
ii  php-pear                                    1:1.10.1+submodules+notgz-8+donate.sury.org~precise+2   PEAR Base System
ii  php-xdebug                                  2.5.0-1+deb.sury.org~precise+1                          Xdebug Module for PHP
ii  php-xml                                     1:7.0+45+deb.sury.org~precise+1                         DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii  php5-cli                                    5.5.37+dfsg-1+deprecated+dontuse+deb.sury.org~precise+1 command-line interpreter for the php5 scripting language
ii  php5-common                                 5.5.37+dfsg-1+deprecated+dontuse+deb.sury.org~precise+1 Common files for packages built from the php5 source
ii  php5-curl                                   5.5.37+dfsg-1+deprecated+dontuse+deb.sury.org~precise+1 CURL module for php5
ii  php5-dev                                    5.5.37+dfsg-1+deprecated+dontuse+deb.sury.org~precise+1 Files for PHP5 module development
ii  php5-fpm                                    5.5.37+dfsg-1+deprecated+dontuse+deb.sury.org~precise+1 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php5-json                                   1.3.9-1+deb.sury.org~precise+3                          JSON module for php5
ii  php5-memcache                               3.0.8-5+deb.sury.org~precise+1                          memcache extension module for PHP5
ii  php5-memcached                              2.2.0-2+deb.sury.org~precise+1                          memcached extension module for PHP5, uses libmemcached
ii  php5-mysql                                  5.5.37+dfsg-1+deprecated+dontuse+deb.sury.org~precise+1 MySQL module for php5
ii  php5-readline                               5.5.37+dfsg-1+deprecated+dontuse+deb.sury.org~precise+1 Readline module for php5
ii  php5-redis                                  2.2.7-1+deb.sury.org~precise+1                          PHP extension for interfacing with Redis
ii  php5-xdebug                                 2.3.2-1+deb.sury.org~precise+1                          Xdebug Module for PHP 5
ii  php5.5                                      5.5.38-4+deb.sury.org~precise+1                         server-side, HTML-embedded scripting language (metapackage)
ii  php5.5-cli                                  5.5.38-4+deb.sury.org~precise+1                         command-line interpreter for the PHP scripting language
ii  php5.5-common                               5.5.38-4+deb.sury.org~precise+1                         documentation, examples and common module for PHP
ii  php5.5-dev                                  5.5.38-4+deb.sury.org~precise+1                         Files for PHP5.5 module development
ii  php5.5-fpm                                  5.5.38-4+deb.sury.org~precise+1                         server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php5.5-json                                 5.5.38-4+deb.sury.org~precise+1                         JSON module for PHP
ii  php5.5-mbstring                             5.5.38-4+deb.sury.org~precise+1                         MBSTRING module for PHP
ii  php5.5-mysql                                5.5.38-4+deb.sury.org~precise+1                         MySQL module for PHP
ii  php5.5-opcache                              5.5.38-4+deb.sury.org~precise+1                         Zend OpCache module for PHP
ii  php5.5-readline                             5.5.38-4+deb.sury.org~precise+1                         readline module for PHP
ii  php7.0-cli                                  7.0.13-1+deb.sury.org~precise+1                         command-line interpreter for the PHP scripting language
ii  php7.0-common                               7.0.13-1+deb.sury.org~precise+1                         documentation, examples and common module for PHP
ii  php7.0-curl                                 7.0.13-1+deb.sury.org~precise+1                         CURL module for PHP
ii  php7.0-dev                                  7.0.13-1+deb.sury.org~precise+1                         Files for PHP7.0 module development
ii  php7.0-fpm                                  7.0.13-1+deb.sury.org~precise+1                         server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.0-intl                                 7.0.13-1+deb.sury.org~precise+1                         Internationalisation module for PHP
ii  php7.0-json                                 7.0.13-1+deb.sury.org~precise+1                         JSON module for PHP
ii  php7.0-mbstring                             7.0.13-1+deb.sury.org~precise+1                         MBSTRING module for PHP
ii  php7.0-mcrypt                               7.0.13-1+deb.sury.org~precise+1                         libmcrypt module for PHP
ii  php7.0-mysql                                7.0.13-1+deb.sury.org~precise+1                         MySQL module for PHP
ii  php7.0-opcache                              7.0.13-1+deb.sury.org~precise+1                         Zend OpCache module for PHP
ii  php7.0-pgsql                                7.0.13-1+deb.sury.org~precise+1                         PostgreSQL module for PHP
ii  php7.0-readline                             7.0.13-1+deb.sury.org~precise+1                         readline module for PHP
ii  php7.0-xml                                  7.0.13-1+deb.sury.org~precise+1                         DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii  pkg-php-tools                               1.21+deb.sury.org~precise+1                             various packaging tools and scripts for PHP packages

Accordingly, under version 7, I set it like this:
#apt-get install php7.0-mbstring

A
Anton, 2016-12-06
@karminski

Modules for PHP 5.x are installed with the apt-get install php5-module_name command. For PHP 7.0 - apt-get install php7.0-module_name. These modules will not overlap.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question