Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux云服务器docker安装node、mongodb #8

Open
zhuanyongxigua opened this issue Feb 8, 2018 · 0 comments
Open

Linux云服务器docker安装node、mongodb #8

zhuanyongxigua opened this issue Feb 8, 2018 · 0 comments

Comments

@zhuanyongxigua
Copy link
Owner

首先要购买好云服务器

然后打开terminal

ssh root@45.76.222.131

terminal会提示输入密码,直接输入收到的密码就好。

接着就要输入以下的命令了。

生成一个ssh key

ssh-keygen

显示公钥

cat ~/.ssh/id_rsa.pub

把生成的公钥放到GitHub上面

接着回来搭建基本的开发环境

安装vim

apt-get install -y vim git

安装docker

curl -SsL https://get.docker.com | sh

查看docker中的容器

docker ps -a

docker中安装node6.8

docker pull node:6.8

docker中安装mongodb:3.0

docker pull mongo:3.0

docker运行node

docker run -itd -v /root:/root --name node --net=host node:6.8 bash

进入docker

docker exec -it node bash

从GitHub克隆过来自己写好的网页应用

git clone git@github.com:zhuanyongxigua/notepad-online.git

列出所有

ls -all

出容器(另开一个terminal重新进)运行mongodb

docker run -itd --name mgo --net=host mongo:3.0

然后就可以cd到克隆过来的文件里面使用npm installnpm start

如果运行出错,需要停掉程序

docker stop node

这里面的node就是上面创建的那个,因为上面创建的时候的name规定的是node

改好错之后就继续运行node

docker start node

如果需要向mongodb post数据

curl -i -H "Content-Type:application/json" -XPOST -d '这里是JSON数据' url

如果需要移除容器,需要先把容器停下来,在移除

docker stop node
docker rm node        //node就是之前开启的容器的名称

博客:https://zhuanyongxigua.github.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant