Installing GMP on docker using lando - php

I'm trying to spin up a laravel instance via lando using php8.
I also need to install the php GMP module...
I'm very new to docker and lando.
Now it seems as though the php instance that lando uses does not have GMP pre-setup
I found a post somewhere where someone installed some php modules via the lando file and tried to modify my file based on that.
This is my lando file at the moment:
name: og-tools
recipe: laravel
config:
webroot: public
composer_version: 2
database: mariadb
cache: redis
services:
appserver:
type: php:8.0
via: apache
build_as_root:
- apt-get update -y
- apt-get install php8.0-gmp
- echo "extension=gmp.so" > /etc/php8/apache2/conf.d/gmp.ini
mailhog:
type: mailhog
portforward: true
hogfrom:
- appserver
When I try running it I get the following:
E: Unable to locate package php8.0-gmp
E: Couldn't find any package by glob 'php8.0-gmp'
E: Couldn't find any package by regex 'php8.0-gmp'
ERROR ==> E: Couldn't find any package by regex 'php8.0-gmp'
However looking up PHP8 GMP searches lead me to this site: https://websiteforstudents.com/how-to-migrate-to-php-8-0-on-ubuntu/
They mention the package php8.0-gmp however I don't seem to be able to find it.
I could just be doing this all completely wrong, I'm a little out of my depth for the time being and trying to learn as I go

Thanks to one of the guys over on the lando slack, this is the solution he gave me which works:
services:
appserver:
build_as_root:
- apt update && apt install libgmp-dev -y && docker-php-ext-install gmp

Related

Issue with install and setup mongodb into m1 macbook

I have an issue with connecting php(valet) and MongoDB. I tried to install MongoDB with pecl and command sudo pecl install mongodb and brew install mongodb and all time I get some errors during the install process:
In file included from /private/tmp/pear/temp/mongodb/src/MongoDB/Cursor.c:18: /opt/homebrew/Cellar/php#8.0/8.0.17/include/php/ext/spl/spl_iterators.h:151:4: error: unknown type name 'pcre_cache_entry' pcre_cache_entry *pce; ^ 1 error generated. make: *** [src/MongoDB/Cursor.lo] Error 1 ERROR: make' failed`.
But when I run mongo --version I get:
and I install MongoDB Compass and as you can see, I can connect to the database and write into it:
But when I try out to install laravel package jenssegers/mongodb I get these errors: I tried with --ignore-platform-req=ext-mongodb flag but then it install package but it didn't work, I get this error: Error: Class "MongoDB\Driver\Manager" not found.
Finally, I find out a great package that helps me in this! This repo saves me a ton of time and debugging! Thank you shivammathur!
Hey I also had the same problem. A good alternative is to also follow with this article if you want to stick with pecl https://freek.dev/2151-fixing-the-dreaded-pcre2h-file-not-found-error-when-installing-imagick

Docker container fails to build when installing GRPC

I have a Dockerfile that when used with my docker-compose commands works fine, I'd like to have this docker container built however as GRPC takes 15 mins to install every time I want to run tests in GitHub Actions
This is what my Dockerfile currently looks like:
FROM xxx-base:6
RUN pecl install grpc \
&& docker-php-ext-enable grpc \
WORKDIR /application
And I get the following error output:
#5 580.4 g++: fatal error: Killed signal terminated program cc1plus
#5 580.4 compilation terminated.
#5 580.4 make: *** [Makefile:248: src/core/ext/filters/client_channel/lb_policy/xds/cds.lo] Error 1
#5 580.5 ERROR: `make' failed
------
executor failed running [/bin/sh -c sudo pecl install grpc && docker-php-ext-enable grpc WORKDIR /application]: exit code: 1
It's worth mentioning in the base container used here I used pecl to install imagik so I know that command at least partially works. This is a base PHP 7.4 container.
Any suggestions, I've seen some other posts referring to the memory limit on the docker build, but I'm not sure what to change
Pastebin full stacktrace: pastebin.com/g7iZ2uRn
Installing GRPC in a pipeline takes a long time.
I recommend using the cache of the provider used (bitbucket, github etc ..) or using a base image which is used as the starting point of the Dockerfile
FROM baseimage:latest
I have implemented an image based on alpine and php 7.4 with extension grpc installed, check it on github gits click here
In case gcc –version says anything less than 4.9 ...this might be the cause.
This answer also seems to be related to your scenario... in case PECL fails.

Composer Install (own Container) with Docker missing PHP Extensions

