我是一个新手,对shell脚本不熟悉。我正在运行Vagrant,并发现自己需要在php.ini中调整这些设置:
upload_max_filesize 120M
post_max_size 120M
max_execution_time 200
max_input_time 200
我该如何将它们添加到shell脚本中,以便在第一次vagrant up时只需设置我的机器?
使用下面的脚本,您可以轻松地调整php.ini中的值。每次只需要更新前4行。
请确保您的sed命令支持-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
s/^\($key\).*/\1 $(eval echo \${$key})/
。 - Adib Arouisudo sed -i "s/^\($key\).*/\1 $(eval echo \${$key})/" /etc/php5/apache2/php.ini
。 - Visualisesudo sed -i "s/^\($key\).*/\1 = $(eval echo \${$key})/" /etc/php5/apache2/php.ini
- Visualisesed -i.bak "s/^\($key\).*/\1 $(eval echo \${$key})/" php.ini
将创建php.ini.bak。 - Mike有一个用于此目的的 shell 脚本 https://github.com/StanAngeloff/vagrant-shell-scripts#php
php-settings-update(name, value)
Update a PHP setting value. This function will look for all php.ini files in /etc. For each file, a conf.d directory would be created in the parent directory (if one doesn't already exist) and inside a file specifying the setting name/value will be placed.
Example (create a default timezone):
php-settings-update 'date.timezone' 'Europe/London'
sed
来完成这个任务。 - Brad