Docker install memcached - php

I am trying to install memcached in Dockerfile but I keep getting th same error. Everything was working fine but looks like some layers were cached I and the images was being built with no problems at all. But since I cleared the cache I can't build the image. Here is some of it's content:
FROM php:5-apache
RUN apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev
RUN pecl install memcached
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini
There are many other things that are installed but as I said everything was working before. The error is that memcached requires php7 to run. I dont know if something has changed in the recent builds of the library but looks like it refuses to work with php5. Here is the error:
pecl/memcached requires PHP (version >= 7.0.0), installed version is 5.6.30
pecl/memcached can optionally use PHP extension "igbinary" (version >= 2.0)
pecl/memcached can optionally use PHP extension "msgpack" (version >= 2.0)
No valid packages found
install failed
The command '/bin/sh -c pecl install memcached' returned a non-zero code: 1

The PECL memcached package introduced the dependency on PHP 7 in version 3.0.0. You can still install the 2.x version of that package:
FROM php:5-apache
RUN apt-get update && apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev
RUN pecl install memcached-2.2.0
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini

Related

How to install php module intl on ubunut 22.04 with two php versions active - php 8.1 and php 8.2

My worpdress website site health page dispalyas apossible improvement - php module intl missing.
My server has multiple versions of php (8.1 &8.2) active.
I use the following ssh command to install the missing intl module-
apt-get install -y php-intl
But get tis error message.
The following packages have unmet dependencies:
php8.1-intl : Depends: php8.1-common (= 8.1.2-1ubuntu2.10) but 8.1.14-1+ubuntu18.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
the php modules which are active om my server , like imagick, are installed for php8.1. but my active php version is 8.2.
The problem is with the dependencies of the "php8.1-intl" package. Specifically, it requires version 8.1.2-1ubuntu2.10 of the "php8.1-common" package, but the version that is currently available is 8.1.14-1+ubuntu18.04.1+deb.sury.org+1, which is causing a conflict.
try:
sudo apt update
sudo apt-get check
sudo apt-get install -f
sudo dpkg --configure -a
5.sudo apt-get install php8.1-common=8.1.2-1ubuntu2.10
6.sudo apt-get install php8.1-intl
You may need to remove the conflicting package(s) and installing the required packages again. But be careful when removing packages as it may cause other dependencies to break.

conflicting requests install php-zip on fedora

I'm trying to install php-zip but I get a conflict error:
Problem: conflicting requests
- nothing provides libzip(x86-64) >= 1.8.0 needed by php-pecl-zip-1.19.5-1.fc34.remi.8.0.x86_64
- nothing provides libzip(x86-64) >= 1.8.0 needed by php-pecl-zip-1.20.0-1.fc34.remi.8.0.x86_64
This library is available in "remi" repository, which seems to not be enabled.
https://rpms.remirepo.net/fedora/34/remi/x86_64/repoview/libzip.html
No need pear package, just use the below command.
sometime need check os version then use compatible repo
$ dnf install libzip-dev libzip php-zip php-devel -y
$ php -m | grep zip
> 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

Laravel 5.5 minimum requirements

I am using Ubuntu 17 with php 7.1 and am trying to install Laravel 5.5 but it is telling me to check the minimum requirements.
I can't install the recommended php extensions. I am using sudo add-apt-repository ppa:ondrej/php but it appears the extension are not there and there is a mismatch from the repo
Repository 'http://ppa.launchpad.net/ondrej/php/ubuntu artful InRelease' changed its 'Label' value from '***** The main PPA for PHP (5.6, 7.0, 7.1) with many PECL extensions *****' to '***** The main PPA for supported PHP versions with many PECL extensions *****'
Your composer should say what extensions you need.
You also check doc https://laravel.com/docs/master#installation
PHP >= 7.0.0
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext
Install PHP 7.1 on Ubuntu
Use the following set of commands to add PPA for PHP 7 in your Ubuntu system and install it.
> sudo apt-get install python-software-properties
> sudo add-apt-repository ppa:ondrej/php
> sudo apt-get update
> sudo apt-get install -y php7.1
Now use the following command to check installed php version on your system.
> php -v
Install PHP 7 Modules/Extensions
Find all the available PHP 7 modules using the following command:
> sudo apt-cache search php7-*
Install required PHP extensions using the following command
> sudo apt-get install <extension-name>
You can install multiple extensions using the same command. Separate extension names by a space.
For example
> sudo apt-get install php7.1-xml php7.1-xmlrpc php7.1-zip
Laravel 5.5 System Requirements Checker
To verify system requirements for Laravel 5.5 you can then use the following simple app.
https://github.com/mitesh1409/laravel-system-requirements-checker
Do git clone of this repo inside your server's root directory and then execute it.
For example using Apache server on Ubuntu 16.04, do git clone of this repo inside "var/www/html". It will create an app folder named "laravel-system-requirements-checker". Now you can run this using the url "http://localhost/laravel-system-requirements-checker/".
I hope this will help everyone starting development on Laravel 5.5.
Thanks.
Laravel-Requirement-Checker from browser
https://github.com/hosamalzagh/Laravel-Requirement-Checker

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)

Categories