Php5enmod on php:5.6 does not enable mod

When I run

version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/php:5.6-apache

    working_directory: ~

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "composer.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: Install PHP requirements
          command: sudo apt-get -y install php5-gd

      - run:
          name: Enable PHP requirements
          command: sudo php5enmod gd

I get the following error:

44

What am I doing wrong?

There is nothing special about this image. Its built off of the official php image from docker. Does this work locally?

It works in my VM. Can I somehow install the CCI image locally so I won’t need to push new commits just to try different ways of enabling GD?

This is what I can find in my container:

circleci@675117bd279a:/etc$ ls -lah /etc | grep php
drwxr-xr-x 1 root   root      52 Dec 15 11:48 php5

And:

circleci@675117bd279a:/etc$ ls -lahR /etc/php5/
/etc/php5/:
total 0
drwxr-xr-x 1 root root   28 Dec 15 11:52 .
drwxr-xr-x 1 root root 2.0K Dec 15 11:46 ..
drwxr-xr-x 1 root root   48 Dec 15 11:46 mods-available

/etc/php5/mods-available:
total 8.0K
drwxr-xr-x 1 root root 48 Dec 15 11:46 .
drwxr-xr-x 1 root root 28 Dec 15 11:52 ..
-rw-r--r-- 1 root root  0 Dec 15 11:52 gd.ini
-rw-r--r-- 1 root root 83 Feb  8  2017 opcache.ini
-rw-r--r-- 1 root root 66 Feb  8  2017 pdo.ini

And:

circleci@675117bd279a:/usr/lib$ ls -lahR /usr/lib/php5/
/usr/lib/php5/:
total 4.0K
drwxr-xr-x 1 root root   40 Dec 15 11:46 .
drwxr-xr-x 1 root root  546 Dec 15 11:46 ..
drwxr-xr-x 1 root root   42 Dec 15 11:46 20131226
-rwxr-xr-x 1 root root 2.7K Feb  8  2017 sessionclean

/usr/lib/php5/20131226:
total 388K
drwxr-xr-x 1 root root   42 Dec 15 11:46 .
drwxr-xr-x 1 root root   40 Dec 15 11:46 ..
-rw-r--r-- 1 root root 112K Feb  8  2017 gd.so
-rw-r--r-- 1 root root 157K Feb  8  2017 opcache.so
-rw-r--r-- 1 root root 116K Feb  8  2017 pdo.so

Why can’t I enable GD?

Trying to write the content of the ini files semi-manually seems to not work either:


What is in /etc/php5/mods-enabled?

What do you get if you do php -m in SSH/rescue mode?

If you do a SSH into the container after failure, can you do sudo php5enmod gd there?

(I don’t have much of a idea what is going wrong, just a few things to try).

Aha, I spot that this is 0 bytes as well - seems to agree with your later findings that it is having trouble writing this file.

That directory wasn’t created, I managed to add it manually when ssh:ing into the container. Couldn’t get sudo php5enmod gd working manually.

The other thing to try is to try sudo apt-get -y install php5-gd in SSH mode (or see the verbose output from where it is presently). As far as I recall, on Ubuntu the module installation should be done for you, and the php5enmod is unnecessary. The only reason why that might not work automagically is if PHP is in a non-standard place in this image.

Also, are you sure it’s called php5-gd? Just do an apt-cache show php5-gd to make sure.

circleci@75270f702b61:~$ apt-cache show php5-gd
Package: php5-gd
Source: php5
Version: 5.6.30+dfsg-0+deb8u1
Installed-Size: 115
Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Architecture: amd64
Depends: libc6 (>= 2.4), libfreetype6 (>= 2.2.1), libgd3 (>= 2.1.0), libjpeg62-turbo (>= 1.3.1), libpng12-0 (>= 1.2.13-4), libvpx1 (>= 1.0.0), libx11-6, libxpm4, zlib1g (>= 1:1.1.4), phpapi-20131226, php5-common (= 5.6.30+dfsg-0+deb8u1), ucf
Description: GD module for php5
Description-md5: 8589696941eddf5936d927aa77051a52
Homepage: http://www.php.net/
Tag: devel::lang:php, implemented-in::c, role::shared-lib,
 secteam::squeeze-limited-support, secteam::wheezy-limited-support,
 works-with::image
Section: php
Priority: optional
Filename: pool/main/p/php5/php5-gd_5.6.30+dfsg-0+deb8u1_amd64.deb
Size: 29222
MD5sum: a76647061bf0ec7caf232581c0a17e40
SHA1: 78ec006b807bd19bccc76db0a37d858d3d81bd8f
SHA256: cd17d0291ebc8f469e19ed4819156d13a0330ae5611831477f485805c6cd453a
circleci@75270f702b61:~$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed:      /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

I’t like there is no PHP ini files at all, as if the PHP 5.6 installation is incomplete.

Fair enough. I am not sure what else to suggest - I am using docker:17.05.0-ce-git, and it has been smooth-sailing for me. I much prefer doing my own build anyway - would adding a Dockerfile and tweaking your .circleci/config.yml work for you?

I quite like defaulting to Alpine anyway - I would guess the CircleCI PHP images are based on Ubuntu or Debian, which are a bit on the chunky side.

Well, our production environment is Ubuntu, so that has value.

After manually creating directories and symbolic links, I have now reached:

32

yet:

circleci@0a68b6d82e9d:~$ cat /usr/local/etc/php/conf.d/gd.ini
; configuration for php GD module
; priority=20
extension=gd.so

Didn’t work, so I changed /usr/local/etc/php/conf.d/gd.ini to:

; configuration for php GD module
; priority=20
extension=/usr/lib/php5/20131226/gd.so

You should the How to install more PHP extensions section of the community’s PHP container:

https://hub.docker.com/_/php/

It’s not immensely straightforward compared to traditional PHP setups.

1 Like