Vous êtes sur la page 1sur 7

Instalasi Odoo

Sumber : http://odootricks.wordpress.com/2014/09/30/installing-odoo-8-on-centos-6-with-virtualpython-install/
This tutorial will walk you through the process of installing the latest version of Odoo on CentOS 6. It
is intended for those who might not be experienced Linux administrators but who want to run their
own Odoo server. You can simply copy-paste the commands into your terminal or SSH window.
The tutorial is fully tested on CentOS 6.5 but should work for any 6.x version. Please see my other
tutorial for CentOS 7 instructions.
First we will install the PostgreSQL database server, then install the necessary package dependencies.
Next we will create a virtual Python environment (so we dont interfere with the CentOS version) and
install all the modules Odoo requires. Then its time to pull the latest Odoo code from GitHub and
create a CentOS 6 compatible init script. Finally we will add the necessary firewall rules and connect
to the server.
This tutorial assumes you have already performed a minimal install of the latest version of CentOS 6.5
on a server dedicated to just running Odoo. It also assumes you will be running Odoo on the same
server as the PostgreSQL database.
1: Generate Odoo Passwords
Before starting installation we will generate two passwords. The first line generates a strong random
password for the odoo server to access the PostgreSQL database that we will install. The second line is
the master password you will use to create the Odoo database after the installation is complete. Dont
worry about these for now. After the installation is complete you will find both these passwords in the
Odoo configuration file (/etc/odoo-server.conf).
Important: You must run these commands as the root user
ODOO_POSTGRES_PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`
ODOO_DB_ADMIN_PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`
2: Install and configure PostgreSQL
First will install the PostgreSQL version 9.3. Unfortunately the CentOS 6 official respository only
contains older versions, so we will need to install directly from the PostgreSQL repositories. We use
the repository rather than simply downloading an RPM because its easier to keep up to date with
important security and maintenance updates. This command will add the PostgreSQL repository to
your server:
rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
Its important we exclude postgresql from the official CentOS repository files, otherwise we will
encounter problems when we run updates:
sed -i 's/^gpgkey.*/&\nexclude=postgresql*/' /etc/yum.repos.d/CentOS-Base.repo
Installing PostgreSQL and some associated libraries is now straightforward. We then need to initialise
the database.

yum -y install postgresql93 postgresql93-server postgresql93-devel postgresql93-libs

service postgresql-9.3 initdb
Next we need to configure PostgreSQL so it will accept connections using MD5 hashed passwords so
its compatible with the Python modules:
sed -i "/^host/s/ident/md5/g" /var/lib/pgsql/9.3/data/pg_hba.conf
Finally lets add PostgreSQL to the list of services which will be enabled at startup. We then start the
PostgreSQL server and add the Odoo user with the password we generated in step 1.
/sbin/chkconfig --level 35 postgresql-9.3 on
service postgresql-9.3 start
-c "createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo"
3: Installing Python
Odoo requires a modern version of Python lot of additional libraries. Potentially these could conflict
with the Python libraries supplied in CentOS 6 and relied upon by the built in administration tools. So
to avoid this risk we will create a virtual environment under the Odoo system user account which will
be used solely by the Odoo server.
First lets install some package dependencies:
yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel
tk-devel gdbm-devel db4-devel libffi-devel libxslt libxslt-devel libxml2 libxml2-devel openldap-devel
libjpeg-turbo-devel openjpeg-devel libtiff-devel git libpng libXext libz.so.1 xorg-x11-fonts-Type1 curl
We also need the wkhtmltopdf package in order to generate PDF reports in Odoo. This link is for the
64bit version of CentOS. For 32bit change amd64 to i386 in the filename below.
rpm -ivh http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linuxcentos6-amd64.rpm
ln -s /usr/local/bin/wkhtmltopdf /usr/bin/
Optional: You may wish to install Microsofts Core Fonts so they are available when you generate
reports in Odoo. First we need to install some dependencies, then the msttcore-fonts-installer rpm
downloads the fonts from sourceforge, installs them and activates them on your CentOS server.
For 64 bit (x86) CentOS installs ONLY:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/libmspack-0.4-0.1.alpha.el6.x86_64.rpm
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/cabextract-1.3-3.el6.x86_64.rpm
rpm -ivh https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.61.noarch.rpm
For 32 bit (i386) CentOS installs ONLY:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/libmspack-0.4-0.1.alpha.el6.i686.rpm
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/cabextract-1.3-3.el6.i686.rpm

rpm -ivh https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.61.noarch.rpm

Now lets download and install Python 2.7.8 from source. The first command removes any existing
python2.7 installs from previous attempts. Note after compiling we use altinstall to prevent
overwriting the CentOS default python installation. We will do the Python build in the root users home
directory as some CentOS installs prevent the execution of compiled C programs in the /tmp/ directory
for security reasons (see noexec in /etc/fstab):
rm -rf /usr/local/lib/python2.7
cd /root/
wget http://python.org/ftp/python/2.7.8/Python-2.7.8.tgz
tar -xzf Python-2.7.8.tgz
cd Python-2.7.8
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make altinstall
With Python successfully installed its time to add the Python virtual environment (virtualenv) and the
PIP module installation utility:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | /usr/local/bin/python2.7
/usr/local/bin/easy_install-2.7 pip virtualenv
Next lets create an Odoo user and setup the virtual environment.
adduser odoo
DIR="/var/run/odoo /var/log/odoo /opt/odoo /opt/andromeda-addons"
for NAME in $DIR
if [ ! -d $NAME ]; then
mkdir $NAME
chown odoo.odoo $NAME
4: Installing Python modules in a virtual environment
Odoo requires a lot of Python modules to run. With the Python virtual environment successfully
created we now need to add all the additional modules.
Important note for WHM/cPanel users: If your hosting provider is using WHM/cPanel to manager
your server, you must enable compiler access for the odoo user otherwise the Python and additional
modules installation will fail. See here for instructions on how to enable compiler access. You can
disable compiler access again after Odoo installation is completed.
Important: Commands in this section must be run as the odoo user
First lets switch from root to the odoo user, then create a new virtual environment called odoo and
activate it:
su - odoo

