compile php 5.4.5 with mongo driver - php

Now I have installed php 5.3.* via apt-get on my Ubuntu PC, but I need to work with 5.4.5 for some issue.
According to this reason, I try to compile and install new version php 5.4.5 with mongo driver into separete place:
I did next steps:
sudo su
cd /opt
tar xfz php-5.4.5.tar.gz
cd php-5.4.5
./configure --prefix=/opt/php545 --enable-phar --with-config-file-path=/opt/php545/php.ini
make & make install
after above commands I had got working php:
/opt/php545/bin/php -v
PHP 5.4.5 (cli) (built: Aug 15 2012 09:04:56)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
after it I did next:
/opt/php545/bin/pecl install mongo
and it return me
Build process completed successfully
Installing '/opt/php545/lib/php/extensions/no-debug-non-zts-20100525/mongo.so'
install ok: channel://pecl.php.net/mongo-1.2.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini
I added into /opt/php545/php.ini next line
extension=/opt/php545/lib/php/extensions/no-debug-non-zts-20100525/mongo.so
but mongo not loaded as module:
/opt/php545/bin/php -m | grep mongo
!!!Nothing here!!!
What did I do wrong?
PS:
/opt/php545/bin/php -i | grep php.ini
return
Configuration File (php.ini) Path => /opt/php545/php.ini
(php.ini seting up properly)

php config doesn't accept absolute path for extensions line, please use extension_dir.

Not load the extension from php.ini, load from ini file parsed as follows:
nano /usr/local/php-5.x.xx/php.d/mongo.ini
x.xx is you PHP version.
Then load the extension:
;Enable mongo extension module
extension=mongo.so
mongo.default_port=27017
save with ctrl + o and close white crtl + x
Then restart the services:
service php-fpm restart
service httpd restart
// php-fpm If it has
So you should already loaded.

Related

PHP 7.4 and Ubuntu 18 - PHP Startup: Unable to load dynamic library 'curl.so'

