从 shell 脚本更改 php.ini 值 [英] Change php.ini values from shell script

查看:32
本文介绍了从 shell 脚本更改 php.ini 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 shell 脚本的新手.我正在运行 Vagrant,发现自己需要在 php.ini 中调整这些设置:

I am new to shell scripts. I am running Vagrant, and find myself needing to adjust these setting in the php.ini:

upload_max_filesize 120M
post_max_size 120M
max_execution_time 200
max_input_time 200

如何将这些添加到 shell 脚本中,以便我可以在第一次流浪时配置我的机器?

How can I add those to a shell script so I can just provision my machine on first vagrant up?

推荐答案

使用以下脚本,您可以轻松调整 php.ini 值.每次只需要更新前 4 行.

with below script, you can easily adjust php.ini values. Every time, just need update top 4 lines.

确保您的 sed 命令支持 -i 选项.

make sure, your sed command supports -i option.

#!/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

这篇关于从 shell 脚本更改 php.ini 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