在尝试使用 envoy 尝试自动部署的时候,遇到了问题,即:如果我要自己创建一个新的域名,那只能上线去执行 lnmp vhost add 的命令。
sudo /usr/bin/expect<<EOF
spawn lnmp vhost add
expect {
"Please enter domain" {send "{{$host}}\n";exp_continue}
"Enter more domain name" {send "\n";exp_continue}
"Please enter the directory" {send "\n";exp_continue}
"Allow Rewrite rule" {send "y\n";exp_continue}
"Default rewrite" {send "laravel\n";exp_continue}
"Enable PHP Pathinfo" {send "\n";exp_continue}
"Allow access log" {send "\n";exp_continue}
"Enable IPv6" {send "\n";exp_continue}
"Enter your choice " {send "\n";exp_continue}
"Add SSL Certificate" {send "\n";exp_continue}
"Press any key to start" {send "\r"; exp_continue}
}
expect eof
EOF
@task('lnmp' ,['on'=>'dev'])
@if($force)
sudo rm -rf /usr/local/nginx/conf/vhost/{{$host}}.conf
sudo rm -rf /home/wwwroot/{{$host}}
@endif
sudo /usr/bin/expect<<EOF
spawn lnmp vhost add
expect {
"Please enter domain" {send "{{$host}}\n";exp_continue}
"Enter more domain name" {send "\n";exp_continue}
"Please enter the directory" {send "\n";exp_continue}
"Allow Rewrite rule" {send "y\n";exp_continue}
"Default rewrite" {send "laravel\n";exp_continue}
"Enable PHP Pathinfo" {send "\n";exp_continue}
"Allow access log" {send "\n";exp_continue}
"Enable IPv6" {send "\n";exp_continue}
"Enter your choice " {send "\n";exp_continue}
"Add SSL Certificate" {send "\n";exp_continue}
"Press any key to start" {send "\r";}
}
expect eof
EOF
ls -lah /home/wwwroot/
@endtask
这样就 OK 了