简体   繁体   中英

Replicate DigitalOcean's Ubuntu 14.04 environment as close as possible on my MacBook?

I have a Ubuntu 14.04 droplet (with Express, Nodejs, Socket.IO, and Jade being the primary stack). Nothing too fancy.

I want to replicate that environment on my 2015 MacBook Pro. What tools and instructions should I download and use in order to achieve that?

I would rather not use a Virtual Server to go inside and code in the Ubuntu server everytime.

Maybe have a configuration for localhost/production servers?

I have some provisions scripts that I use for setting up droplets, also I run the same provisions scripts to create local virtual machines using Vagrant .

You can create a shared folder between your host (OS X) and virtual machine, so you can code and access files directly from OS X, and server from virtual machine will be able to execute them.

Also you can forward a port from your host machine to the virtual machine, accessing http://localhost:8000/ form your host machine (OS X) will actually access server on the virtual machine.

For automating provisioning you can dig into Ansible, Puppet, Chef.

I think you want to clone your server to your local.

But the environment on your Mac OS is different from that on Ubuntu Linux.

The stacks in your Linux droplet are compiled only for Ubuntu 14.04 which would not fit in your Mac OS probably.

I suggest your would only consider that back up the project codes and put it in your MacOS then build an environment (Express, Nodejs, Socket.IO, etc.) specifically for Mac OS.

For backing up projects, you could use this tool rsync . It's easy and convenient, no matter where you want to put your project (including Mac OS or other Linux/Unix destros).

Unless you have SSL set up, there should be nothing special you need to do to have this app behave virtually the same way between environments - there isn't even a database in the stack. There are some differences between Ubuntu and Mac behavior with the fs library, but they are pretty esoteric. Node.js works fairly well across platforms:

  • clone the code locally (using Git, or some other VCS).
  • run npm install assuming node.js is installed on this machine. If it isn't, that should be the only dependency you need. npm install will grab all of the node dependencies you need.
  • then run the code as you would on the server.

Maybe also check that your node.js binary is the same between environments for best luck.

If you do have SSL set up, you probably will need a local configuration vs prod configuration so that SSL is disabled locally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM