首页 > 其他 > 详细

Vagrant+

时间:2019-10-23 23:22:18      阅读:92      评论:0      收藏:0      [点我收藏+]

 

 

1, 简单的LAMP 构建:

技术分享图片
# =================
# bin/bash
# author Xu

# ===================
# ++++++++++++++++++++++

# ----------- createFile
# arg 1 is Filename
# arg 2 is Contents
# return 1
function createFile ()
{
    if [ -f "./"$1 ];then
    echo "The File "$1" already exists!"
    echo "
    Whether to delete ?"$1"
    (0) NO
    (1) YES
    "
    read -p 1 input
    case $input in
        0)
        exit;;
        1)
        rm $1
        exit;;
    esac
else
    echo " Create add file "$1".  OK"
    cat>>$1 <<EDF
$2
EDF
fi
    return 1
}

echo "
[0] create Vagrantfile;
[1] chmod + > VirtualBox;
[2] vagrant up;
[3] ping ip;
[4] ssh;
[5] Url;
[9] exit;
"

# Url
url=\"192.168.33.11\"

read -p 9 input
case $input in
    0 )
echo Create add file Vagrantfile;

# Create add file Vagrantfile
vagrantfile="Vagrantfile"

createFile $vagrantfile "Vagrant.configure(\"2\") do |config|
config.vm.box = \"scotch/box\"
config.vm.box_version = \"3.5\"
config.vm.network \"private_network\", ip: $url
config.vm.synced_folder \".\", \"/vagrant_data\"
config.vm.synced_folder \"public\", \"/var/www/public\"
end
"
#  execution this
exec sh  "$0" 
#  ....... vagrant up

        exit;;
     1 )
echo "Add permissions otherwise an error will be reported!"
for bin in VirtualBox VirtualBoxVM VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT VBoxHeadless; do
    sudo chmod u+s "/Applications/VirtualBox.app/Contents/MacOS/${bin}"
done
        exit;;
     2 )
# 
rm -rf public && mkdir public && cd public && cat>>index.php<<EDF
<?php echo phpinfo();?>
EDF
vagrant up
        exit;;
     3 )
vagrant ssh -c ifconfig
        exit;;    
     4 )
vagrant ssh
        exit;;
     5 )
echo $url
        exit;;
     9 )
        exit;;
esac
View Code

 

2,

Vagrant+

原文:https://www.cnblogs.com/q1104460935/p/11728998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!