I wasn't sure whether to include this in Ask Ubuntu or Stack Overflow where I decided on Stack Overflow since I'm having some parsing issues.
Using Ubuntu 17.04, PHP5.6 in XAMPP
So I'm trying to use the bitwasp/bitcoin composer package and it requires two extensions to be installed, ext-gmp and ext-bcmath, where I have installed them using:
sudo apt-get install php5.6-bcmath
sudo apt-get install php5.6-gmp
When executing the Bitcoin code, I get this error:
Fatal error: Call to undefined function Mdanter\Ecc\Curves\gmp_init() in /usr/dev/proj/PROECTNAME/vendor/mdanter/ecc/src/Curves/SecgCurve.php on line 117
Bcmath has successfully been found, but gmp hasn't. (using /opt/lampp/bin/php -m it's not on the list)
By running sudo apt-get install php5.6-gmp I get:
Here is a pastebin of the PHP modules I have concerning /opt/lampp/php -m.
Things I've tried:
Purge packages then re-install using different versions, but the default php-gmp package is for PHP7
Adding extension=gmp, =php_gmp.so, =gmp.so, gives me an error that the extension was not able to be found.
Related
I want to update php version from 7.0 to 7.1 so i tried update php commands to update php version on ubuntu system.
But its not updated, so i removed php 7.0 version using purge command
sudo apt-get purge 'php*'
These are the commands i tried for update php7.1 version after uninstall php7.0
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1 php7.1-common
Getting error in command prompt as
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.1
E: Couldn't find any package by glob 'php7.1'
E: Couldn't find any package by regex 'php7.1'
E: Unable to locate package php7.1-common
E: Couldn't find any package by glob 'php7.1-common'
E: Couldn't find any package by regex 'php7.1-common'
What im missing or did any thing wrong here?
It seems like php7.1 and php7.1-common packages are not available in your apt's sources.
I am assuming you are using the latest Ubuntu 18 LTS.
You could install php7.2 from the repositories, however older versions are not included anymore. You would have to install them manually.
For Version 7.2
sudo apt update
sudo apt install php7.2 php7.2-common
php -v
For Version 7.1
Download php
Extract the downloaded archive
Follow the included readme file
other options
If you are developing with different versions of PHP you might want to look into PHP docker containers
PHPDocker.io can be a good starting point.
EDIT: Also maybe consider posting this question on askubuntu instead, they might have more specific knowledge there.
You need to remove the old version before adding the new one.
Try: sudo apt-get remove php7.0*
Also it is useful to list all php packages to check if you are installing all you need.
sudo apt-get list php*
Then it is safe to run your commands.
I had php 5.4 on centOs and I have removed that and installed php 7.
Now One of my codes on server return the following error:
PHP Fatal error: Call to undefined function mb_internal_encoding()
And when I run yum install php-mbstring I got the following error:
Error: php70u-common conflicts with php-common-5.4.16-43.el7_4.x86_64
Error: php70u-json conflicts with php-common-5.4.16-43.el7_4.x86_64
I have removed and installed php7 several times but I didn't work.
It seems that centOs want to install an older version of the package but I don't know how to tell it to download the latest version of mbstring
To search the right MB-String for your PHP version try this command:
sudo yum list | egrep 'php' | grep 70
Change (70) by the specific version of PHP you do have installed in your server,this command will show you all the packages related to you PHP version.
This command will show :
ea-php70-php-mbstring.i686
ea-php70-php-mbstring.x86_64
Now you can install the version compatible with your system.I hope it will works for you.
yum install php72w-mbstring
will install the mbstring for 7.2
cannot-initialize-mbstring-with-php-7
If that does not work, you might only have package for 7.1 available
If that still does not work, you could remove the old 5.4 php common package and try again :
First search which old php packages are still installed on your machine :
yum list installed | grep php | grep 5.4
Then remove the old packages (for instance php-commom-5.4 . You can do the same with other ones if not used)
yum remove php-common-5.4
Then install php-mbstring again
yum install php-mbstring
Since my upgrade from PHP 5.5.9 to 5.6 on my Ubuntu 14.04 LTS server I have been getting problems with the expect library for PHP. It keeps displaying the Fatal error in the description. I believe the package that I need for this is libexpect-php5. Some installation checks confirm that it is installed:
root#k1:/etc/php5/conf.d$ dpkg --get-selections | grep -v deinstall | grep expect
empty-expect install
expect install
expect-dev install
expect-lite install
libexpect-ocaml install
libexpect-ocaml-dev install
libexpect-perl install
**libexpect-php5** install // installed right?
libexpect-simple-perl install
libghc-hspec-expectations-dev install
libghc-hspec-expectations-doc install
libghc-hspec-expectations-prof install
libnet-scp-expect-perl install
libtest-expect-perl install
netexpect install
python-pexpect install
python-pexpect-doc install
python3-pexpect install
and
root#k1:/etc/php5/conf.d$ expect -v
expect version 5.45
and the expect.so files:
root#k1:/usr/lib$ ls | grep expect
libexpect.so
libexpect.so.5
libexpect.so.5.45
and finally my /etc/php5/apache2/php.ini file:
extension=expect.so
I had to install libexpect-ph5 by downloading and installing the .deb file manually, because it was erring about an uninstallable dependency api... Now when I do and apt-get update && apt-get upgrade it keeps telling me this:
The following packages have been kept back:
libexpect-php5
Just installing that package does something, but the system will still keep the package back. This leaves me with a PHP version that doesn't know about the expect_popen() function.
How do I solve this?
I found out that Apache2 was loading the wrong php.ini file. Since the upgrade to PHP 5.6 the path has changed as well (of course).
Old location:
/etc/php/apache2/php.ini
New location:
/etc/php/5.6/apache2/php.ini
Along with that I had to specify the exact path to my expect.so extension in php.ini.
I had a Yii installation that was working fine up until today. I installed updates on my machine today after which this error was being thrown on all pages:
PHP Fatal Error – yii\base\ErrorException
Uncaught Error: Call to undefined function yii\web\mb_strlen() in /application/vendor/yiisoft/yii2/web/ErrorHandler.php:404
I ran composer update but the error persists.
I am using yii 2.0.7 on PHP 7 on Ubuntu 14.04. How do I fix this?
The error is a bit of a red herring since mb_strlen() is actually part of the mbstring php extension and not a function in yii2.
In php5 mbstring was part of libapache2-mod-php5.
It seems to be missing from libapache2-mod-php7. To fix this install the php7.x-mbstring package where x is your version:
sudo apt install php7.x-mbstring
You may need to restart Apache after this install.
For PHP7.1
Debian flavours
sudo apt-get install php7.1-mbstring
RedHat flavours
sudo yum install php7.1-mbstring
CentOS/RHEL-based
To get a list of available modules to check the version you need is available:
yum search mbstring
Installing mbstring module:
sudo yum install php-mbstring
This will install the correct version for you for your current php installation.
I want to install the v8js extension for PHP5.5 on Ubuntu 12.04 but can't make it working.
When I try to install the v8js extension version 0.2.0 (latest) with PECL, I have this message:
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
If I try to install an old version, I have a compilation error. This message is very similar to my issue: Install v8js for php on ubuntu
How can I fix this issue?
EDIT: I couldn't install it on Ubuntu 14.04 with PHP5.5, even with a PHP downgrade with PHPbrew to PHP 5.4. However, using Ubuntu 12.04 with PHP 5.4 works great. I didn't try the downgrade from PHP 5.5 to 5.4 on Ubuntu 12.04.
in case you can't find libv8-dev or libv8-dbg, you can find the correct version by run command
~$ apt-cache search libv8
libv8-3.14-dbg - V8 JavaScript engine - debugging symbols
libv8-3.14-dev - V8 JavaScript engine - development files for 3.14 branch
libv8-3.14.5 - V8 JavaScript engine - runtime library
libv8-dev - V8 JavaScript engine - development files for latest branch
then you can run
~$ sudo apt-get install libv8-3.14-dev libv8-3.14-dbg g++ cpp
then you can try to install v8js via pecl by running
~$ sudo pecl install v8js-0.2.0
if that command return error like this
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
you can try to install v8js-0.1.3 instead by running
~$ sudo pecl install v8js-0.1.3
then edit your php.ini to add v8js extension
~$ echo "extension=v8js.so" >> /etc/php5/cli/php.ini
Open your terminal/console
sudo apt-get install libv8-dev libv8-dbg g++ cpp
Make an update sudo apt-get update
Try sudo pecl install v8js-0.2.0 (or other version i.e.: sudo pecl install v8js-0.1.3)
Edit your php.ini (Check: Where is my php.ini file?) file by adding: extension=v8js.so.
Restart server
If it the extension still doesn't work, try to edit /etc/php5/conf.d/v8js.ini and add extension=v8js.so and restart server again.
Hope this helps.
These other answers work well and I used v8js-0.1.3 for the past 1.5 years but after needing to upgrade to PHP 7 I needed a better solution as v0.1.3 doesn't compile with PHP 7 (something to do with php_smart_str being renamed to php_smart_string).
After a couple hours of frustrating research and compiling libv8 myself, I didn't want to have to go through this whole process on every server I provisioned.
Anyway, I found this site which points you to a launchpad PPA site that provides a couple different ubuntu packages with the 5.1 and 5.2 libv8 libraries.
I ran these commands (please don't add repositories of 3rd party devs without understanding the risks).
sudo apt-add-repository ppa:pinepain/libv8-5.2
sudo apt-get update
sudo apt-get install libv8-5.2-dev
sudo pecl install v8js-1.1.0
(Thanks #JeyKeu for suggesting to add "apt-get update" to these commands)
I couldn't get v8js-1.3.0 or 1.2.0 to build, but 1.1.0 worked well. I checked the changelog and found that the latest updates are not necessary in my circumstance anyway.