I followed this tutorial:
$ apt-get install php-pear php5-dev libmagic-dev
$ pecl install fileinfo
$ sudo echo "extension=fileinfo.so" > /etc/php5/fileinfo.ini
$ sudo apachectl restart
But when I run this, it said failing message:
root#111:~/mine/Fileinfo-1.0.4# pecl install fileinfo
WARNING: "pear/Fileinfo" is deprecated in favor of "channel://php-src/ext/fileinfo/in php sources"
downloading Fileinfo-1.0.4.tgz ...
Starting to download Fileinfo-1.0.4.tgz (5,835 bytes)
.....done: 5,835 bytes
3 source files, building
WARNING: php_bin /alidata/server/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Cannot find config.m4.
Make sure that you run '/alidata/server/php/bin/phpize' in the top level source directory of the module
ERROR: `phpize' failed
Here is my machine information:
root#111:~/mine/Fileinfo-1.0.4# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise
Here is my PHP version information:
root#111:~/mine/Fileinfo-1.0.4# php --version
PHP 5.4.27 (cli) (built: Jun 12 2014 22:20:06)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies
Related
I have curl installed and running on php for Apache2. On command line however it does not work:
$ php test.php
PHP Fatal error: Uncaught Error: Call to undefined function curlhttp()
checking for curl:
$ php -i | grep curl
/etc/php/7.0/cli/conf.d/20-curl.ini,
curl
having a deeper look:
cat /etc/php/7.0/cli/conf.d/20-curl.ini
; configuration for php curl module
; priority=20
extension=curl.so
where is the library anyway?
$ locate curl.so
/usr/lib/php/20151012/curl.so
/usr/lib/x86_64-linux-gnu/libcurl.so
/usr/lib/x86_64-linux-gnu/libcurl.so.3
/usr/lib/x86_64-linux-gnu/libcurl.so.4
/usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0
which php version?
$ php -v
PHP 7.0.33-0ubuntu0.16.04.15 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33-0ubuntu0.16.04.15, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
Let's check SO for a solution:
How to install php-curl in Ubuntu 16.04
trying to reinstall:
sudo apt install php7.0-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-curl is already the newest version (7.0.33-0ubuntu0.16.04.15).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
$ sudo apt install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
curl is already the newest version (7.47.0-1ubuntu2.14).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
I don't see the problem. What might be the cause and how can this be fixed?
I have Centos 7 and Virtualmin installed, with the tipycal php-fpm 5.4, 7.0, 7.1 that you can choice between the versions you prefer on every virtualhost via Virtualmin control panel, and everything works well.
But when I access to the server via SSH and check php -v I get this:
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
How can I select another php default/base version for the shell system?
When you issue the php command on the shell it uses the default php version on the server which in your case is php-5.4.16
To use another php version, you have to check where the binaries for those php versions are and invoke them with their full path rather than just typing php.
For example, on CentOS, for PHP 7.2 for example, the full path of the php binary is: /opt/rh/rh-php72/root/usr/bin/php
root#virtualmin /root
ยป /opt/rh/rh-php72/root/usr/bin/php -v
PHP 7.2.24 (cli) (built: Nov 4 2019 10:23:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24, Copyright (c) 1999-2018, by Zend Technologies
Install versions of PHP in centos 7
Setup Yum Repository
First of all, you need to enable Remi and EPEL yum repositories on your system. Use the following command to install EPEL repository on your CentOS and Red Hat 7/6 systems
Use this command to install EPEL yum repository on your system
sudo yum install epel-release
and now execute one of the following commands as per your operating system version to install the Remi repository.
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Install PHP 7 on CentOS
Your system is prepared for the PHP installation from yum repositories. Use one of the following commands to install PHP 7.4 or PHP 7.3 or PHP 7.2 or PHP 7.1 on your system based on your requirements.
Install PHP 7.4
yum --enablerepo=remi-php74 install php
Install PHP 7.3
yum --enablerepo=remi-php73 install php
Install PHP 7.2
yum --enablerepo=remi-php72 install php
.
Check version PHP install
php -v
.
PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Install PHP Modules
You may also need to install additional PHP modules based on your application requirements. The below command will install some more useful PHP modules.
For PHP 7.4
yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
For PHP 7.3
yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
For PHP 7.2
yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
I'm trying to install the yaml extension on Ubuntu.
I have PHP 7.1 on my server.
ubuntu#www1:~$ php -v
PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:27:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.15-1+ubuntu14.04.1+deb.sury.org+2, Copyright
(c) 1999-2018, by Zend Technologies
I was following another SO post that said to run
sudo apt install libyaml-dev php-dev php-pear
When I do that, the installer says, in part:
The following extra packages will be installed:
dh-php php7.2-cli php7.2-common php7.2-dev php7.2-json php7.2-opcache
php7.2-readline pkg-php-tools xml2
Suggested packages:
dh-make
The following NEW packages will be installed:
dh-php php-dev php7.2-cli php7.2-common php7.2-dev php7.2-json
php7.2-opcache php7.2-readline pkg-php-tools xml2
0 upgraded, 10 newly installed, 0 to remove and 85 not upgraded.
Need to get 3,073 kB of archives.
After this operation, 18.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
So, why would the installer install PHP 7.2 extensions on a PHP 7.1 server?
I aborted the install and came here to ask:
How do I force my server to stay at PHP 7.1 and install the yaml extension?
Have you tried
sudo apt-get install -y php7.1-yaml
I have an error saying MongoClient class is not found.
I've tried both the instructions on the MongoDB website and these answers.
Upon php -v there is
PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mongo.so'
PHP 5.6.30-1+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
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
with sudo grep -rnw /etc -e "mongo.so"
I have
/etc/php/5.6/fpm/php.ini:2033:extension=mongo.so
/etc/php/5.6/cli/php.ini:2032:extension=mongo.so
/etc/php/5.6/apache2/php.ini:2033:extension=mongo.so
Then I tried the manual installation.
When I run phpize
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
At the make test output I get
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
How do I compile the correct module?
I've removed php 7 entirely
sudo apt-get purge php7.*
I guess you had installed the wrong extension for your system.
I suggest to start fresh and use pecl to install and compile mongo extension properly.
Install pecl (assuming that you are using Debian-based distribution with correct apt repos, pecl comes bundled with php-pear)
sudo apt-get install php5-dev php-pear
Install the legacy mongo driver from pecl
sudo pecl install mongo
Add extension=mongo.so on php.ini
sudo su
echo "extension=mongo.so" >> /etc/php5/mods-available/mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/cli/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/fpm/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/apache2/conf.d/30-mongo.ini
Note that the legacy driver is not compatible with PHP 7+ and the lastest version of MongoDB one can use with this driver is 3.0. See the compatibility chart from MongoDB Docs.
I have a Vaprobash VagrantFile building a Ubuntu Nginx stack.
In it I specify PHP v5.6:
php_version = "5.6" //Options: 5.5 | 5.6
However, I run
$ vagrant up
when I ssh into the box and do
$ php -v
it shows PHP 5.5.9-1ubuntu4.20 (cli) (built: Oct 3 2016 13:00:37).
Why wasn't 5.6 installed?
I am not sure this repo has been updated for php after the ppa has been migrated (see https://github.com/oerdnj/deb.sury.org/wiki/PPA-migration-to-ppa:ondrej-php)
basically in scripts/php.sh you need to replace ppa by
sudo add-apt-repository ppa:ondrej/php
(make sure to run sudo apt-get update if you're running this command directly from the VM after the initial provisioning) -
and to install php5.6 you need to run
sudo apt-get install -qq libapache2-mod-php5.6
with this change, you now get
vagrant#vaprobash:~$ php -v
PHP 5.6.28-1+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
If you need additional php modules, make sure to replace the installation by specifying 5.6 in your php version such as
sudo apt-get install -qq php5.6-fpm