基本上,我正在尝试设置一个
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
您需要将最外面的单引号更改为双引号并删除变量名称周围的单引号.
原文链接:https://www.f2er.com/bash/385641.htmlERROR_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
请注意,我还更改了第一个变量和相关的sed命令,因此它与另一个变量并行.
我假设你得到的错误信息是“unterminated`s”命令.