Installing PHP 7.04 on Trusty image

container-image
trusty

#1

You can use PHP 7.0.4 which is not pre-installed yet on Trusty image.

machine:
  php:
    version: 7.0.4

  pre:
    - curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash
    - sudo apt-get install circleci-php-7.0.4=1

Please note that 7.0.4 is already pre-installed on Precise image.


#2

How would one go about installing the apache module? Neither the precise or trusty containers (or this method) include the apache module; they all fail trying to (still trying to load the php5 module, php7 module not there) on apache restart


#3

@dbos That’s exactly what I’m working on right now! I just updated our image making code so that apache module is included.

Just to make sure, but all you need is libphp7.so file (for php7) ? Or do you mean other files as well when you say “apache module” ?


#4

I believe all I need is libphp7.so; when I install from another repo (ppa:ondrej/php) it removes the php5 module and adds the php7 module from my apache “mods available” and “mods enabled” as well.

We have just started using CircleCI and I’m not especially familiar with rbenv, so I’m just kind of puttering away trying to get it to work. Our project wont run on PHP5 unfortunately…


#5

@dbos I’m sorry for the slow turnaround.

We have a plan to ship a new container image first for 12.04 and then 14.04 to fix this issue sometime next week. In the meantime, I just built a PHP 7.0.4 package for 12.04 so that you can workaround this.

test:
  override:
    - wget https://s3.amazonaws.com/circle-downloads/circle-phpenv-php-7.0.4_1.7_amd64.deb
    - sudo dpkg -i circle-phpenv-php-7.0.4_1.7_amd64.deb

Can you give it a try? This should re-install PHP 7.0.4 with ~/.phpenv/versions/7.0.4/libexec/apache2/libphp7.so.

Please let me know if you have any questions.


#6

It looks like this container is still trying to use the php5 module for apache.


#7

I’m still having trouble getting php7 working with apache on the ubuntu 14.04 container.

Does anyone know a workaround?


#8

In case anyone else needs this, I got around it by re-installing php7:

- sudo add-apt-repository ppa:ondrej/php -y
    - sudo apt-get update
    - sudo apt-get install php7.0 php7.0-mysql
    - sudo a2dismod php5
    - sudo a2enmod php7.0

#9

I am having the exact same problem. libphp7.so. is not found. it might just be that the instructions here are not correct: https://circleci.com/docs/language-php/


#10

Here’s everything we did in circle.yml to move to PHP7.1:

dependencies:
  pre:
    # Set up php-redis.
    # The PHPAPI version (20160303) needs to match.
    # If we start using a different version of PHP this section may need to be updated.
    - sudo apt-add-repository -y ppa:ondrej/php
    - sudo apt-get update
    - sudo apt-get install php-redis php-igbinary
    - echo 'extension=/usr/lib/php/20160303/redis.so' | sudo tee /opt/circleci/php/7.1.0/etc/conf.d/redis.ini
    - echo 'extension=/usr/lib/php/20160303/igbinary.so' | sudo tee /opt/circleci/php/7.1.0/etc/conf.d/igbinary.ini
    # Set up Apache with SSL and tell Apache to use the PHP installation that CircleCI has provided.
    - echo 'LoadModule php7_module /opt/circleci/php/7.1.0/usr/lib/apache2/modules/libphp7.so' | sudo tee /etc/apache2/mods-available/php7.load
    - sudo cp /etc/apache2/mods-available/php5.conf /etc/apache2/mods-available/php7.conf
    - sudo a2dismod php5
    - sudo a2enmod php7

machine:
  pre:
    - sudo apt-get update; USE_PRECOMPILE=true sudo -E circleci-install php 7.1.0

  php:
    # Specify a PHP version, since we depend on it above.
    version: 7.1.0

#11