Installing MySQL Native Driver - php

I'm trying to get mysqli_result::fetch_all() to work but I'm out of my depth and butting my head against a wall. This is all being done on remote server and I'm using PuTTY to connect. The internet is telling me to install MySQL Native Driver using the following lines of code:
php ./configure --with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
What I'm getting back is "Could not open input file: ./configure". What do I do now?

You can install the mysqlnd extension over the package manager. You should look at the documentation of your specific operation system.
But on APT systems you can use:
apt-get install php5-mysqlnd
under CentOS or better Red Hat package Manager:
yum install php-mysqlnd
when you are root you don't need the sudo command. When you are logged on as a normal user you have to write sudo before your command.
A good tutorial how to install the extension:
http://blog.ahughes.org/?p=602

Related

configure error: Package requirements (sqlite3 > 3.7.4) were not met

I'm trying to install php on Centos 7 following instructions from: https://www.php.net/manual/en/install.unix.nginx.php.
My nginx version: nginx/1.19.0
I downloaded php-7.4.6.tar.gz from https://www.php.net/downloads
but
at the step:
./configure --enable-fpm --with-mysqli
I got this error:
checking for sqlite3 > 3.7.4... no
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
No package 'sqlite3' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables SQLITE_CFLAGS
and SQLITE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
I do have sqlite3 up and running:
# sqlite3
SQLite version 3.7.17
So, how should I set the environment variable (in configure file?)?
Thanks!
To compile from source, dependencies need to be available as a linkable library (and sometimes headers which the new program uses for building). -devel packages install these libraries, so to build PHP from source with SQLite support, you need to install sqlite-devel.
If you have Ubuntu >= 20.04, install this package libsqlite3-dev to satisfy the dev dependency/package requirements.
sudo apt install libsqlite3-dev will work. To know which libraries to install you may find apt search sqlite3 useful.
for ubuntu21.04 I needed to use sudo apt install libsqlite3-dev
sudo apt-get install -y libbz2-dev sqlite3 libsqlite3-dev libssl-dev libcurl4-openssl-dev libjpeg-dev libonig-dev libreadline-dev libtidy-dev libxslt-dev libzip-dev
The command sudo apt-get install sqlite3 works for ubuntu.
On Ubuntu 22.04 I had the same problem after installing :-
sudo apt-get install sqlite3 libsqlite3-dev
To get round this :-
sudo find / -name sqlite3.pc
Then add the folder that contains that file to :-
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/

Installing Postgres driver in php7-fpm Docker container

I've installed PHP:latest Docker container using the docker-compose command. It installed php-7.1.6-fpm in my Docker. When I tried to install php7-pgsql extension it failed to find that package, instead found pdo and pdo_pgsql packages. That will not satisfy my need. When I search for the available packages in the installed PHP container, I could not find any related pgsql packages for php7, instead, I saw php5-pgsql package, that will not work with php7-fpm.
Finally, I installed php-5.6-fpm container after removing the old one targeting to use php5-pgsql package. But now I disappointed again that I could not find php5-pgsql package in the newly installed container.
I know I'll be missing some important points. Whether Alpine Linux does not have php-pgsql extension. What are the possible ways to include this extension in my PHP container. I've also included Nginx and Postgres in my docker-compose.yml
I've only 3-day theory knowledge in Docker and first-day practical experience.
Thanks for reading.
I ran into the same issue when I was settings up a new project to use pgsql.
I am using php7, so you should be able to use it as well. On your Dockerfile ensure you're covering the following steps.
Ensure you have the dependencies installed:
RUN apt-get update && apt-get install -y libpq-dev
Configure the extension:
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
Install the extension:
RUN docker-php-ext-install pdo pdo_pgsql
This is an old question i know, but i ran into this today and believe the above solution has changed with php:7.4-fpm-alpine
So where it used to be:
RUN apt-get update && apt-get install -y libpq-dev
Should now be:
RUN apt-get update && apt-get install -y postgresql-dev
Hopefully this helps anyone that runs into the same issue.

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)

Error compiling mysqlnd_qc with apc

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.

error: cannot find php_pdo_driver.h while installing pdo_mysql

I want to load pdo_mysql extension to php inorder to install Megento in my VPS (runs CentOS).
Then I searched the PHP.ini file for something like "extension=pdo.so ". But I was unable to find such a line in my ini file. Then I tried to install pdo_mysql using "pecl install" . But the installation exits by displaying this error ,
checking for PDO includes... checking for PDO includes...
configure: error: Cannot find php_pdo_driver.h.
ERROR: `/root/tmp/pear/PDO_MYSQL/configure' failed
My phpinfo . Please help me to solve this problem.
You have to build PHP with PDO support.
http://pecl.php.net/package/PDO
"Do not use this, as PDO has been moved into core (the php source) so this pecl extension is dead."
Current PHP comes with PDO extension in its core, but you still need to add support for each database engine you need to connect to.
I had this problem with symfony2 complaning about the lack of pdo_pgsql driver. I looked everywhere on the web and basically concluded that I had to do (in ubuntu)
sudo apt-get install libpq-dev
sudo pecl install pdo_pgsql
But that will fail, basically for the same reason as it failed you (in my case it said configure: error: Cannot find php_pdo_driver.h.)
then, by accident, I found out that you need to install the packages as
sudo apt-get install php5-pgsql
sudo apt-get install php5-mysql
and that will add pdo_pgsql and pdo_mysql to your PDO driver.
In centOS, it should be
sudo yum install php-pgsql
sudo yum install php-mysql

Categories