Difficulty loading pecl stats module w/ php 5.6 fpm - php

Experiencing difficulty getting PECL stats module loaded in Vagrant dev environment.
Dev Env: Ubuntu 14.04, Nginx 1.4.6, PHP 5.6.24.
Production copy running successfully.
Prod Env: Ubuntu 14.04, Nginx 1.4.6, PHP 5.5.9.
We need to migrate the application to a new server. New server node is the same env setup as the Dev/Vagrant box listed above. Only environment change between current node & new node is PHP version.
PHP5.6-FPM service is running as expected in Vagrant. The application works as expected, until attempting to run any php stats methods, for example stats_standard_deviation().
PECL stats 1.0.5 has been installed & verified.
Confirmed the correct php.ini via phpinfo() prior to adding stats extension.
Confirmed the stats.so extension exists.
I've restarted services, restarted the Vagrant box. I've confirmed stats module is loaded in production via phpinfo() & am using the same method to confirm it is NOT loading in dev. Just can't seem the get the extension loaded.
Any help is greatly appreciated !

This was a two-part issue.
An incorrect PECL dependency was installed. php5-dev was the pkg installed, which directed the PECL installer to use PHP API 20121212
PECL config looks for standard PHP 5 install by default, v. 5.5.9. That needed to reflect the correct settings. Possibly using either pkg-config or autoconfig packages would rectify this hiccup by assisting PECL in the PHP detection process.
Solution
Clean out the PECL stats module, as well as the php dev package.
Set PECL config.
Then re-install correct versions.
# Clean out previous ver.
$ pecl uninstall stats-1.0.5
$ apt-get remove --purge php5-dev
# Install correct PECL dependency
$ apt-get install php5.6-dev
# Set PECL config to correct PHP install
$ pecl config-set php_bin /usr/bin/php5.6
$ pecl config-set php_ini /etc/php/5.6/fpm
# Re-install PECL package & restart PHP-FPM service
$ pecl install stats-1.0.5
$ service php5.6-fpm restart

Related

Add SQLSRV extension on multiple PHP versions on Ubuntu/NGINX

