基本上,我正在尝试设置一个 shell 脚本,让我在新服务器上自动配置一些参数
特别是,我想在 php.ini 中设置
error_log= /var/log/php_errors.log error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
在我的 bash 脚本中,我有这个:
ERROR_REPORTING="error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED"
ERROR_LOG="/var/log/php_errors.log"
#CREATE LOG FILE
sed -i 's/error_reporting = .*/error_reporting = '${ERROR_REPORTING}'/' /etc/php.ini
touch $ERROR_LOG
chown apache:apache $ERROR_LOG
#The ; in the next line is because the line is commented by default on RHEL5
sed -i 's/;error_log = .*/error_log = '${ERROR_LOG}'/' /etc/php.ini
Run Code Online (Sandbox Code Playgroud)
但是,这似乎不起作用,并且错误对我来说并不明显……有人可以纠正我的错误吗?
您需要将最外面的单引号更改为双引号并删除变量名称周围的单引号。
ERROR_REPORTING="E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED"
ERROR_LOG="/var/log/php_errors.log"
#CREATE LOG FILE
sed -i "s/error_reporting = .*/error_reporting = ${ERROR_REPORTING}/" /etc/php.ini
touch $ERROR_LOG
chown apache:apache $ERROR_LOG
#The ; in the next line is because the line is commented by default on RHEL5
sed -i "s/;error_log = .*/error_log = ${ERROR_LOG}/" /etc/php.ini
Run Code Online (Sandbox Code Playgroud)
请注意,我还更改了第一个变量和相关sed命令,使其与另一组平行。
我假设您收到的错误消息是“未终止的‘s’命令”。
| 归档时间: |
|
| 查看次数: |
5976 次 |
| 最近记录: |