PHP Modules not matching with PHP Info file - php-ini

So I am trying to install the bcmath module and it seems to have worked but when I check my phpinfo it says it is not on there.
This is the output I get when I do php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
Not sure if this makes a different but I am using nginx and CentOS and I also used the command yum install php74-php-bcmath.x86_64 to install it. Here is a screenshot of where the bcmath module should be in my phpinfo:

Related

How can I find out the version of a library that is packaged with Ruby, e.g. json?

Some Ruby functionality packaged with the Ruby distribution (and not needing to be installed as gems explicitly or via bundler). JSON is one example (require 'json'). It can be required in Ruby code but doesn't require gem installation.
Yet JSON is a gem on Github, at https://github.com/flori/json.
So how can I know which version of that gem I'm getting when I require 'json' in my code?
Alternatively many ruby gems specify their version in a constant.
You can utilize this to determine the version you are using in code or in console as well e.g.
require 'json'
JSON.constants.grep(/VERSION/)
#=>[:VERSION, :VERSION_ARRAY, :VERSION_MAJOR, :VERSION_MINOR, :VERSION_BUILD]
JSON::VERSION
#=> 2.5.1
require 'bundler'
Bundler.constants.grep(/VERSION/)
#=> [:VERSION]
Bundler::VERSION
#=> 2.2.3
You can find the Ruby home directory, and search below it for a directory of the appropriate name, and then inspect its version.rb file. For example, with rvm-managed rubies, I can do this (on a Posix-complaint system such as Linux or Mac OS):
$ cd $(which ruby)/../..; pwd
/Users/keith.bennett/.rvm/rubies/ruby-3.0.1
$find . -type d -name '*json*'
./lib/ruby/3.0.0/psych/json
./lib/ruby/3.0.0/json
./lib/ruby/3.0.0/rdoc/generator/template/json_index
./lib/ruby/3.0.0/x86_64-darwin19/json
./lib/ruby/gems/3.0.0/gems/json-2.5.1
./lib/ruby/gems/3.0.0/gems/rbs-1.0.4/stdlib/json
I can cat ./lib/ruby/3.0.0/json/version.rb | grep 'VERSION ' (include the space after "VERSION"), and I get:
VERSION = '2.5.1'
..which is also the version of the gem in the gems directory included in the listing above.
So I can see that 2.5.1 is my JSON version.

Difficulty installing JSON module for Perl on Mac [duplicate]

