nanobox-io/nanobox

How to add custom php.ini?

mbrodala opened this issue · 8 comments

Since the PHP ini options configurable through the boxfile.yml are very limited I thought about adding a custom php.ini to my codebase and have it copied to the correct location. For this I used the following:

  extra_steps:
    - cp config/php.ini /data/etc/php.d/zz-php.ini

However, when I issue nanobox run this does not seem to be executed, at least the file does not exist afterwards. Other extra_steps are executed just fine and manually running that command in a console session works fine too.

Any ideas?

Which extra_steps did you add it to?

To run.config of course. :-)

Odd. That should take, then. Maybe running nanobox build -v will illuminate something we've missed?

Here's the relevant part of the output:

$ nanobox build -v
Building runtime :
  Starting docker container :
  Preparing environment for build :
    ...

  Gathering requirements :
  Mounting cache_dirs :
  Installing binaries and runtimes :
    - Installing packages :
      ...

    - ldconfig :

    - Configuring PHP...
      ...
    - Configuring Apache webserver...
      ...
    - Configuring php-fpm...
      ...
    - composer install :
      Gathering patches for root package.
      Loading composer repositories with package information
      Installing dependencies (including require-dev) from lock file
      Nothing to install or update
      Generating autoload files
      Registered helhum/dotenv-connector in composer autoload definition
      Generating  class alias map file
      Inserting class alias loader into main autoload.php file
      Setting up TYPO3 Core Extension directories
      > typo3cms install:generatepackagestates
      sh: 1: typo3cms: not found
      Script typo3cms install:generatepackagestates handling the post-autoload-dump event returned with error code 127

    - After build hook 1 :
       $ cp config/php.ini /data/etc/php.d/zz-php.ini

    - After build hook 2 :
       $ npm install
      ...

  Packaging build :
    - Stashing build environment...
    - Stashing home into cache...
    - Stashing pkg cache...
    - Uninstalling user-requested dev packages :
      ...

    - Removing orphaned packages...
    - Stashing deploy environment...

The mentioned command is indeed executed as well as following commands, however the file is not created:

/app $ ll /data/etc/php.d/
total 4
-rw-rw-r-- 1 gonano gonano 1711 Mar 12 11:47 xdebug.ini

Oh! I think I know what's up, there. Try copying the file into /data/etc/php.dev.d/.

OK, cp config/php.ini /data/etc/php.dev.d/zz-php.ini did work indeed:

$ ll /data/etc/php.d/
total 8
-rw-rw-r-- 1 gonano gonano 1711 Mar 12 12:06 xdebug.ini
-rwxrwxr-x 1 gonano gonano   31 Mar 12 12:06 zz-php.ini*

I guess for production I need an additional cp config/php.ini /data/etc/php.prod.d/zz-php.ini then?

Indeed so. You can put that as a deploy hook, rather than a build hook, though. (That is, in deploy.config for the prod one.)

OK, the full setup would then look like this:

run.config:
  extra_steps:
    - cp config/php.ini /data/etc/php.dev.d/zz-php.ini

deploy.config:
  extra_steps:
    - cp config/php.ini /data/etc/php.prod.d/zz-php.ini

Thanks for clarifying. :-)