I'm using the ondrej ppa for PHP and am running Ubuntu 18. Running php -v gives me the following output:
PHP Warning: PHP Startup: Unable to load dynamic library 'curl.so' (tried: /usr/lib/php/20190902/curl.so (/usr/lib/php/20190902/curl.so: symbol curl_mime_addpart version CURL_OPENSSL_4 not defined in file libcurl.so.4 with link time reference), /usr/lib/php/20190902/curl.so.so (/usr/lib/php/20190902/curl.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.2 (cli) (built: Jan 23 2020 11:21:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
Basically, I can't run any composer commands because a lot of libraries depend on curl, and apparently it isn't being found. I've done the following:
Tried to update everything (sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get install php7.4-curl). This doesn't fix the issue.
Restarted apache despite this being the cli version.
Double checked where it's trying to find the library. What's weird is that /usr/lib/php/20190902/curl.so is a valid path and the file is definitely there.
Running php --ini also shows that the curl extension is loaded:
Configuration File (php.ini) Path: /etc/php/7.4/cli
Loaded Configuration File: /etc/php/7.4/cli/php.ini
Scan for additional .ini files in: /etc/php/7.4/cli/conf.d
Additional .ini files parsed: /etc/php/7.4/cli/conf.d/10-mysqlnd.ini,
...more ini files...
/etc/php/7.4/cli/conf.d/20-curl.ini,
...more ini files...
I'm unsure how to fix this as the file it supposedly can not find is exactly where it says it looked, and everything is up to date.
For anyone with this issue, the answer is here.
Basically, the libcurl that was installed on my Ubuntu machine clashed with the official one that Ubuntu has? Weirdly it was only affecting php7.3 and 7.4 and not 7.2. Anyways, I renamed the libcurl module like so:
mv /usr/local/lib/libcurl.so.4.4.0 /usr/local/lib/libcurl.so.4.4.0.backup
And by running php -m, I could verify that the cURL module was now enabled.
I found that if I did:
apt search | more
(the pipe is for long lists)
that I could find the php package name that I needed.
For example:
apt search curl
told me that the name of the package for my php version is 'php7.2-curl'
So, all I had to do was sudo apt install php7.2 curl.
I repeated this (some names require a little googling, and/or some apt search creativity.
I solved it by doing this:
Uninstall curl:
apt remove php7.4-curl
New install:
apt install php7.4-curl
I have now all right.
After trying to run composer update things were failing because the deps where from php -v 7 while I was using 8.
composer install --ignore-platform-reqs
worked for me

How to enable PHP Intl extension on macOS Mojave?

I'm trying to install Magento (2.3.0) on macOS Mojave. Magento shows PHP Extension intl. is missing.
I tried the below to resolve:
Made a copy of php.ini using cp /etc/php.ini.default php.ini
Removed ";" before extension=php_intl.dll
Restart Apache sudo apachectl restart
But the above did not resolve.
On checking php -v, i'm seeing the below error:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll,
0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-
non-zts-20160303/php_intl.dll in Unknown on line 0
PHP 7.1.19 (cli) (built: Aug 17 2018 20:10:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
There are only 2 files under /usr/lib/php/extensions/no-debug-non-zts-20160303 namely opache.so and xdebug.so
How can i install or enable "PHP Extension intl" on my macOS Mojave?
Here's a solution that worked for me:
Find all PHP versions installed brew list | grep php
Remove all versions of PHP brew remove --ignore-dependencies --force php70 php71 php72 (based on what you see above)
Install PHP brew install php72 (i chose 7.2, 7.3 is not supported yet by several vendors)
Run the command which php should show you the path to the installed PHP. Copy the path.
Update your bash_profile vi ~/.bash_profile and add this line to the file:
export PATH=/usr/local/php5/bin:$PATH
Save and run this source ~/.bash_profile
Check if PHP Intl Extension is installed using php -m | grep intl. If the installation went well, we will see intl listed. If not the extension is not installed.
I think from PHP 7 (not sure of the version), the extensions are available by default and we need not enable them in php.ini file explicitly.
If you installed Homebrew's php, linking it to a directory in your path will fix the issue.
brew link --force php#7.3
I had the same issue and that fixed it.
Here is a link where I got a detailed answer from
Got help from the link and able to compile https://donatstudios.com/Install-PHP-Mcrypt-Extension-in-OS-X
Next we will download the PHP source. Verify the exact version of PHP you are running. This can be retrieved as follows. The version is highlighted.
$ php --version
PHP 7.1.19 (cli) (built: Aug 17 2018 18:03:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Now we move into a working directory and download the source making sure to update the following for the version from above.
$ cd /tmp
$ curl -L http://php.net/get/php-{{php-version}}.tar.bz2/from/this/mirror > php.tar.bz2
$ open php.tar.bz2
Now we will compile and test the extension.
$ cd php-{{php-version}}/ext/{{extension}}
$ phpize
$ ./configure
$ make
$ make test
$ sudo make install
If all that goes well finally we'll need to add the following to our php.ini - I usually add at it at the end of the file.
extension = {{extension}}
.so
You can verify your installation with the following:
$ php --info | grep {{extension}}\\.
Lastly, depending on your setup now you may want to restart apache.
$ sudo apachectl restart

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

I have overlook at this issue Linux - PHP 7.0 and MSSQL (Microsoft SQL)
and I am sure did exactly what MS told me to do in this page
installing-the-drivers-on-red-hat-7
howevey, i stiil got the error when type 'php -v':
PHP Warning: PHP Startup: Unable to load dynamic library
'pdo_sqlsrv.so' (tried: /usr/lib64/php/modules/pdo_sqlsrv.so
(/usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol:
php_pdo_register_driver), /usr/lib64/php/modules/pdo_sqlsrv.so.so
(/usr/lib64/php/modules/pdo_sqlsrv.so.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0
PHP 7.2.10
(cli) (built: Sep 15 2018 07:10:58) ( NTS ) Copyright (c) 1997-2018
The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend
Technologies
with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend
Technologies
I never modify the php.ini,
[user#tssvr php.d]$ pwd
/etc/php.d
[user#tssvr php.d]$ ls
20-sqlsrv.ini ctype.ini fileinfo.ini gmp.ini mbstring.ini pdo.ini shmop.ini tokenizer.ini xmlwriter.ini
30-pdo_sqlsrv.ini curl.ini ftp.ini iconv.ini mysqli.ini pdo_mysql.ini simplexml.ini xml.ini xsl.ini
bz2.ini dom.ini gd.ini intl.ini opcache-default.blacklist pdo_sqlite.ini sockets.ini xmlreader.ini zip.ini
calendar.ini exif.ini gettext.ini json.ini opcache.ini phar.ini sqlite3.ini xml_wddx.ini
[user#tssvr php.d]$ cat 20-sqlsrv.ini
extension=sqlsrv.so
[user#tssvr php.d]$ cat 30-pdo_sqlsrv.ini
extension=pdo_sqlsrv.so
it seems that the sqlsrv.so is good, but the pho_sqlsrv.so just can't work correctly,,although i notice that double 'so' appear: 'pdo_sqlsrv.so.so' ,
can any guys can help me through this ,many thanks.
Type in terminal linux centos 7 :
php --ini
find /etc/php.d/20-pdo.ini
Edit the file and append extension=sqlsrv.so extension=pdo_sqlsrv.so
note: comment extension extension=sqlsrv.so , extension=pdo_sqlsrv.so in /etc/php.ini
reboot system
php -m - you see loaded module
The proper order to load the modules is:
extension=pdo.so
extension=pdo_sqlsrv.so
extension=sqlsrv.so
One can either put these into one .ini file - or use numbered .ini files.
Loading them in alphabetical order (which is the default) won't work.
I ran into the same issue with Ubuntu 18.04 and 20.xx. I finally got it to work on Ubuntu 18.04 and pretty sure this will work on 20.xx as well.
This is for PHP 7.1 so if you are not using 7.4 or 8.0 you will have to specify the version in pecl.
pecl install sqlsrv-5.7.0preview
pecl install pdo_sqlsrv-5.7.0preview
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.1/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.1/mods-available/pdo_sqlsrv.ini
phpenmod -v 7.1 sqlsrv pdo_sqlsrv
service apache2 restart
The trick that got everything working was the printf and phpenmod command. You still need to add the extension to your php.ini file as well. Not sure if the order really matters but the driver does not appear to get installed properly using the pecl installer.
After restarting apache I can now see pdo_sqlsrv listed in php.ini and my php application can connect to the local Microsoft SQL server.
BTW, I got this working on WSL2 for Windows.
This is the way I solved this on CentOS 7.
First I've installed pdo_dblib extension
[root#localhost html]# yum list *dblib*
Complementos cargados:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.airenetworks.es
* centos-sclo-rh: mirror.airenetworks.es
* epel: ftp.uma.es
* extras: mirror.airenetworks.es
* remi-safe: mir01.syntis.net
* updates: mirror.tedra.es
Paquetes instalados
php73-php-pdo-dblib.x86_64
Paquetes disponibles
php70-php-pdo-dblib.x86_64
php71-php-pdo-dblib.x86_64
php72-php-pdo-dblib.x86_64
php74-pdo-dblib.x86_64
php74-php-pdo-dblib.x86_64
php80-php-pdo-dblib.x86_64
php81-php-pdo-dblib.x86_64
[root#localhost html]# yum install php73-php-pdo-dblib.x86_64
I have php 7.3 installed so I've chosen matching version extension. After installation, tried a simple test script I created to test connectivity but still got error.
Used locate command to find out if pdo_dblib.so library was correctly installed and found it under /opt/remi/php73/root/usr/lib64/php/modules path which looked a bit strange
With the command locate php.ini I discovered that there were 2 php.ini files on the machine. With the command php -i and by creating a simple file to test it from the web browser:
<?php
phpinfo()
I checked what php.ini file was in use both from Cli and from Apache. It was /etc/php.ini.
With php -m I saw PDO was loading correctly, so I searched the location of pdo.so library. Copied pdo_dblib.so library on previous search location. Searched for pdo_dblib.ini file and copied it under the location of pdo.ini file (which full name was 20-pdo.ini).
After all of these changes, restarted Apache systemctl restart httpd and checked again that pdo_dblib was loading both from cli and web whith php -i and the phpinfo() file.

how to add php5.6 mbstring extension in centos 6.8

My terminal shows php version as
[root#localhost modules]# php -v
PHP 5.6.25 (cli) (built: Oct 21 2016 17:57:17)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
and when I check for mbstring extension for php with php -m command I get
but when i check with yum list installed php* i get this
php-mbstring.x86_64 5.6.30-1.el6.remi #remi-php56
when I check with phpinfo() I get result as
1) i get related result in Additional ini file parsed section as
I try with new installation of php56w-mbstring also then also same problem.
Diagnostic
1/ find which php command is used:
which php
2/ find which package provides this command
rpm --query --file $(which php)
If this fails, this probably means you are using a manually installed PHP version, built from sources, usually in /usr/local.
Installation
As, in your case php is provided by rh-php56-php-cli, you need to install needed extensions, from the same repository (centos-sclo) and in the same namespace (rh-php56):
yum install rh-php56-php-mbstring
Its small mistake here...
In my setup there are two version for php
1)php with apahce and
2)php cli
[root#localhost modules]# which php
/opt/rh/rh-php56/root/usr/bin/php
[root#localhost modules]# find / -name php.ini
/opt/rh/rh-php56/register.content/etc/opt/rh/rh-php56/php.ini
/etc/opt/rh/rh-php56/php.ini
/etc/php.ini
here i select /etc/opt/rh/rh-php56/php.ini and after this check for mbstring in terminal by i fine mbstring.so file
as
[root#localhost modules]# find / -name mbstring.so
/usr/lib64/php/modules/mbstring.so
/usr/lib64/php-zts/modules/mbstring.so
with gedit /etc/opt/rh/rh-php56/php.ini i added that extension and related path with it as
extension=/usr/lib64/php/modules/mbstring.so
after that check with
php -m
now i get mbstring with this command.

Mcrypt PHP extension required in Mac OS X El Capitan

Getting error Mcrypt PHP extension required. with Laravel in Mac OS X El Capitan.
Already installed the mcrypt using brew.
brew install mcrypt
brew install homebrew/php/php55-mcrypt
sudo apachectl restart
which php
/usr/local/bin/php
php --version
PHP 5.5.30 (cli) (built: Oct 3 2015 23:48:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/5.5
Loaded Configuration File: /usr/local/etc/php/5.5/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.5/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini
Yu most rename original libphp:
sudo mv /usr/libexec/apache2/libphp5.so /usr/libexec/apache2/libphp5.so.origin
and link the new homebrew php lib installed
sudo ln -s /usr/local/Cellar/php55/5.5.29/libexec/apache2/libphp5.so /usr/libexec/apache2/libphp5.so
and then restart apachectl
sudo apachectl restart
that works for me
I think this is what you are looking for:
http://phpbrew.github.io/phpbrew/
It lets you build any number of php versions, switch between them and set defaults. Add and remove extensions and more.
Good luck!

Categories