I am currently learning about Docker, and using it for 2 weeks. Now i have a very simple task, installing PHP Libraries via Composer. That is usually, when working without Docker:
composer install
Now since i am using Docker, i found there is a Docker Container, that is holding composer for me:
docker run --rm -v $(pwd):/app composer/composer install
This is working pretty good, but there is some libraries out there, that require specific php libraries to be installed, like bcmath, so i add this to my Dockerfile
FROM php:7.0-apache
RUN docker-php-ext-install bcmath <-- added this line
COPY . /var/www/html
WORKDIR /var/www/html
EXPOSE 80
When i rebuild my container, this code returns true
var_dump(extension_loaded('bcmath'))
Hooray! BCMath is installed correctly, but composer does not recognize it, because the library is not installed in the composer container!
Now i could ignore that by using
docker run --rm -v $(pwd):/app composer/composer install --ignore-platform-reqs
but this is, in my opinion, a dirty workound, and composer can not validate my platform. Is there any clean solution, besides downloading composer in my Dockerfile and not reusing an existing container?
You may use platform settings to mimic your PHP container configuration. This will work similar to --ignore-platform-reqs switch (it will use PHP and extensions configured in composer.json instead of real info from current PHP installation), but it gives you more granular control. Instead of "ignore all platform requirements checks" you may say "I really have bcmath installed, trust me". All other requirements will be checked, so you still be warned if new requirement will pop-up.
"config": {
"platform": {
"php": "7.1",
"ext-bcmath": "*"
}
},
You need PHP + PHP Extensions + Composer in the same(!) container = DevContainer.
Simply install Composer using the command provided here.

Install Specific PHP Version with Puppet & Vagrant

First time puppet user, and I'm having trouble getting an install of a specified version of PHP using Vagrant. I'm using the example42/php module, and I keep running into ensure problems.
Error: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install php-5.5.12' returned 1: Error: Nothing to do
Error: /Stage[main]/Php/Package[php]/ensure: change from absent to 5.5.12 failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install php-5.5.12' returned 1: Error: Nothing to do
Warning: /Stage[main]/Php/File[php.conf]: Skipping because of failed dependencies
spits out of my console, followed by another attempt that's identical.
My .pp file I'm provisioning with:
class lamp {
# package {'php':
# ensure => present,
# }
}
node 'node1' {
include lamp
file { '/php':
ensure => directory,
# I read that I may need to have a directory in order for the install to work...
}
class { 'php':
version => '5.5.12',
}
}
As far as I can tell, I'm referencing correctly to the modules, which I store inside /puppet/modules/ and it's finding them, but I'm having a hard time getting a specific version of PHP to install. I could use a very simple "getting started LAMP" for Puppet but that only install 5.3.3 even if I ensure => latest,
The puppet module only uses your system's package manager (yum) to download specific php packages. If it cannot find the required packages, it will not work. 5.3.3 is latest version in your repository, so it install that. I wouldn't be surprised if this is the only version of php available in your repositories.
You need to configure yum with some repositories which have the required PHP packages and then try the puppet module with that.

PHP extensions dependency issue when installing from puppet

does anybody knows how to resolve issue with dependencies for php extensions ?
default.pp
class { 'php':
package => 'php5',
service => 'apache',
version => '5.2.10.dfsg.1-2ubuntu6.5',
require => Package['apache'],
}
package { "PhpModule_mhash":
ensure => '5.2.10.dfsg.1-2ubuntu6.5',
name => 'php5-mhash',
require => [Package['php'], Package['PhpModule_common'], ],
}
when i vagrant up i'm receiving err
err: /Stage[main]//Package[PhpModule_mhash]/ensure: change from purged to 5.2.10.dfsg.1-2ubuntu6.5 failed: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install php5-mhash=5.2.10.dfsg.1-2ubuntu6.5' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php5-mhash : Depends: php5 but it is not going to be installed or
phpapi-20060613+lfs
E: Unable to correct problems, you have held broken packages.
at /tmp/vagrant-puppet/manifests/default.pp:79
My virtual box repository is up to date and all required packages are available. PHP is also installed without problems.
What's very interesting is fact that when i vagrant ssh and execute following command:
/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install php5-mhash=5.2.10.dfsg.1-2ubuntu6.5
it's installed without any notice...
Is there a way to tell Package that php5 is already installed ?
Is there a way to omit dependencies if i have already required package ?
What options do i have on Puppet or Debian side?
Thanks in advance
Puppet Chaining is the answer !
Even though i've specified that *PhpModule_mhash* package`requires php class i had to insert chaining in my manifest.
Class['php'] -> Package['PhpModule_common'] -> Package['PhpModule_cli'] -> Package['PhpModule_mhash']

Categories