我正在尝试创建一个 bash 脚本,以便在我开发时在我的服务器上安装各种东西。我的想法是它在部署时运行,如果我更改服务器,我只需运行脚本,一切都会正常进行。
到目前为止我有这个:
#!/bin/sh
apt-get update # To get the latest package lists
apt-get install imagemagick ghostscript
INI_LOC=echo php -i | grep 'php.ini' | grep 'Loaded Configuration File'
这是一半。 $INI_LOC 现在的值是“Loaded Configuration File =>/etc/php/7.1/cli/php.ini”
我的问题是,如何更改此变量以仅显示“/etc/php/7.1/cli/php.ini”?
下一步是使用此变量将“extension=imagick.so”添加到 php.ini 文件(如果尚未添加)。
如有任何帮助,我们将不胜感激。
最佳答案
$INI_LOC now has the value "Loaded Configuration File => /etc/php/7.1/cli/php.ini"
My question is, how do I change this variable to only show "/etc/php/7.1/cli/php.ini"?
似乎您只需要从 INI_LOC
中删除“Loaded Configuration File =>”字符串:
INI_LOC=`echo $INI_LOC | sed 's/Loaded Configuration File => //'`
关于php - Bash 脚本 - 将 PHP INI 位置存储在变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48249269/