Kulga Thanks, I don't know why the script can not locate those packages. I just run it like: ./flarum_management.sh -if domain.com
After several hours of trying, I find that, if I install php manually by 'sudo apt-get install php-fpm php-mysql' before the script, there will be no problem, it works great.
So now I will first install Nginx, MySQL, PHP on Ubuntu 16.04, then I run the script with '-if' flag, it work as expected like this finally. And I can also remove one domain totally.
Great script!