Before you start,download a good terminal that runs shell like cmder full version, for detail, check their website.
- Check video How To Make Your Boring Mac Terminal So Much Better for step by step instructions.
- Blog version of above
Windows/linux users go to 1.2 directly
brew install --cask multipass
reter to their website
输入命令
multipass find
output should be similar to below
Image Aliases Version Description
18.04 bionic 20221014 Ubuntu 18.04 LTS
20.04 focal 20221018 Ubuntu 20.04 LTS
22.04 jammy,lts 20221101.1 Ubuntu 22.04 LTS
anbox-cloud-appliance latest Anbox Cloud Appliance
charm-dev latest A development and testing environment for charmers
docker latest A Docker environment with Portainer and related tools
jellyfin latest Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube latest minikube is local Kubernetes
# curl -L -o script1.sh 'https://raw.githubusercontent.com/byegates/twitter2/main/script1.sh'
cd ~
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/byegates/twitter2/main/script1.sh)" | tee script1.txt
script1 output y有这些信息(example如下), 把'192.168.64.1'
ssh [email protected] -i ~/.ssh/multipass-ssh-key -o StrictHostKeyChecking=no
mount 作用时把你的Mac的home folder映射到虚拟机里面, 这样虚拟机里面和外面就可以操作相同的文件了,比较方便
# 在ubuntu 虚拟机的命令行
ls ~/Home
output应该是你整个home 文件夹
怎么办?重新mount一次,在你host (Mac/Windows) terminal 输入下面的命令
multipass set local.privileged-mounts=Yes
multipass unmount lts2204:Home
multipass mount $HOME lts2204:Home
然后回到上一步在ubuntu里面 ls ~/Home, 你就应该能看到很多文件夹(你的Mac/Windows的home文件夹), 里面有个叫做github的再里面的twitter就是你的项目root folder了
安装必要的软件包,更新,初始化你的项目
cd ~
bash script2.sh
如果找不到script2.sh 这个文件, run 下面的命令(先下载,再执行)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/byegates/twitter2/main/script2.sh)" | tee script2.txt
cd ~/Home/github/twitter
如果进去不了或者看不到东西,回到第五步,fix mount bug
按照说明走完那四步
这个每次登录ubuntu都要run一次,小本本记一下
source ~/.virtualenvs/twitter2/bin/activate
把settings.py里面的 DATABASES 部分替换成下面的内容
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'twitter',
'HOST': 'localhost',
'PORT': '3306',
'USER': 'root',
'PASSWORD': 'yourpassword',
}
}
python manage.py runserver 0.0.0.0:8000&
去浏览器输入, 端口都是8000, 但是ip地址again, 是你自己的虚拟机地址❕
192.168.64.1:8000