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

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/

Related

Unable to install PHP 7.4 Zip extension in Ubuntu 20.04

I'm getting this error when running sudo apt-get install php7.4-zip:
The following packages have unmet dependencies:
php7.4-zip : Depends: php7.4-common (= 7.4.3-4ubuntu2.12) but 7.4.10-1+ubuntu18.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
The PHP manual page for installing the Zip extension says this:
As of PHP 7.4.0, in order to use these functions you must compile PHP with zip support by using the --with-zip configure option. Previously, zip support had to be enabled by using the --enable-zip configure option. As of PHP 7.4.0, the bundled libzip is removed.
What is the straightforward method for getting the Zip extension installed on my system?
UPDATE: Additional information:
dpkg --get-selections | grep hold returns no held packages.
sudo apt autoremove removed some packages but did not change the message returned by sudo apt install php7.4-zip
try this:
sudo apt-get install -y php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath
Try apt-search for repo is exists for php7.4-zip
apt search php7.4-zip
If repos are exists
apt install php7.4-zip
Or you can use the wildcard
apt install php7.4*zip

GitLab PHP docker image - the requested PHP extension gd is missing from your system

I'm writing some unit tests for our application and we're using GitLab CI with GitLab Runner v11.11.1 and using Docker executor with image php:7.1.
When running composer install (our composer version is 1.10.17) I get the following error on a few required packages:
the requested PHP extension gd is missing from your system
I've tried a couple things like on our gitlab-ci.yml:
apt-get update -yqq
apt-get install -yqq libpng-dev
But that also produced the same error.
I also tried requiring ext-gd from the composer.json file:
composer require ext-gd
But I got this error:
The requested PHP extension ext-gd ^7.1 is missing from your system. Install or enable PHP's gd extension.
The last attempt I made was:
apt-get install php-common
phpenmod gd
But this gave me this error:
Unable to locate package php-common
Does anyone know how to simply enable the PHP extension gd so I can run my unit tests?
I fixed the errors when I added this to my gitlab-ci.yml file:
...
before_script:
- apt-get update -yqq
- apt-get install libjpeg-dev libpng-dev -yqq
- docker-php-ext-install gd
...
You need PHP GD library. For Debian and Debian based systems, e.g. Ubuntu, as well as Debian based Docker containers use:
apt-get install -qy php-gd
If it's still unclear, or you have older/other system just search
apt-cache search php gd
and will find out possible package candidates.
For Docker containers it seems you need a different route, so Dockerfile:
FROM php:7.1-apache-buster
RUN apt-get update
RUN apt-get upgrade -qqy
RUN php -v
RUN apt-get install -qy libpng-dev
RUN docker-php-ext-install gd

How to add yaml to php server docker installation

I am having problems installing yaml support on my php docker configuraiton.
Here is my dockerbuild file:
FROM php:7.2.2-apache
RUN docker-php-ext-install mysqli
# Install YAML extension
RUN pecl install yaml && echo "extension=yaml.so" > /usr/local/etc/php/conf.d/ext-yaml.ini && docker-php-ext-enable yaml
But I am getting error:
configure: error: Please install libyaml
I googled, but haven`t found working solution yet. Any ideas how should I do it?
Note:
RUN apt-get install libyaml
Havent worked, got message E: Unable to locate package libyaml
And also this command havent worked:
yum install libyaml-devel
error: yum install libyaml-devel
First you need to run the update and then install the required package that is libyaml-dev.
FROM php:7.2.2-apache
RUN docker-php-ext-install mysqli
# Install YAML extension
RUN apt-get update -y
RUN apt-get install libyaml-dev -y
RUN pecl install yaml && echo "extension=yaml.so" > /usr/local/etc/php/conf.d/ext-yaml.ini && docker-php-ext-enable yaml
How do I install the yaml package for Python?
I found also different way, maybe for someone easier because adding php extension is really simple.
https://github.com/mlocati/docker-php-extension-installer
And here is my final Dockerfile
FROM php:7.2.2-apache
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions mysqli yaml

Is it safe to remove dev packages in Ubuntu after the PHP extension was build?

I'm building pdo_firebird extension with php5 and firebird pdo on ubuntu / debian tutorial on server provisioning.
Tutorial recommends installing a bunch of extensions:
sudo apt-get install php5-dev firebird2.5-dev php-pear devscripts debget
I've checked Building extensions using phpize and other chapters from PHP Internals Book, but found nothing.
Is it safe to remove installed packages? What is a best practice?
apt-get -y remove --purge php5-dev firebird2.5-dev php-pear devscripts debget
apt-get autoremove -y
It is safe to remove *-dev packages after building is done.
But only the *-dev packages, but removing the *-dev packages will also remove any packages automatically installed with the *-dev packages as dependencies.
E. g. libmcrypt-dev also installs libmcrypt4
sudo apt-get -y install libmcrypt-dev
# run your build commands here ...
sudo apt-get -y purge libmcrypt-dev
will result in:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so' - libmcrypt.so.4: cannot open shared object file: No such file or directory in Unknown on line 0
So you need to ensure your library packages are installed separate:
sudo apt-get -y install libmcrypt-dev libmcrypt4
# run your build commands here ...
sudo apt-get -y purge libmcrypt-dev
One should generally not have any problems while removing packages as they generally follow the trend they are used to while installing them even when compiling from source.
Although removing specific packages only causes trouble when these are dependent on other packages and vice versa to function correctly (it may show this warning too if there exists any such conflict) hence use autoremove that's it.
To avoid these confusions ,later install all packages separately and not what is bundled with them.

How to fix error with xml2-config not found when installing PHP from sources?

When I try to install php 5.3 stable from source on Ubuntu (downloading compressed installation file from http://www.php.net/downloads.php) and I run ./configure I get this error:
configure: error: xml2-config not found. Please check your libxml2 installation.
All you need to do instal install package libxml2-dev for example:
sudo apt-get install libxml2-dev
On CentOS/RHEL:
sudo yum install libxml2-devel
For the latest versions it is needed to install libxml++2.6-dev like that:
apt-get install libxml++2.6-dev
I had the same issue when I used a DockerFile.
My Docker is based on the php:5.5-apache image.
I got that error when executing the command RUN docker-php-ext-install soap
I have solved it by adding the following command to my Dockerfile:
RUN apt-get update && apt-get install -y libxml2-dev
Ubuntu, Debian:
sudo apt install libxml2-dev
Centos:
sudo yum install libxml2-devel
this solution it gonna be ok on Redhat 8.0
sudo yum install libxml2-devel
OpenSuse
"sudo zypper install libxml2-devel"
It will install any other dependencies or required packages/libraries

Categories