/usr/local/bin/virtualenv --python=/usr/local/bin/python2.7 odoo

source odoo/bin/activate
Before starting the module installation we need to add the path to the PostgreSQL binaries, otherwise
the PsycoPG2 module install will fail:
export PATH=/usr/pgsql-9.3/bin:$PATH
Now lets install all the Python modules. Note we are replacing PIL with pillow its a better
supporting fork of PIL and it plays nicely with the location of the CentOS development libraries.
pip install http://download.gna.org/pychart/PyChart-1.39.tar.gz
pip install babel
pip install docutils
pip install feedparser
pip install gdata
pip install Jinja2
pip install mako
pip install mock
pip install psutil
pip install psycopg2
pip install pydot
pip install python-dateutil
pip install python-openid
pip install pytz
pip install pywebdav
pip install pyyaml
pip install reportlab
pip install simplejson
pip install unittest2
pip install vatnumber
pip install vobject
pip install werkzeug
pip install xlwt
pip install pyopenssl
pip install lxml
pip install python-ldap
pip install decorator
pip install requests
pip install pillow
pip install pyPdf
pip install passlib
5: Installing Odoo 8 from GitHub
Now its finally time to install Odoo itself. We are going to download the latest version of Odoo 8
from the GitHub repository. Note that we are installing into the /opt directory so we can easily manage
the installation in a single location and keep it separate from the rest of the operating system.
Important: These commands must be run as the odoo user
cd /opt

git clone https://github.com/odoo/odoo.git --branch 8.0

chown -R odoo.odoo odoo
Lets create a basic Odoo server configuration file. The passwords we created earlier will be
automatically populated. Note Ive also disabled the various RPC modules for extra security as I dont
use them. Ive also dialled back the logging so we only see warnings and fatal errors. Im located in
the UK, so the timezone is set to Europe/London.
Important: All the following commands must be run as the root user
cat > /etc/odoo-server.conf << EOF
; This is the password that allows database operations:
admin_passwd = $ODOO_DB_ADMIN_PASSWORD
db_host = localhost
db_port = 5432
db_user = odoo
addons_path = /opt/odoo/addons
load = web
timezone = Europe/London
no-xmlrpc = True
no-xmlrpcs = True
no-netrpc = True
logfile = /var/log/odoo/odoo-server.log
log_handler = werkzeug:WARNING
log_level = warn
no-logrotate = True
chown root.odoo /etc/odoo-server.conf
chmod 640 /etc/odoo-server.conf
I also like to enable logrotation using the built in CentOS tools so the logs are managed in the same
way as all the other applications.
cat > /etc/logrotate.d/odoo-server << EOF
/var/log/odoo/*.log {
Next we create a script to easily start and stop the Odoo server. We download a pre-created init script,
then use a sed script to modify the startup command so it plays nicely with the virtual Python
environment we created earlier.

wget -O /etc/init.d/odoo https://raw.githubusercontent.com/Johnzero/OE7/master/install/openerpserver.init

sed -i "s/openerp/odoo/g" /etc/init.d/odoo
sed -i "s/OpenERP/Odoo/g" /etc/init.d/odoo
sed -i "s/\/usr\/bin\/setsid \/usr\/bin\/odoo-server/~\/odoo\/bin\/python \/opt\/odoo\/openerp-server/"
chmod +x /etc/init.d/odoo
/sbin/chkconfig --level 35 odoo on
The final step in this section is to add the necessary firewall rules. The redirect command accepts
connection on port 80 and redirects them to the default Odoo port 8069. This avoids your users having
to remember to enter the port number each time.
/sbin/iptables -A INPUT -p tcp --dport 5432 -i lo -j ACCEPT -m comment --comment "Accept local
connections to PostgreSQL"
/sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8069 -m comment
--comment="Redirect Odoo HTTP requests to 8069"
/sbin/iptables -A INPUT -p tcp --dport 8069 -j ACCEPT -m comment --comment "Accept inbound
Odoo connections"
/etc/init.d/iptables save
6: Launching Odoo and logging in
To start Odoo, simply run the init script:
/etc/init.d/odoo start
You should be able to open a browser and connect to your Odoo server IP address.
You can check the logfiles in /var/log/messages and /var/log/odoo/odoo-server.log to make sure
everything started correctly. Note you can also use /etc/init.d/odoo restart and /etc/init.d/odoo stop
to restart and stop Odoo as required.
tail -50f /var/log/odoo/odoo-server.log
Remember you can find your database admin password in the odoo configuration file: /etc/odooserver.conf
7: Updating Odoo
If you want to update the Odoo code to the latest version you can easily do that by stopping the server
then performing a git pull. Note that you must only do the git pull as the odoo user.
/etc/init.d/odoo stop
su - odoo
cd /opt/odoo
git pull
/etc/init.d/odoo start

I hope this guide helps you get Odoo 8 up and running on CentOS 6.5. Let me know how you get on
in the comment section, and also check out my other tutorials.