I get this error:
Can't locate Foo.pm in #INC
Is there an easier way to install it than downloading, untarring, making, etc?
On Unix:
usually you start cpan in your shell:
$ cpan
and type
install Chocolate::Belgian
or in short form:
cpan Chocolate::Belgian
On Windows:
If you're using ActivePerl on Windows, the PPM (Perl Package Manager) has much of the same functionality as CPAN.pm.
Example:
$ ppm
ppm> search net-smtp
ppm> install Net-SMTP-Multipart
see How do I install Perl modules? in the CPAN FAQ
Many distributions ship a lot of perl modules as packages.
Debian/Ubuntu: apt-cache search 'perl$'
Arch Linux: pacman -Ss '^perl-'
Gentoo: category dev-perl
You should always prefer them as you benefit from automatic (security) updates and the ease of removal. This can be pretty tricky with the cpan tool itself.
For Gentoo there's a nice tool called g-cpan which builds/installs the module from CPAN and creates a Gentoo package (ebuild) for you.
Try App::cpanminus:
# cpanm Chocolate::Belgian
It's great for just getting stuff installed. It provides none of the more complex functionality of CPAN or CPANPLUS, so it's easy to use, provided you know which module you want to install. If you haven't already got cpanminus, just type:
# cpan App::cpanminus
to install it.
It is also possible to install it without using cpan at all. The basic bootstrap procedure is,
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
For more information go to the App::cpanminus page and look at the section on installation.
I note some folks suggesting one run cpan under sudo. That used to be necessary to install into the system directory, but modern versions of the CPAN shell allow you to configure it to use sudo just for installing. This is much safer, since it means that tests don't run as root.
If you have an old CPAN shell, simply install the new cpan ("install CPAN") and when you reload the shell, it should prompt you to configure these new directives.
Nowadays, when I'm on a system with an old CPAN, the first thing I do is update the shell and set it up to do this so I can do most of my cpan work as a normal user.
Also, I'd strongly suggest that Windows users investigate strawberry Perl. This is a version of Perl that comes packaged with a pre-configured CPAN shell as well as a compiler. It also includes some hard-to-compile Perl modules with their external C library dependencies, notably XML::Parser. This means that you can do the same thing as every other Perl user when it comes to installing modules, and things tend to "just work" a lot more often.
If you're on Ubuntu and you want to install the pre-packaged perl module (for example, geo::ipfree) try this:
$ apt-cache search perl geo::ipfree
libgeo-ipfree-perl - A look up country of ip address Perl module
$ sudo apt-get install libgeo-ipfree-perl
A couple of people mentioned the cpan utility, but it's more than just starting a shell. Just give it the modules that you want to install and let it do it's work.
$prompt> cpan Foo::Bar
If you don't give it any arguments it starts the CPAN.pm shell. This works on Unix, Mac, and should be just fine on Windows (especially Strawberry Perl).
There are several other things that you can do with the cpan tool as well. Here's a summary of the current features (which might be newer than the one that comes with CPAN.pm and perl):
-a
Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.
-A module [ module ... ]
Shows the primary maintainers for the specified modules
-C module [ module ... ]
Show the Changes files for the specified modules
-D module [ module ... ]
Show the module details. This prints one line for each out-of-date module (meaning,
modules locally installed but have newer versions on CPAN). Each line has three columns:
module name, local version, and CPAN version.
-L author [ author ... ]
List the modules by the specified authors.
-h
Prints a help message.
-O
Show the out-of-date modules.
-r
Recompiles dynamically loaded modules with CPAN::Shell->recompile.
-v
Print the script version and CPAN.pm version.
sudo perl -MCPAN -e 'install Foo'
Also see Yes, even you can use CPAN. It shows how you can use CPAN without having root or sudo access.
Otto made a good suggestion. This works for Debian too, as well as any other Debian derivative. The missing piece is what to do when apt-cache search doesn't find something.
$ sudo apt-get install dh-make-perl build-essential apt-file
$ sudo apt-file update
Then whenever you have a random module you wish to install:
$ cd ~/some/path
$ dh-make-perl --build --cpan Some::Random::Module
$ sudo dpkg -i libsome-random-module-perl-0.01-1_i386.deb
This will give you a deb package that you can install to get Some::Random::Module. One of the big benefits here is man pages and sample scripts in addition to the module itself will be placed in your distro's location of choice. If the distro ever comes out with an official package for a newer version of Some::Random::Module, it will automatically be installed when you apt-get upgrade.
Already answered and accepted answer - but anyway:
IMHO the easiest way installing CPAN modules (on unix like systems, and have no idea about the wondows) is:
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
The above is installing the "zero configuration CPAN modules installer" called cpanm. (Can take several minutes to install - don't break the process)
and after - simply:
cpanm Foo
cpanm Module::One
cpanm Another::Module
Many times it does happen that cpan install command fails with the message like
"make test had returned bad status, won't install without force"
In that case following is the way to install the module:
perl -MCPAN -e "CPAN::Shell->force(qw(install Foo::Bar));"
Lots of recommendation for CPAN.pm, which is great, but if you're using Perl 5.10 then you've also got access to CPANPLUS.pm which is like CPAN.pm but better.
And, of course, it's available on CPAN for people still using older versions of Perl. Why not try:
$ cpan CPANPLUS
Use cpan command as cpan Modulename
$ cpan HTML::Parser
To install dependencies automatically follow the below
$ perl -MCPAN -e shell
cpan[1]> o conf prerequisites_policy follow
cpan[2]> o conf commit
exit
I prefer App::cpanminus, it installs dependencies automatically. Just do
$ cpanm HTML::Parser
On ubuntu most perl modules are already packaged, so installing is much faster than most other systems which have to compile.
To install Foo::Bar at a commmand prompt for example usually you just do:
sudo apt-get install libfoo-bar-perl
Sadly not all modules follow that naming convention.
On Fedora Linux or Enterprise Linux, yum also tracks perl library dependencies. So, if the perl module is available, and some rpm package exports that dependency, it will install the right package for you.
yum install 'perl(Chocolate::Belgian)'
(most likely perl-Chocolate-Belgian package, or even ChocolateFactory package)
Even it should work:
cpan -i module_name
2 ways that I know of :
USING PPM :
With Windows (ActivePerl) I've used ppm
from the command line type ppm. At the ppm prompt ...
ppm> install foo
or
ppm> search foo
to get a list of foo modules available. Type help for all the commands
USING CPAN :
you can also use CPAN like this (*nix systems) :
perl -MCPAN -e 'shell'
gets you a prompt
cpan>
at the prompt ...
cpan> install foo (again to install the foo module)
type h to get a list of commands for cpan
On Fedora you can use
# yum install foo
as long as Fedora has an existing package for the module.
Easiest way for me is this:
PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install DateTime::TimeZone'
a) automatic recursive dependency detection/resolving/installing
b) it's a shell onliner, good for setup-scripts
If you want to put the new module into a custom location that your cpan shell isn't configured to use, then perhaps, the following will be handy.
#wget <URL to the module.tgz>
##unpack
perl Build.PL
./Build destdir=$HOME install_base=$HOME
./Build destdir=$HOME install_base=$HOME install
Sometimes you can use the yum search foo to search the relative perl module, then use yum install xxx to install.
Secure solution
Many answers mention the use of the cpan utility (which uses CPAN.pm) without a word on security. By default, CPAN 2.27 and earlier configures urllist to use a http URL (namely, http://www.cpan.org/), which allows MITM attacks, thus is insecure. This is what is used to download the CHECKSUMS files, so that it needs to be changed to a secure URL (e.g. https://www.cpan.org/).
So, after running cpan and accepting the default configuration, you need to modify the generated MyConfig.pm file (the full path is output) in the following way. Replace
'urllist' => [q[http://www.cpan.org/]],
by
'urllist' => [q[https://www.cpan.org/]],
Note: https is not sufficient; you also need a web site you can trust. So, be careful if you want to choose some arbitrary mirror.
Then you can use cpan in the usual way.
My bug report on rt.cpan.org about the insecure URL.
Simply executing cpan Foo::Bar on shell would serve the purpose.
Seems like you've already got your answer but I figured I'd chime in. This is what I do in some scripts on an Ubuntu (or debian server)
#!/usr/bin/perl
use warnings;
use strict;
#I've gotten into the habit of setting this on all my scripts, prevents weird path issues if the script is not being run by root
$ENV{'PATH'} = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin';
#Fill this with the perl modules required for your project
my #perl = qw(LWP::Simple XML::LibXML MIME::Lite DBI DateTime Config::Tiny Proc::ProcessTable);
chomp(my $curl = `which curl`);
if(!$curl){ system('apt-get install curl -y > /dev/null'); }
chomp(my $cpanm = system('/bin/bash', '-c', 'which cpanm &>/dev/null'));
#installs cpanm if missing
if($cpanm){ system('curl -s -L http://cpanmin.us | perl - --sudo App::cpanminus'); }
#loops through required modules and installs them if missing
foreach my $x (#perl){
eval "use $x";
if($#){
system("cpanm $x");
eval "use $x";
}
}
This works well for me, maybe there is something here you can use.
On Windows with the ActiveState distribution of Perl, use the ppm command.

PHP7 and pdo_mysql [duplicate]

This question already has answers here:
PDO drivers no value in Windows
(18 answers)
Closed 5 years ago.
I've just upgraded PHP5.6 to PHP7 on my XAMPP on Windows 10 following this guide. It works just fine, except for PDO.
In my phpinfo() I get PDO support enabled, PDO drivers no value.
I copied the php.ini-development and renamed it to php.ini, and I have uncommented the extension folder declaration, and the extention driver php_pdo_mysql.dll.
extension_dir = "ext"
...
extension=php_pdo_mysql.dll
I have verified that php_pdo_mysql.dll is located in C:\xampp\php\ext and when I run php -m in a console, both PDO and pdo_mysql are listed as active modules.
C:\xampp\php>php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
filter
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mysqlnd
openssl
pcre
PDO
pdo_mysql
Phar
Reflection
session
SimpleXML
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
When I run a script that utilizes PDO, I get thrown
Fatal error: Uncaught PDOException: could not find driver in (path to script)
The script I am running is completely valid and worked fine before the upgrade (basically just a new PDO(params)).
What am I missing?
For some reason, not sure why, Windows needs an absolute path to the extension dir. So instead of
extension_dir = "ext"
in php.ini, I put
extension_dir = "C:/xampp/php/ext"
and then restarted apache. Everything works again.
Maybe someone can elaborate on this issue?

How to port OpenCv to NaCl

Does anyone know any way how to port OpenCV to NaCl? I'm trying to make Chrome extension based on face recognition. I would appreciate some help.
The detailed instructions below have been reposted from (the now defunct metacaptcha.com/install_opencv_nacl) for convenience.
1. Prerequitsites
OpenCV depends on several important libraries such as bzip2, zlib, NaclMounts and at least one decompression/compression library to handle common images such as libpng/jpeg/tiff. This article will focus on libjpeg only. Those libraries need to be built in both 32-bit and 64-bit architect as dynamic library using NaCl Glibc toolchain (Pepper 28).
In order to build the 32-bit and 64-bit shared libraries for NaCl, the 32-bit and 64-bit version of NaCl gcc/linker need to be used respectively. To make this easier in the tutorial, we make the following environment variables:
Note: In case one of the link in the article failed to work, a backup link can be found here.
export NACL_SDK_ROOT=/Users/thai/apps/nacl_sdk/pepper_28
export NACL_PREFIX="$NACL_SDK_ROOT"/toolchain/mac_x86_glibc/x86_64-nacl
export NACL_64="$NACL_SDK_ROOT"/toolchain/mac_x86_glibc/bin/x86_64-nacl
export NACL_32="$NACL_SDK_ROOT"/toolchain/mac_x86_glibc/bin/i686-nacl
1.1 Bzip2 for Native Client
Download Bzip2 v1.0.6, extract to your local directory. Makefile-libbz2_so is the file we want to use for make, we want to change the gcc toolchain parameters such that, instead of using the regular OS gcc, it will use the NaCl gcc in $NACL_SDK_ROOT/toolchain/mac_x86_glibc/x86_64-nacl/bin/.
Run make -f Makefile-libbz2_so on bzip2 with the following parameters, then copy the library into NaCl toolchain.
make -f Makefile-libbz2_so CC=$NACL_64-'gcc -m64'
cp libbz2.so.1.0.6 $NACL_PREFIX/lib64/libbz2.so
make clean
make -f Makefile-libbz2_so CC=$NACL_32-'gcc -m32'
cp libbz2.so.1.0.6 $NACL_PREFIX/lib32/libbz2.so
cp *.h $NACL_PREFIX/include
1.2 Zlib for Native Client
Download Zlib-1.2.8, extract to your local directory. Zlib is using autoconfig to generate Makefile, we will need to run this tool first then modify the GCC toolchain into NaCl one.
Run ./configure --enable-shared on zlib, then run make with the following parameters.
./configure --enable-shared
make shared CC=$NACL_64-'gcc -m64' AR=$NACL_64-ar ARFLAGS=rc CFLAGS='-O3 -DHAVE_HIDDEN' LDFLAGS='-O3 -fPIC -DHAVE_HIDDEN' LDSHARED='$(CC) -shared -Wl,-soname -Wl,libz.so' SHAREDLIB=libz.so SHAREDLIBM=libz.so.1.2.8 SHAREDLIBV=libz.so.1
cp libz.so.1 $NACL_PREFIX/lib64/libz.so
make clean
make shared CC=$NACL_32-'gcc -m32' AR=$NACL_32-ar ARFLAGS=rc CFLAGS='-O3 -DHAVE_HIDDEN' LDFLAGS='-O3 -fPIC -DHAVE_HIDDEN' LDSHARED='$(CC) -shared -Wl,-soname -Wl,libz.so' SHAREDLIB=libz.so SHAREDLIBM=libz.so.1.2.8 SHAREDLIBV=libz.so.1
cp libz.so.1 $NACL_PREFIX/lib32/libz.so
cp zlib.h zconf.h $NACL_PREFIX/include
1.3 libJPEG for Native Client
Download jpeg-v6b, NaCl jpeg makefile.cfg patch and put them to your local directory.
Patch the jpeg-v6b directory with the nacl-jpeg-makefile.cfg patch.
cd jpeg-6b
patch < nacl-jpeg-v6b-makefile.cfg.patch
Run ./configure on jpeg-6b, then run make libjpeg.so with the following parameters.
./configure
make libjpeg.so CC=$NACL_64-gcc CFLAGS='-m64 -fPIC -O2 -I.' LDFLAGS='-shared -Wl,-soname -Wl,libjpeg.so -o libjpeg.so'
mv libjpeg.so $NACL_PREFIX/lib64/libjpeg.so
make clean
make libjpeg.so CC=$NACL_32-gcc CFLAGS='-m32 -fPIC -O2 -I.' LDFLAGS='-shared -Wl,-soname -Wl,libjpeg.so -o libjpeg.so'
mv libjpeg.so $NACL_PREFIX/lib32/libjpeg.so
make install-headers prefix=$NACL_PREFIX
1.4 NaclMounts for Native Client
Download NaclMounts, nacl-mounts.patch and our custom Makefile
Go to your local nacl-mount directory, copy the Makefile into this directory, applying the patch and run the following commands (assuming you already set the environment variables at the beginning of the article)
cp Makefile nacl-mounts/
cd nacl-mounts/
patch -p0 < ../nacl-mounts.patch
make ARCH=x86_64 BIT=64
cp libnaclmounts.so $NACL_PREFIX/lib64
make clean
make ARCH=i686 BIT=32
cp libnaclmounts.so $NACL_PREFIX/lib32
make install-headers
2. OpenCV for Native Client
OpenCV need to be built in cross-compiling mode, to easily do that with cmake (build tool of OpenCV). We set CMAKE_SYSTEM_NAME=Linux to force cross-compiling for Linux target. A OpenCV-nacl-cmake script is written in order to facilitate the build process if you have already setup the environment variables in the previous step.
2.1 Setup source code
Download OpenCV 2.4.2, opencv-nacl-cmake script
Extract OpenCV to your local directory.
Create nacl/m32, nacl/m64 directory in OpenCV-2.4.2/ for building 32/64 bit version of OpenCV Native Client code.
Copy opencv-nacl-cmake script into nacl/ directory.
tar xvf OpenCV-2.4.2.tar.gz
cd OpenCV-2.4.2
mkdir nacl
cd nacl
mkdir m64 m32
cp ~/Downloads/opencv-nacl-cmake ./
2.2 Patch OpenCV I/O Library (persistance.cpp) / Exclude building of apps
In order for OpenCV to read/write to files in Native Client, a new file system library need to be used. This patch replace all the OS system calls for file I/O with NaclMounts library.
Download persistance.cpp patch for OpenCV 2.4.2
Copy the patch to your OpenCV dir, and apply the path using these commands
cp ~/Download/opencv-nacl-persistance.patch OpenCV-2.4.2
cd OpenCV-2.4.2
patch -p0 < opencv-nacl-persistance.patch
We also need to tell cmake to exclude the apps module in OpenCV (the apps module doesn't need to be ported). This can be done by simply moving the CMakeList.txt file in apps directory
mv apps/CMakeList.txt apps/CMakeList.txt.old
2.3 Configure, build and install
Run ./opencv-nacl-cmake with the following parameters to configure and build the library. The following bash commands also install both 32 and 64-bit versions of the library for OpenCV. Because of the naming convention of Native Client, we have to move the lib/, lib32/, lib64/ directory around in order to install the architecture correctly.
cd nacl/m32
../opencv-nacl-cmake i686 32
make -j8
unlink $NACL_PREFIX/lib64
mv $NACL_PREFIX/lib $NACL_PREFIX/lib64
mv $NACL_PREFIX/lib32 $NACL_PREFIX/lib
ln -s $NACL_PREFIX/lib $NACL_PREFIX/lib32
make install
unlink $NACL_PREFIX/lib32
mv $NACL_PREFIX/lib $NACL_PREFIX/lib32
mv $NACL_PREFIX/lib64 $NACL_PREFIX/lib
ln -s $NACL_PREFIX/lib $NACL_PREFIX/lib64
cd ../m64
../opencv-nacl-cmake x86_64 64
make -j8
make install
At this point, you have finished installing OpenCV 2.4.2 for Native Client Pepper 28.
A simple applications adapted from the OpenCV's tutorials to perform face detection in Google Chrome can be found in example_opencv_nacl_facedetect.

How to use Linux Xampp mysql_pdo with Symfony 2.0

I've got a serious problem.
I would like to use Doctrine 2 on my Symfony 2 projet.
I've change the php path from the app/console :
/opt/lampp/bin php
I've specify the good path for my mysql_pdo in /opt/lampp/etc/php.ini
pdo_mysql.default_socket = /opt/lampp/var/mysql/mysql.sock
and check to my php_info() for my pdo :
PDO
PDO support enabled
PDO drivers mysql, pgsql, sqlite, sqlite2
pdo_mysql
PDO Driver for MySQL enabled
Client API version mysqlnd 5.0.7-dev - 091210 - $Revision: 304625
$
Directive Local Value Master Value
pdo_mysql.default_socket /opt/lampp/var/mysql/mysql.sock /opt/lampp/var/mysql/mysql.sock
pdo_pgsql
PDO Driver for PostgreSQL enabled
PostgreSQL(libpq) Version 8.0.3
Module version 1.0.2
Revision $Id: pdo_pgsql.c 300351 2010-06-10 12:11:19Z iliaa $
Everything seems fine, but when I use this Symfony command :
php app/console doctrine:mapping:import WonderWBundle yml
It juste says :
[PDOException] could not find driver
I'm on Ubuntu 10.10
XAMPP for Linux 1.7.4 !
It seems that I've got everything to made Pdo work well but not on Symfony 2.
Does anyone could help ? Pleeeaaaassse (I'm going mad !!)
Thanks a lot :P
(P.S : Grrr cannot link my screenshots !)
Another reason could be related to PHP itself.
Various linux distros compile their php-cgi/fpm/apache and php-cli to use different php.ini files ( which actually makes sense )
Both ini files use to have their module configuration files included from subdirectories.
If you install an additional module manually, the `phpinfo()? viewed in a web browser may show the module, but programs executed on the commandline, just like Zend Framework app/console are using php-cli with another configuration.
e.g. for the apache module
/etc/php/php-apache/php.ini
/etc/php/php-apache/php.d/pdo_mysql.ini
for the commandline php
/etc/php/php-cli/php.ini
In this case you have to repeat your module configuration for the commandline client
/etc/php/php-cli/php.d/pdo_mysql.ini
The commandline php also has a phpinfo functionality, which you can use to verify your cli installation:
~ # php -i | grep "pdo"