Want to modify php.ini
dharmeshmp opened this issue · 2 comments
Hi,
In one of my project i need to update value of serialize_precision
to 16 in php.ini
I am not able to figure it out how I can change this value using your image.
Can you please guide me?
Thanks in advance.
There are lots and lots of ways, but I think the easiest way without building your own image would be to take advantage of my "custom script" support.
By setting the following CONTAINER_POST_INIT_SCRIPT=/somewhere/on/filesystem.sh
You could map a script to that location and inside the script could do the following
#!/bin/bash
source /assets/functions/20-php-fpm # Pull my container functions to find the PHP folder nicely
php_bootstrap # Set a new environment variable called 'php_prefix'
sed -i 's|serialize_precision =.*|serialize_precision = 18|g' /etc/"${php_prefix}"/php.ini # Modify _any_ value of serialize precision to the one you want.
This will run after all the other scripts have fun to configure Nginx and PHP-FPM.
There is another way which could work:
Setting an environment variable of
CONTAINER_POST_INIT_COMMAND="source /assets/functions/20-php-fpm; sed -i 's|serialize_precision =.*|serialize_precision = 18|g' /etc/$${php_prefix}/php.ini"
should theoretically work, having it run without having to map a script, however I think the scripts are more flexible to do other things to override settings.
I dont have the ability to scan a seperate folder for directives at this time, but don't see why I couldn't in the future.
Hi @tiredofit
Thanks for the solution. I implemented your recommended solution and it's working fine.
Have done some modifications to your script.
#!/bin/bash
source /assets/functions/20-php-fpm # Pull my container functions to find the PHP folder nicely
phpfpm_bootstrap # Set a new environment variable called 'php_prefix'
sed -i 's|serialize_precision =.*|serialize_precision = -1|g' "${php_prefix}"php.ini # Modify _any_ value of serialize precision to the one you want.
phpfpm_bootstrap
instead of php_bootstrap
"${php_prefix}"php.ini
instead of /etc/"${php_prefix}"/php.ini
Thanks again.