Does anybody know how to install php 7 with ImageMagick on CircleCI?
Everything except ImageMagick works. Here is the error message I get.
Intervention\Image\Exception\NotSupportedException:
ImageMagick module not available with this PHP installation.
Here is my circle.yml
machine:
pre:
- sudo apt-get update; USE_PRECOMPILE=true sudo -E circleci-install php 7.0.4
php:
version: 7.0.4
timezone: America/Los_Angeles
services:
- mysql
environment:
APP_ENV: testing
APP_KEY: randomrandomrandomrandomrandomra
dependencies:
pre:
- sudo aptitude -y install imagemagick
- sudo apt-add-repository -y ppa:ondrej/php
- sudo apt-get -y update
- sudo apt-get -y install php-imagick
override:
- composer install --prefer-dist --no-interaction
post:
- mv .env.circleci .env
test:
override:
- vendor/bin/phpunit
To get imagick working with PHP 7 you need to use the following in your circle.yml:
machine:
php:
version: 7.1.3
dependencies:
pre:
- printf "\n" | pecl install -f imagick
- echo "extension = imagick.so" >> /opt/circleci/php/$(phpenv global)/etc/php.ini
Hope this helps!
I had a similar problem and solved it using suggestions from these two posts...
From this post from the circle-ci discussion forum, you'll need to install with PECL and then enable with docker-php-ext-enable
RUN apt-get update && apt-get install -y \
libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick
if it fails to activate the extension you may add this after/instead of docker-php-ext-enable imagick
echo "extension=imagick.so" | sudo tee -a /usr/local/etc/php/conf.d/ext-imagick.ini
For that, you can refer to this github comment
Related
I have a PHP-CLI Docker image of Debian Buster and would like to install php-imagick package but with command:
Dockerfile:
RUN apt-get install -y php-imagick
I get an error:
Package php-imagick is not available, but is referred to by another
package. This may mean that the package is missing, has been
obsoleted, or is only available from another source
E: Package 'php-imagick' has no installation candidate
running before:
RUN apt-get update -y && apt-get upgrade -y
did not help.
how come there is no package candidate for php-imagick?
how to install and enable imagick extension for this PHP Docker image?
Dockerfile to replicate issue:
FROM php:7.3-buster
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y php-imagick
build command
docker build --tag testimage .
Unless you have a good reason not to, using the packages from https://deb.sury.org/ is probably a good idea. The following appears to work:
FROM debian:buster-slim
USER root
# Get Debian up-to-date
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y git \
mariadb-client wget curl \
ca-certificates lsb-release apt-transport-https gnupg bsdmainutils
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/php.list \
&& curl https://packages.sury.org/php/apt.gpg | apt-key add - \
&& apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y php7.3 php7.3-common php7.3-cli \
php7.3-mysql php7.3-curl php7.3-xml php7.3-mbstring \
php7.3-intl php7.3-redis php7.3-zip \
php7.3-imagick supervisor
I have a simple docker file, as follows:
FROM php:7.2-apache
COPY src/ /var/www/html/
Normally to install drivers for Mongo or MySQL connectivity I would do so by adding something like the below to the dockerfile:
docker-php-ext-install mongo
On this occasion I want to connect my php application to a SQL Server database, and I understand the best way to do this for php 7.x is by using the PDO driver, however I am unfamiliar with how to do configure this in the dockerfile.
I've tried doing a pecl install, like adding:
RUN pecl install sqlsrv pdo_sqlsrv
However this fails with a combination of errors that do not seem to point me in the right direction.
I'm just looking for a simple way to get this done in a dockerfile or by using docker run.
For added info, here's the error I'm getting:
/tmp/pear/temp/sqlsrv/shared/xplat.h:30:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
Makefile:194: recipe for target 'conn.lo' failed
make: *** [conn.lo] Error 1
ERROR: `make' failed
The command '/bin/sh -c pecl install sqlsrv pdo_sqlsrv && docker-php-ext-enable pdo_sqlsrv' returned a non-zero code: 1
Thanks all
I have created a docker file for this exact purpose:
FROM php:7.3-apache
ENV ACCEPT_EULA=Y
RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv
COPY . /var/www/html/
Enjoy!
Did you get an answer to this? I got it working with the following steps. (The unixodbc-dev package should get you past the pecl install.)
in the Docker file:
RUN apt-get -y install unixodbc-dev
RUN pecl install sqlsrv pdo_sqlsrv
And then you have to add some changes to php.ini to enable sqlserver.
get a local copy of php.ini and add these lines:
extension=pdo_sqlsrv.so
extension=sqlsrv.so
Then copy your local php.ini into the docker image (my file is in a local "config" folder).
in the Docker file:
COPY config/php.ini /usr/local/etc/php/
My docker config:
###############
# MSSQL support
###############
RUN apt-get update \
&& apt-get install -y gpg unixodbc unixodbc-dev \
&& docker-php-ext-install pdo pdo_mysql \
&& pecl install sqlsrv pdo_sqlsrv
# ------------ Install MS SQL client deps ------------ #
# adding custom MS repository
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install SQL Server drivers and tools
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"
# Debian 9 msodbcsql : https://packages.microsoft.com/debian/9/prod/pool/main/m/msodbcsql17/
RUN wget https://packages.microsoft.com/debian/9/prod/pool/main/m/msodbcsql17/msodbcsql17_17.4.2.1-1_amd64.deb
RUN ACCEPT_EULA=Y dpkg -i msodbcsql17_17.4.2.1-1_amd64.deb
RUN apt-get -y install locales
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
RUN locale-gen
RUN echo "extension=sqlsrv.so" >> /usr/local/etc/php/conf.d/docker-php-ext-sqlsrv.ini
RUN echo "extension=pdo_sqlsrv.so" >> /usr/local/etc/php/conf.d/docker-php-ext-pdo-sqlsrv.ini
# -------------- END MSSQL -------------------------------- #
FROM php:7.4.0-apache
ENV ACCEPT_EULA=Y
RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-relea`enter code here`se.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv pdo pdo_mysql
COPY index.php /var/www/html/
I am new to docker, needed to use it for a legacy project that requires php5. Here is my Dockerfile snippet:
FROM ubuntu:14.04.1
LABEL MAINTAINER Hasan
RUN apt-get update && \
apt-get install -y apache2 && \
apt-get install -y mysql-server php5-mysql && \
apt-get install -y php5 libapache2-mod-php5 php5-mcrypt
WORKDIR /var/www/html
COPY . /var/www/html
EXPOSE 80
CMD service apache2 start
Here is the command to build it:
docker build -t rakibtg/oldapp .
It gives few error including 'Hash Sum mismatch' and 'returned a non-zero code: 100'
Fetched 16.7 MB in 60s (274 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/perl/perl-modules_5.18.2-2ubuntu1.4_all.deb Hash Sum mismatch
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update && apt-get install -y apache2 && apt-get install -y mysql-server php5-mysql && apt-get install -y php5 libapache2-mod-php5 php5-mcrypt' returned a non-zero code: 100
What should i do to fix it?
Also, is the CMD is configured properly here? Any guide would be appreciated
I am using docker on mac
This error seems more linked to apt-get behavior rather than to Docker.
You can try:
FROM ubuntu:14.04.1
LABEL MAINTAINER Hasan
RUN apt-get clean && apt-get update && \
apt-get install -y apache2 && \
apt-get install -y mysql-server php5-mysql && \
apt-get install -y php5 libapache2-mod-php5 php5-mcrypt
WORKDIR /var/www/html
COPY . /var/www/html
EXPOSE 80
CMD apachectl -D FOREGROUND
or other solutions mentioned in Troube downloading packages list due to a hash sum mismatch error
By the way I changed your CMD statement. Indeed when using service the process will be detached from shell and Docker will stop the container (See How to start apache2 automatically in a ubuntu docker container? for associated explanations)
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
hello
i m using UBUNTU 10.04 and i want to use(install) imagick in XAMPP.i have installed imagick from synaptic package manager but when i m trying to use this in XAMPP,its not working and giving an error like"no class imagick found".
when i open phpinfo(),i didnt find imagick there.
pls suggest me how can i install imagick so that it can work with XAMPP???
Try installing php5-imagick. This is the package containing PHP bindings for Imagemagick.
You should use apt-get to install PHP the correct way since you're on a Linux based OS, using XAMPP (http://www.apachefriends.org/en/xampp.html) is not the way to go.
Depending on the version of PHP you need I would use a script like this to pin your version to 5.2.x, unless you want to use 5.3.x skip to below Apt-Get commands
#! /bin/sh
#check if running as ROOT
ROOTUSER_NAME=root
username=`id -nu` # Or... username=`whoami`
if [ "$username" = "$ROOTUSER_NAME" ]
then
echo "Running as ROOT!!!"
else
echo "Please run as Root as you are just an ordinary user (but mom loves you just the same)."
exit 0
fi
php_packages=`dpkg -l | grep php | awk '{print $2}'`
#check if PHP Packages are NULL
if [ -n php_packages ]
then
echo "Using Found PHP Packages"
echo $php_packages
else
echo "Nothing found, using defaults"
php_packages="libapache2-mod-php5 php-pear php5-cgi php5-cli php5-common php5-curl php5-gd php5-gmp php5-ldap php5-mcrypt php5-mhash php5-mysql php5-odbc php5-pgsql php5-pspell php5-recode php5-snmp php5-sqlite php5-sybase php5-tidy php5-xmlrpc php5-xsl"
fi
# Restart Apache Command
RESTART="/etc/init.d/apache2 restart"
#might need to run aptitude purge to remove all the config/ini files
#aptitude purge $php_packages
apt-get remove $php_packages
echo "Removed Packages\n"
sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list
echo "SED Command\n"
#Create the directory
mkdir -p /etc/apt/preferences.d/
echo "Make DIR: /etc/apt/preferences.d/\n"
# PINing the verion number so Ubuntu wont upgrade the package
for package in $php_packages;
do echo "Package: $package
Pin: release a=karmic
Pin-Priority: 991
" | sudo tee -a /etc/apt/preferences.d/php
done
echo "Finished with PIN\n"
#Update apt-get repos
apt-get update
echo "Updating Apt-Get\n"
#Just listing all the packages that should be installed
for package in $php_packages;
do echo "Package: $package "
done
echo "Starting PHP Install\n";
apt-get install $php_packages php5-mcrypt
echo "Finished Install.........\nRestarting Apache...........\n"
#Restart Apache
RESTART
#Autoclean, remove old files
apt-get autoclean
Here are the Apt-Get commands that you could run as well
# Add Repo
sudo add-apt-repository "deb http://archive.canonical.com/ lucid parnter"
sudo apt-get update
# install
sudo apt-get install apache2 imagemagick php5-imagick
# remove old files
sudo apt-get autoremove