Odoo Development Essentials
上QQ阅读APP看书,第一时间看更新

Setting up a host for the Odoo server

We will prefer using Debian/Ubuntu for our Odoo server, even though you will still be able to work from your favorite desktop system, be it Windows, Macintosh, or Linux.

Odoo can run on a variety of operating systems, so why pick Debian at the expense of other operating systems? Because Odoo is developed primarily with the Debian/Ubuntu platform in mind, it supports Odoo better. It will be easier to find help and additional resources if working with Debian/Ubuntu.

It's also the platform the majority of developers work on, and where most deployments are rolled out. So, inevitably, Odoo developers will be expected to be comfortable with that platform. Even if you're from a Windows background it will be important to have some knowledge about it.

In this chapter, you will learn how to set up and work with Odoo hosted in a Debian system, using only the command line. For those more at home with a Windows system, we will cover how to set up a virtual machine to host the Odoo server. As a bonus, the techniques you will learn will also allow you to manage Odoo in cloud servers where your only access will be through Secure Shell (SSH).

Note

Keep in mind that these instructions are intended to set up a new system for development. If you want to try some of them in an existing system, always take a backup ahead of time to be able to restore it in case something goes wrong.

Provisions for a Debian host

As explained earlier, we will need a Debian host for our Odoo version 8.0 server. If these are your first steps with Linux, you may like to know that Ubuntu is a Debian-based Linux distribution, so they are very similar.

Note

Odoo is guaranteed to work with the current stable version of Debian or Ubuntu. At the time of writing this book, these are Debian 7 "Wheezy" and Ubuntu 14.04 "Trusty Tahr". Both ship with Python 2.7, necessary to run Odoo.

If you are already running Ubuntu or another Debian-based distribution, you're set; this machine can also be used as a host for Odoo.

For the Windows and Macintosh operating systems, it is possible to have Python, PostgreSQL, and all the dependencies installed, and then run Odoo from source natively.

However, that could prove to be a challenge, so our advice is to use a virtual machine running Debian or Ubuntu Server. You're welcome to choose your preferred virtualization software to get a working Debian system in a VM. If you need some guidance, here is some advice: regarding the virtualization software, you have several options, such as Microsoft Hyper-V (available in some versions of Windows), Oracle VirtualBox, or VMWare Player (or VMWare Fusion for Macintosh). VMWare Player is probably easier to use, and free-to-use downloads can be found at https://my.vmware.com/web/vmware/downloads.

Regarding the Linux image to use, Ubuntu Server is more user friendly to install than Debian. If you're beginning with Linux, I would recommend trying a ready-to-use image. TurnKey Linux provides easy-to-use, preinstalled images in several formats, including ISO. The ISO format will work with any virtualization software you choose, or even on a bare-metal machine you might have. A good option might be the LAPP image, found at http://www.turnkeylinux.org/lapp.

Once installed and booted, you should be able to log in to a command-line shell.

If you are logging in using root, your first task should be to create a user to use for your work, since it's considered bad practice to work as root. In particular, the Odoo server will refuse to run if you are using root.

If you are using Ubuntu, you probably won't need this since the installation process has already guided you in the creation of a user.

Creating a user account for Odoo

First, make sure sudo is installed. Our work user will need it. If logged in as root:

# apt-get update && apt-get upgrade # Install system updates
# apt-get install sudo # Make sure 'sudo' is installed

The following commands will create an odoo user:

# useradd -m -g sudo -s /bin/bash odoo # Create an 'Odoo' user with sudo powers
# passwd odoo # Ask and set a password for the new user

You can change odoo to whatever username you want. The -m option has its home directory created. The -g sudo adds it to the sudoers list, so it can run commands as root, and the -s /bin/bash sets the default shell to bash, which is nicer to use than the default sh.

Now we can log in as the new user and set up Odoo.