Change php.ini values ​​from shell script

I am new to shell scripting. I run Vagrant and I need to configure these parameters in php.ini:

upload_max_filesize 120M
post_max_size 120M
max_execution_time 200
max_input_time 200

How can I add them to a shell script so that I can just put my car on the first stroller up?

+6
source share
2 answers

using the script below, you can easily adjust php.ini values. Each time you just need to update the 4 top lines.

make sure your sed command supports -i.

#!/usr/bin/env bash

upload_max_filesize=240M
post_max_size=50M
max_execution_time=100
max_input_time=223

for key in upload_max_filesize post_max_size max_execution_time max_input_time
do
 sed -i "s/^\($key\).*/\1 $(eval echo = \${$key})/" php.ini
done
+14
source

For this purpose, there is a shell script https://github.com/StanAngeloff/vagrant-shell-scripts#php

php-settings-update(name, value)

PHP. php.ini /etc. conf.d ( ) / .

( ):

php-settings-update 'date.timezone' 'Europe/London'
+3

Source: https://habr.com/ru/post/1536892/


All Articles