Error compiling mysqlnd_qc with apc - php

Running the command pecl install mysqlnd_qc to install the caching with APC enabled I receive the following error:
configure: error: APC is onlysupported if both APC and MySQL Query Cache are compiled statically
ERROR: `/var/tmp/mysqlnd_qc/configure --enable-mysqlnd-qc-apc=yes --enable-qc-memcache=no --enable-qc-sqlite=no' failed
Without the APC enabled it compiles fine...
PHP version: 5.3.17
Running on Amazon RDS.
What does it mean to compile APC and MySQL Query Cache statically?
How is it done?
Update 1:
As I haven't managed to compile mysqlnd_qc with APC, I tried compiling it with memcached.
Here was an interesting issue. The ./configure command didn't recognize the the option the pecl gave for memcache. I found out that the option was entered incorrectly...
So I killed the pecl installation when it was asking for the options and ran the following commands myself:
sudo ./configure --enable-mysqlnd-qc-memcache --with-libmemcached-dir=/usr/
sudo make
sudo make install
So with memcached it now works.
If running on Fedora (I guess also RedHat and CentOS) there is available a rpm:
sudo yum install php-pecl-mysqlnd-qc
Update 2:
I managed to compile with APC, see the detailed answer below.

Well found the solution:
Here is what I did:
Get php 5.3.17:
wget https://github.com/php/php-src/archive/PHP-5.3.17.zip
unzip PHP-5.3.17.zip
Get mysqlnd_qc:
wget http://pecl.php.net/get/mysqlnd_qc-1.1.1.tgz
tar -zxvf http://pecl.php.net/get/mysqlnd_qc-1.1.1.tgz
mkdir -p php-src-PHP-5.3.17/ext/mysqlnd_qc
cp -R mysqlnd_qc-1.1.1/* php-src-PHP-5.3.17/ext/mysqlnd_qc
Get APC:
wget http://pecl.php.net/get/APC-3.1.13.tgz
tar -xzvf APC-3.1.13.tgz
mkdir -p php-src-PHP-5.3.17/ext/apc
cp -R APC-3.1.13/* php-src-PHP-5.3.17/ext/apc/
Compile: (maybe don't need all on other systems)
sudo yum install bison
sudo yum install libxml2 libxml2-devel
sudo yum install autoconf213
sudo yum install httpd-devel
sudo yum install bzip2 lbzip2 bzip2-libs bzip2-devel
export PHP_AUTOCONF=/usr/bin/autoconf-2.13
./buildconf --force
make clean && make
(for me the linkage failed and had to add '-lpthread' to linkage)
make test
sudo make install
I used also the following 2 commands but I don't remember for what and when...
phpize
aclocal
Run the same ./configure as in phpinfo and add these options:
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-qc --enable-mysqlnd-qc-apc --enable-mysqlnd --enable-apc --enable-static=apc
All the --with must be replaced.

It looks like you have to compile from source giving the right .configure options.
pecl install just gives you a .so, which is a dynamic module extension, you can add via php.ini
So if you really need mysqlnd_qc with apc (do you?), you have to get the php src, and compile it
with the needed modules.
If you don´t need it, just say no or hit return when pecl install mysqlnd_qc ask you about it.

Related

php's ssh2 extension installation on RHEL8 with php 7.4

I have installed php7.4 via RHEL8's Default Stream using dnf.
I want to install the php's ssh2 module.
How do I install Pyrus (Pear2 Package Manager) on RHEL8 with php7.4?
When I tried: php pyrus.phar
I got the error message in command prompt: Could not open input file: pyrus.phar
I used:
updatedb
locate pyrus
Got nothing
So, what is the issue here?
Best Regards
Thayalan
I wanted to install php's ssh2 extension via Pyrus but I was having trouble with Pyrus. Therefore, I tried it without Pyrus. I preferred yum or dnf installation throughout. But, it was not possible for some. The following are how I have installed ssh2:
yum install make gcc php-devel php-pear
libssh2 package (ssh2 package needs it) installed by downloading the file https://libssh2.org/download/libssh2-1.10.0.tar.gz into an appropriate folder.
Then, I entered the following commands:
tar -zxvf libssh2-1.10.0.tar.gz
cd libssh2-1.10.0
./configure
make
make install
ssh2 package installed by downloading the file https://pecl.php.net/get/ssh2-1.3.1.tgz into an appropriate folder.
Then, I entered the following commands:
tar -zxvf ssh2-1.3.1.tgz
cd ssh2-1.3.1
phpize
./configure
make
make test
make install
Then I entered the following entry into /etc/php.ini: extension=ssh2.so
After that, I restarted php by: systemctl restart php-fpm
And now, php's ssh2 extension has been successfully installed.

PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so'

I am trying to update laravel using composer update on ubuntu 06.04 but everytime i run composer update this warning always comes up.
PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Does anyone knows how to deal it?
I am using php7.2
I faced similar issue when I installed Php7.2 on Ubuntu 18. Though I had installed mcrypt using PECL still I get the error mentioned in the question.
I did following to fix it
sudo apt-get install php-pear php7.2-dev
then uninstalled
pecl uninstall mcrypt
Now reinstall mcrypt
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
When you are shown the prompt
libmcrypt prefix? [autodetect] :
Press [Enter] to autodetect.
After success installing mcrypt using pecl, you should add mcrypt.so extension to php.ini.
The output will look like this:
...
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so' ----> this is our path to mcrypt extension lib
install ok: channel://pecl.php.net/mcrypt-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
Now restart Apache
sudo service apache2 restart
Grab installing path and add to cli and apache2 php.ini configuration.
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"
First, open up a terminal window and install the necessary dependencies with the commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
Once the dependencies have been installed, you can install mcrypt with the command:
sudo pecl install mcrypt-1.0.1
And there you go. Mcrypt is now installed. Go back to the process of installing whatever server software that depends upon this extension and you should be good to go.
For (>= PHP 7.3) you can use the following command:
sudo pecl install mcrypt-1.0.2
I faced this problem when I upgraded my PHP to 7.3
I found mcrypt.so was still present in /etc/php/7.3 that should not be as it is deprecated in php 7.3 so just deleting mcrypt.so from /etc/php/7.3 solved issue.
I used following commands:
cd /etc/php/7.3
sudo rm -rf mcrypt.so
sudo service apache2 restart
İts is worked for me.
export LC_ALL="C"
export LANG="C
sudo pecl install mcrypt-1.0.1
Also, if you're using php 7.2 & are getting this error and you know do not want/need mcrypt, but do not know how to exclude it.... You need edit your php.ini file and either comment this out by using a semi-colon in front of it:
; extension=mcrypt.so
or just delete that line entirely.

How to use Memcached with PHP7?

I was trying to find any information about using Memcached with PHP7, but I failed. The only valuable information is short Readme.md of php-memcached repo.
Unfortunately, its travis build failed as well as 30/126 tests on my machine.
However make install command was successful and created memcached.so file. Does it mean I can use this extension in production or it still has bugs and is not recommended for using?
I will very appreciate any advice or working solution.
You need to use the php7 branch; see here, Travis is passing.
This should be the complete set of steps to install the memcached extension on a Debian/Ubuntu OS:
sudo apt-get update
sudo apt-get install -y libmemcached-dev libmemcached11 git build-essential
git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
git pull
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make
sudo make install
You may need to change some of the paths if you have them installed at different locations.
To install memcached on the latest ubuntu for the latest php use:
sudo apt-get install php-memcached
For Debian 8 users, you can use:
sudo apt-get install php7.0-memcached
I came to this question via an issue with getting artisan to work in the Laravel Lumen framework.
I'm using PHP 7. PHP 7.0.15-0ubuntu0.16.04.4 to be precise.
I found the only solution was to install what appears to be the PHP 5 version* with memcached†:
sudo apt install memcached php-memcached
*
php-memcached/xenial,now 2.2.0-51-ge573a6e+2.2.0-2build2 amd64 [installed]
memcached extension module for PHP5, uses libmemcached
† If you find you then get the error: [RuntimeException] Could not establish Memcached connection., you need to install the memcached extension as the above sudo apt install memcached (if you're on 16.04+, use apt-get if < 16.04)

How can I install mcrypt under PHP7? Laravel needs it

Since Laravel4 requires mcrypt extension, and PHP7 doesn't seem to have mcrypt extension, is there any workaround for this to work?
Had the same issue - PHP7 missing mcrypt.
This worked for me. When asked, keep local PHP configuration files.
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
Restart FPM (or Apache or NGINX etc.) after installation.
I'm on Mac and with laravel valet I've solved with this:
brew install php70-mcrypt
Even if you enable mcrypt in php.ini, this issue may occur.
Try the following steps.
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
I am working in ubuntu 16.04 and the following commands also helped me.
whereis php -shows the files with this name
php -v -shows the php version
which php -shows current php version that is running on the server
On ubuntu: According to launchpad.net the package for mcrypt is called php7.0-mcrypt.
sudo apt-get install php7.0-mcrypt to install
Open terminal with Ctrl + Alt + T and run following commands for PHP7.0 on Ubuntu 16.4
sudo apt-get install mcrypt php7.0-mcrypt
sudo service apache2 restart
php7 have mcrypt, you can enable it in php.ini and then everything will work fine.
do like this:
wget http://jp2.php.net/distributions/php-7.0.3.tar.gz
tar zxf php-7.0.3.tar.gz
cd php-7.0.3/ext/mcrypt
/php7-path/bin/phpize (when error such as configure: error: mcrypt.h not found. Please reinstall libmcrypt run apt-get install libmcrypt-dev)
./configure --with-php-config=/php7-path/bin/php-config
(sudo) make && make install .this will install the mcrypt.so in php-7.0.3/ext/mcrypt/modules
cp to the /usr/lib/php/20151012/ what is the shared extensions dir
create a mcrypt.ini in /etc/php/mods-available/ write as extension=mcrypt.so
create link to this such as sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.ini in /etc/php/7.0/fpm/conf.d
create link to this such as sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.ini in /etc/php/7.0/cli/conf.d
sudo service nginx restart
sudo service php7.0-fpm restart
yes it is.
I use, Dotdeb, an extra repository providing up-to-date all kinds of cool toys for your Debian servers like Nginx, PHP, MySQL, Redis etc.
Update your sources.list
deb http://packages.dotdeb.org {distribution} all
deb-src http://packages.dotdeb.org {distribution} all
GnuPG keys
wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
Update apt & build something amazing.
sudo apt-get update
PHP7 contains mcrypt extension internally (source-path/ext/mcrypt/).
But it depends on Libmcrypt soft.
Step 1.
Download libmcrypt-x.x.tar.gz from http://mcrypt.sourceforge.net/
and build it.
cd libmcrypt-x.x
./configure
make
make install
Step 2.
Rebuild PHP7 from source and add --with-mcrypt option.
./configure ... --with-mcrypt
Other way without rebuilding PHP7
cd php7-source-path/ext/mcrypt/
/php7-path/bin/phpize
./configure --with-php-config=/php7-path/bin/php-config
make && make install
echo "extension=mcrypt.so" >> /php7-path/ext/php.ini
Restart php

Install PECL SSH2 extension for PHP

I am trying to install this
http://fr2.php.net/manual/en/book.ssh2.php
on a Centos 5 (a fork of RHEL 5).
I installed libssh2 (yum install libssh2) which is located in /usr/lib, and when I install SSH2 extension (via pecl install -f ssh2) I get this message
checking for ssh2 files in default path... not found
configure: error: The required libssh2 library was not found. You can obtain that package from http://sourceforge.net/projects/libssh2/
ERROR: `/tmp/pear/download/ssh2-0.11.0/configure --with-ssh2=/usr' failed
If I set /usr/lib, I get the same message
ERROR: `/tmp/pear/download/ssh2-0.11.0/configure --with-ssh2=/usr/lib' failed
Where is the problem?
Installing libssh2 via tar.gz from http://sourceforge.net/projects/libssh2/ help a lot (--with-ssh2=/usr/local/include/).
But :
yum install libssh2-devel
...is a better idea.
$ sudo pecl channel-update pecl.php.net
$ sudo apt-get install libssh2-1-dev
$ sudo pecl install -a ssh2-0.12
$ echo 'extension=ssh2.so' | sudo tee /etc/php5/mods-available/ssh2.ini > /dev/null
$ sudo php5enmod ssh2
yum install libssh2-devel didn't work for me:
No package libssh2-devel available.
So I downloaded rpm package from rpmfind and installed with rpm -ivh
After that just added extension=ssh2.so to /etc/php.d/ssh2.ini
This is updated answer from #klay + modification from #avn from comment under working solution for PHP 7.x.
$ sudo pecl channel-update pecl.php.net
$ sudo apt-get install libssh2-1-dev
$ sudo pecl install -a ssh2-1.0
$ echo 'extension=ssh2.so' | sudo tee /etc/php/7.2/mods-available/ssh2.ini > /dev/null
$ sudo phpenmod ssh2
Regarding line:
echo 'extension=ssh2.so' | sudo tee /etc/php/7.2/mods-available/ssh2.ini > /dev/null
Make sure that path /etc/php/7.2/mods-available is valid and there is a match with your php version.
I'm running on Centos, none of these answer were the entire solution for me. I followed these instructions:
$ sudo yum install -y gcc php-devel php-pear libssh2 libssh2-devel
But php-devel would not install, complaining about conflicts. I searched yum to find what php devel packages I had available
$> yum search php|grep devel
...
php55u-devel.x86_64 : Files needed for building PHP extensions
php56u-devel.x86_64 : Files needed for building PHP extensions
php70u-devel.x86_64 : Files needed for building PHP extensions
...
So I ran
$> sudo yum install -y php56u-devel
And it installed cleanly. Then, continuing with the instructions, I ran
$ pecl install -f ssh2
And it compiled. Then I added the extension to php
$ touch /etc/php.d/ssh2.ini
$ echo extension=ssh2.so > /etc/php.d/ssh2.ini
And on my system, instead of
$ /etc/init.d/httpd restart
I had to do
$ sudo /bin/systemctl restart php-fpm.service
So that was all the steps to install. And finally to confirm:
$> php -m|grep ssh2
ssh2
I had this problem:
I'm on a Pair.com "Advanced" hosted account, so I'm a little limited on what I'm allowed to do. I don't think I can yum nor aptitude nor any of the other pre-compiled packages.
I've downloaded and compiled libssh2. During the pecl process, it asks where the library is located. It's in "~/usr/local/lib" and I've tried several variations, including fully qualified. But I kept getting the same error.
The error message doesn't spell out precisely which file it's looking for. libssh2.so is in that directory. I know the output is supposed to be ssh2.so. I wondered if there is supposed to be an ss2.something, or libssh.nothing?
I fixed it thus. In my case, after compiling libssh2 I downloaded the PEAR tarball. The trick was:
./configure --with-ssh2=<libssh2 location> --prefix=<libssh2 location>
Another trick is that, since Pair.com is running FreeBSD, I have to do a "cd ." after the ./configure command. Otherwise, make produces a "Permission denied" error. Apparently, this is necessary on all *nix BSD flavors.
The error:
checking for ssh2 files in default path... not found
configure: error: The required libssh2 library was not found.
...can be seen in the source code.
The logic in the code reveals that it will throw this error if it cannot find /include/libssh2.h in either /usr/local, /usr or in the path supplied by the optional --with-ssh2=[DIR] directive. In other words, without customising the directive, it needs to find one of the following:
/usr/local/include/libssh2.h
/usr/include/libssh2.h
If it passes this check, it then assumes it can find the libssh2 lib at /usr/local/lib or /usr/lib.
Hopefully the info above is enough to help someone debug their issue. My own case is fairly specific and unusual (macOS with Homebrew in a custom install path), but in case it helps anyone else, here's my horrifically hacky workaround. Works perfectly lol
In a nutshell I'm creating two temporary symlinks so that pecl can find ssh2 where it expects.
# First check that neither /usr/local/include nor /usr/local/lib exists
sudo ln -s /usr/local/CustomInstallPath/Homebrew/Cellar/libssh2/1.9.0_1/include /usr/local/include
sudo ln -s /usr/local/CustomInstallPath/Homebrew/Cellar/libssh2/1.9.0_1/lib /usr/local/lib
pecl install -a ssh2-1.3.1
sudo rm -rf /usr/local/include
sudo rm -rf /usr/local/lib

Categories