Apache2 and PHP - missing libphp5.so

I’m trying to run selenium tests with Apache2 and PHP 5.6. I seem to be running into some issues where the yaml file doesn’t seem to produce the documented behavior.

I’ve looked at the docs here https://circleci.com/docs/language-php/ and there are a few things that don’t seem to be correct.

By default, the LoadModule path in /etc/apache2/mods-enabled/php5.load is incorrect. I tried to update it to /home/ubuntu/.phpenv/versions/$(phpenv global)/libexec/apache2/libphp5.so as per the docs but this fails too as there is no ~/.phpenv.
I changed the path to be /opt/circleci/.phpenv but the libexec directory is empty.

I searched the entire disk:
sudo find / -name '*php*.so'
and found this file:
/usr/lib/apache2/modules/libphp5.so
which is a symlink:
/usr/lib/apache2/modules/libphp5.so -> /home/ubuntu/.phpenv/versions/5.6.17/libexec/apache2/libphp5.so
but as we’ve already discovered, ~/.phpenv doesn’t exist.

What is the correct way to get Apache2 and PHP 5.6 running as a module for browser testing?

1 Like

This isn’t a great solution, since it doesn’t allow you to actually select your PHP version, but just leave the machine/php section off of your circle.yml file. The container will default to PHP 5.6.17, and it seems to be correctly configured out-of-the-box. This is the only solution I’ve found that allows me run PHP, as even recompiling PHP in every build didn’t work for me.

@pedrosland What build image are you using? Is it Ubuntu 12.04 or 14.04? If 14.04, then can you try replacing ~/.phpenv with $PHPENV_ROOT ?

@MPLew-is Thanks for your tip.This does seem to work correctly. Strange that it would break even when specifying the same version. I do as you suggested but I decided to build a docker image and cache it for subsequent builds instead.

@kimh I was using Ubuntu 14.04.

I switched to using Docker. While it took a while longer, I’m happy with the result and it is more portable.

@pedrosland

tl;dr I just rebuilt PHP 5.6.17 with php module support.

machine:
  php:
    version: 5.6.17

dependencies:
  override:
    - curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash
    - sudo apt-get install circleci-php-5.6.17=2

With the circle.yml above, $PHPENV_ROOT/versions/5.6.17/usr/lib/apache2/modules/libphp5.so should be available which you can copy to your apache directory.

In Ubuntu 12.04 build image we were using our forked php-build which generates the php module under libexec/apache2 directory.

In 14.04 build image, we instead use upstream php-build which generates the php module under the somewhat strange directory: https://github.com/php-build/php-build/blob/9c51240014c1e22f09e8db17f67718f17e8fd69a/bin/php-build#L578

I’m now rebuilding all PHP packages to make sure to include the apache module so that you don’t have to download everytime. Once they are preinstalled, I’ll update our doc to specify the location of the php module.

Please let me know if the circle.yml doesn’t work for you.

this seems to do the trick for me. it also takes the version set earlier into account

dependencies:
  pre:
    - sudo unlink /usr/lib/apache2/modules/libphp5.so
    - sudo ln -s $PHPENV_ROOT/versions/$(phpenv global)/usr/lib/apache2/modules/libphp5.so /usr/lib/apache2/modules/libphp5.so
2 Likes