I had a server set up with the following installed and running:
Ubuntu 20.04
NGINX 1.17.10
PHP 7.4.5
The PHP installation does have the PDO SQLSRV driver installed and working properly.
I needed to add PHP 5.6 to the same server for an older web site. I was able to successfully install PHP 5.6. but I can't seem to get the SQLSRV driver part to install properly.
I had previously installed the mssql tools on the server when setting up PHP 7.4:
apt-get install msodbcsql17 -y
apt-get install mssql-tools
apt install unixodbc-dev
pecl install sqlsrv
pecl install pdo_sqlsrv
In trying to set it up for 5.6, I did follow the steps for the original install. I ran the following commands:
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/5.6/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/5.6/mods-available/pdo_sqlsrv.ini
phpenmod -v 5.6 sqlsrv pdo_sqlsrv
pecl config-set php_ini /etc/php/5.6/fpm/php.ini
ls /etc/php/5.6/fpm/conf.d/*sqlsrv.ini
All commands ran successfully. I then added the following lines to the relevant php.ini file /etc/php/5.6/fpm/php.ini
extension=sqlsrv.so
extension=pdo_sqlsrv.so
I reloaded and restarted php5.6-fpm and then restarted NGINX. PHP 5.6 is successfully installed and I can see the info by running phpinfo(). I got no errors during installation. However, under PDO, PDO Drivers is showing no value. I also confirmed that sqlsrv_connect is not recognized.
I know it would be ideal not to have multiple versions of PHP or to have installed them at separate times, but I didn't have a choice on this project. Do I need to install a separate version of sqlsrv and pdo_sqlsrv on the box, or am I just missing something in the installation?

Could not find driver ( PHP and Firebird )

I have a web-based PHP script named portail, so I want to make it functional on Ubuntu.
I installed Xampp 5.6 , Firebird 2.5 under Ubuntu, then I uncommented the library:
"extension=php_pdo_firebird.dll"
and I made the specific configuration for php5 and firebird
(https://mapopa.blogspot.com/2009/04/php5-and-firebird-pdo-on-ubuntu-hardy.html),
but he always shows me the following message
could not find driver localhost/portail
Screenshot:
You should install the required php extension if not already installed by default installation process. Php extensions are binaries which help php do extra things which can not without them. For example there is another well-known php extension called X-Debug which helps php developers debug their code.
First of all check that you have this php_pdo_firebird extension installed (or not), using Ubuntu CLI (Command-Line Interface):
installed system-wide by default:
php -m | grep -i pdo-firebird
installed using your package manager:
dpkg --get-selections | grep -i php-pdo-firebird
If none of the above returned a result, then you do not have that extension installed. you should install it using your preferred package manager:
sudo apt-get update -y
sudo apt-get install -y php-pdo-firebird
Try this
php -v
apt-get install -y php<your php version>-interbase

An "issue" after ppa:ondrej/php5 deprecation

Today I was upgrading PHP 5.5 on my LEMP stack to version 5.5.35. After upgrading I received an on-screen message that the repo ppa:ondrej/php5 is deprecated and if I want to continue receiving php updates I should move onto ppa:ondrej/php which now includes PHP 5.5, PHP 5.6 and PHP 7.0 in one place. Previously these versions were in different repos.
I followed Ondřej's advice and I run:
sudo add-apt-repository ppa:ondrej/php
And then:
sudo apt-get update
sudo apt-get upgrade --show-upgraded
All went fine, except that two packages were held back: php-pear and pkg-php-tools. That of course happens from time to time when package dependencies change so I run:
sudo apt-get install php-pear pkg-php-tools
Then, I got a message that additionaly the following packages will be installed:
php-cli php-common php-xml php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline php7.0-xml
Immediately I felt that something is wrong here. Why the hell I need PHP 7.0 packages when I'm running PHP 5.5? However I went with option YES and apparently everything went fine. The server is running, no errors or confilcts that I'm aware of. Then I was curious and I checked what version of PHP am I running?
php -v
The output was:
PHP 7.0.6-1+donate.sury.org~trusty...
What the hell happened here? How did I ended up installing PHP 7.0 and why the server/site isn't crashing? Since I use nginx with php-fpm, by examining the nginx.conf I can clearly see that nginx is pointing to php5-fpm.sock so I definitely run php5-fpm here. Plus the site is up, and there are no PHP errors in the log.
I also went and I've uploaded a phpinfo file. The file shows I'm using PHP 5.5.35. So there are two conflicting messages where command via ssh shows that the PHP version is 7.0.6, while the phpinfo file shows that the server is using PHP 5.5.35.
So I run:
sudo apt-get remove php7.0-common
All previously added php7.0 packages were removed and also those two that were initially being held back.
Now, after checking the PHP version via SSH it showed correctly 5.5.35. While all this was happening the server had no trouble whatsoever. The status at this moment is that I don't have php-pear and pkg-php-tools packages, but if I try to install them all those php7.0 packages will have to be installed too.
I've also examined /etc/php5 and /etc/php folders. In this second folder there is 7.0 folder where cli and mods-available folders with mods inside reside.
Can someone explain to me what is happening here and what should I do? Are php5 and php7.0 simultaneously running on the server? Do I need those two packages that were held back in LEMP + Wordpress stack?
php-pear and pkg-php-tools must depend on PHP CLI for default PHP version and that's PHP 7.0. Installing php-cli pulls php7.0-cli that will install /usr/bin/php7.0 and registers it as alternative with highest (70) priority to provide /usr/bin/php.
Installing PHP CLI binary is mostly harmless unless you need to run PHP scripts locally using command line. I could recommend two approaches:
Rewriting those scripts to specify required version, e.g. changing php <script> to php5.6 <script>, or
Use update-alternatives to switch /usr/bin/php to your desired PHP version: a) switch to specific version update-alternatives --set php /usr/bin/php5.6 or b) update-alternatives --config php configure the version by hand
More thorough version of the migration guide is located in DEB.SURY.ORG Wiki.
To use the new PHP FPM packages, you need to install:
sudo apt-get install php5.5-fpm # for PHP 5.5
sudo apt-get install php5.6-fpm # for PHP 5.6
sudo apt-get install php7.0-fpm # for PHP 7.0
and adjust the socket accordingly, look into default FPM configuration:
sudo editor /etc/php/X.Y/fpm/pool.d/www.conf
for the socket location (it's /run/php/phpX.Y-fpm.sock by default).

Conflict when installing PHP intl extension for composer on Centos 7

I am trying to do a Magento 2 DRC installation on a remote linux server, running Centos 7, Apache 2.4.6, MariaDB and PHP v5.6.9. When I try to install Composer I get the following message:
$ cd /var/www/html/magento2 && composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested PHP extension ext-intl * is missing from your system.
I have installed ext-intl using:
yum list php*intl
and
yum install php-intl
But is still gives me the same message.
I have tried various other installations to get around the problem, to no avail. Any suggestions would be gratefully erceived as it is stalling the project.
Would it help to downgrade to PHP 5.5?
You can follow the below steps for magento2 installation on Centos 7.
http://gotechnies.com/install-magento2-centos-7/
There are few easy steps to install Magento 2(M2) on Centos Distro.
Step 1-:
First of all we need to add few EPEL repositories for the php5.6, mysql-server5.6, and phpmyadmin.
# EPEL Repository for php5.6
$ rpm -iUvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ rpm -iUvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# EPEL Repository for mysql-server5.6
$rpm -iUvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
# EPEL Repository for phpMyadmin on Centos 7
$ rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
$ yum -y update
Step 2-:
Install Require packages like apache, php5.6, mysql-server, phpmyadmin.
$ yum install-y httpd php mysql-server phpmyadmin php56w-mcrypt php56w-intl php56w-xsl git
To allow the phpmyadmin in apache 2.4 add the line
Require all granted
Readmore go to above link
Magento2 installation on RHEL/Centos 7 with Php7.
Subscribing to the IUS Community Project Repository
Since PHP 7.x is not yet packaged in official repositories for the major distributions, we’ll have to rely on a third-party source. Several repositories offer PHP 7 RPM files. We’ll use the IUS repository.
IUS offers an installation script for subscribing to their repository and importing associated GPG keys. Make sure you’re in your home directory, and retrieve the script using curl:
curl 'https://setup.ius.io/' -o setup-ius.sh
sudo bash setup-ius.sh
Install Required Packages-:
sudo yum install -y mod_php70u php70u-cli php70u-mysqlnd php70u-json php70u-gd php70u-dom php70u-simplexml php70u-mcrypt php70u-intl httpd mysql-server git
See my Article for Complete Installation magento2-php7-centos7-mysql5.7
The extension has to be installed and activated for the command line PHP, not only for the web server PHP. If you run php -i, which is the CLI equivalent of running phpinfo(), you should see a section containing info about the "intl" extension. If this is missing, you'd also see the path to the "php.ini" file that is being used - this is where you should double check whether or not the extension is activated or not.
Most of the time, it is not.

How to install V8js on PHP5.5?

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.

Categories