用于更改PHP版本的脚本

时间:2018-03-19 21:31:24

标签: bash

我正在尝试使用bash脚本代码在php版本之间切换,但是我收到以下消息错误:

Which PHP version would you like to enable?
php5.6
Module php5.6 already disabled
Module php7.1 already disabled
Module php7.2 already disabled
Enabling... 
ERROR: Module  does not exist!

我的代码:

#!/bin/bash
echo "Which PHP version would you like to enable?";

read $version;

sudo a2dismod php5.6;
sudo a2dismod php7.1;
sudo a2dismod php7.2;

echo "Enabling...";
sudo a2enmod "$version";

systemctl restart apache2;

1 个答案:

答案 0 :(得分:0)

我建议从$删除read $version

在为变量分配内容时,请勿使用$