Odoo 11 Development Essentials(Third Edition)
上QQ阅读APP看书,第一时间看更新

Using a virtual machine

You're welcome to choose your preferred virtualization software to get a working Ubuntu system in a virtual machine, and there are a few options to choose from.

Microsoft Windows 10 includes Hyper-V as a feature. It just needs to be enabled in the Programs and Features menu.

The VMWare Workstation Player can also be a good option. Free to use downloads can be found at https://my.vmware.com/web/vmware/downloads. For macOS, VMWare Fusion should be used instead.

Virtualbox is free software and is available for a wide range of platforms, and so can be a good choice. It can be downloaded from https://www.virtualbox.org.

When writing this chapter, we used Windows 10 and Virtualbox 5.1. Since VirtualBox is free software and supports a wide range of platforms, it seems to be the most versatile choice. Windows 10 was chosen as the example host platform because of its popularity.

A particular configuration important to get right is networking. We want our guest machine to be reachable from the host, so that a web browser in the host can access an Odoo server running in the guest system. And we want our guest system to share the host's internet connection. With VirtualBox, we can achieve these two goals by configuring two network adapters for the guest system.

We first need to ensure connectivity between the host and the guest. This can be done using host-only networking. First, we need to add a network configuration to the VirtualBox host:

  1. From the File menu, select Global Settings. In the Linux edition, the option is File | Preferences
  2. From the list on the left-hand side, select Network, select the Host-only Networks tab, and click on the icon to add a network configuration
  3. In the configuration's Adapter tab, set an IP address for the host, such as 192.168.122.1
  4. In the configuration's DHCP Server tab, enable it and set these suggested values:
    • Server address (for the DHCP): 192.168.122.100
    • Server mask: 255.255.255.0
    • Initial Address: 192.168.122.101
    • Final Address: 192.168.122.254

This configures the network between the host and the guest machines, including a DHCP server that will assign IP addresses to the guest machines.

Now we can go to our Odoo guest settings and add a Network Adapter using the host-only network we just created. Using the suggested configuration, the first IP address assigned will be 192.168.122.101:

However, it does not provide external access to the guest system. For that, we should configure a second network adapter using Network Address Translation (NAT). This is the simplest option to give to the guest system access to external networks.

The Ubuntu guest system might need additional network configuration to be able to use the second adapter. Detailed instructions can be found at https://askubuntu.com/a/876579/88156

Adding these two network adapters to our virtual machine should achieve our two goals: sharing the host's access to external networks (and the internet), and allowing the host to access services on the guest, such as an Odoo server.