odoo14编译安装教程ubuntu18

前提条件,安装好python3.8.0

参考资料:https://blog.csdn.net/ccagy/article/details/113174773

STEP 1 : To Update apt source list.

sudo apt-get update

STEP 2 : Create odoo user and also group.

sudo adduser -system -home=/opt/odoo -group odoo

STEP3 : For the smooth running of odoo, install PostgreSQL database server and install it on the same host as odoo is running.

sudo apt-get install -y postgresql

After the installation start use the below commands to start the postgresql database server

sudo service postgresql start

Then create a database user for odoo

sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo

Give a role password for the newly created role and verify it by giving password again.

exit

Then restart the postgresql server

sudo service postgresql restart

STEP 4 : Install python and depended python packages on the server.

sudo apt-get install -y python3-pip

sudo apt-get install libxml2-dev libxslt1-dev python-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libevent-dev
sudo pip install lxml
	
sudo apt-get install libldap2-dev
sudo apt-get install libsasl2-dev

Install Python Dependencies for Odoo 14.


To switch in to the odoo user and then install the dependency packages.

sudo su - odoo -s /bin/bash
pip3 install Babel decorator docutils ebaysdk feedparser gevent greenlet html2text Jinja2 lxml Mako MarkupSafe mock num2words ofxparse passlib Pillow psutil psycogreen psycopg2 pydot pyparsing PyPDF2 pyserial python-dateutil python-openid pytz pyusb PyYAML qrcode reportlab requests six suds-jurko vatnumber vobject Werkzeug XlsxWriter xlwt xlrd polib

如果安装慢,可以加个参数-i https://pypi.mirrors.ustc.edu.cn/simple/

STEP 5 : Odoo web dependencies

sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install -y node-less
sudo python3 -m pip install libsass

STEP 6 : Install odoo 14 community version from nightly.odoo.com.

Switch to odoo user

sudo su - odoo -s /bin/bash

Download the odoo 14 package from nightly.odoo.com

wget https://nightly.odoo.com/14.0/nightly/deb/odoo_14.0.latest.tar.xz

Extract the downloaded package of odoo14 using tar

tar xfv odoo_14.0.latest.tar.xz

Change directory from /opt/odoo to src

 cd src 

Install the requirements

pip3 install -r requirements.txt

And exit from the odoo user

STEP 7 : Create a odoo configuration file

sudo vim /etc/odoo-server.conf

Copy the below content in configuration file.

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = False
logfile = /var/log/odoo/odoo-server.log
addons_path = /opt/odoo/src/addons,/opt/odoo/src/odoo/addons

Change the permission and also the user ownership of configuration file as below

sudo chown odoo: /etc/odoo-server.conf 
sudo chmod 640 /etc/odoo-server.conf

STEP 8 : Create odoo log file

sudo mkdir /var/log/odoo
sudo chown odoo:root /var/log/odoo

STEP 9 : You can copy and paste the script to this file.

sudo vim /etc/init.d/odoo-server
#!/bin/sh
########################################################
########## +-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+##########
########## Technaureus Info Solutions Pvt Ltd ##########
########## +-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+##########
########################################################
### BEGIN INIT INFO
# Provides: odoo-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Name: Odoo start/stop script for Ubuntu
# Author: Technaureus Info Solutions Pvt Ltd.
# Website: https://technaureus.com
# Description: Using this script, we can start/stop/restart
# or check status of odoo server.
#
# Copyright(c)-2016-Present Technaureus Info Solutions Pvt. Ltd.
# All Rights Reserved.
### END INIT INFO
PATH=/bin:/sbin:/usr/bin
NAME=odoo-server
DESC=ODOO-SERVER
# Specify the daemon path for Odoo server.
# (Default for ODOO >=10: /opt/odoo/odoo-bin)
# (Default for ODOO <=9: /opt/odoo/openerp-server)
DAEMON=/opt/odoo/src/odoo-bin
CONFIGFILE="/etc/odoo-server.conf" # Specify the Odoo Configuration file path.

USER=odoo # Specify the user name (Default: odoo).

PIDFILE=/var/run/$NAME.pid # pidfile

# Additional options that are passed to the Daemon.
DAEMON_ARGS="-c $CONFIGFILE"

display() {
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
NORMAL=$(tput sgr0)
col=$(tput cols)
case "$#" in
1)
if [ $1 -eq 0 ] ; then
printf '%s%*s%s' "$GREEN" $col "[ OK ] " "$NORMAL"
else
printf '%s%*s%s' "$RED" $col "[FAIL] " "$NORMAL"
fi
;;
2)
if [ $1 -eq 0 ] ; then
echo "$GREEN* $2$NORMAL"
else
echo "$RED* $2$NORMAL"
fi
;;
*)
echo "Invalid arguments"
exit 1
;;
esac
}

if ! [ -x $DAEMON ] ; then
echo "Error in ODOO Daemon file: $DAEMON" 
echo "Possible error(s):"
display 1 "Daemon File doesn't exists." 
display 1 "Daemon File is not set to executable." 
exit 0;
fi
if ! [ -r $CONFIGFILE ] ; then
echo "Error in ODOO Config file: $CONFIGFILE" 
echo "Possible error(s):" 
display 1 "Config File doesn't exists." 
display 1 "Config File is not set to readable." 
exit 0;
fi
if ! [ -w $PIDFILE ] ; then
touch $PIDFILE || echo "Permission issue: $PIDFILE" && exit 1
chown $USER: $PIDFILE
fi

# Function that starts the daemon/service
do_start() {
echo $1
check_status
procs=$?
if [ $procs -eq 0 ] ; then
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_ARGS}
return $?
else
detailed_info "${DESC} is already Running !!!" $procs
exit 1
fi
}

# Function that stops the daemon/service
do_stop() {
echo $1
check_status
if [ $? -ne 0 ] ; then
start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
return $?
else
display 0 "${DESC} is already Stopped. You may try: $0 force-restart"
exit 1
fi
}

get_pids(){
pids=$(ps -Ao pid,cmd | grep $DAEMON | grep -v grep | awk '{print $1}')
return $pids
}

# Function that checks the status of daemon/service
check_status() {
echo $1
# start-stop-daemon --status --pidfile ${PIDFILE}
status=$(ps -Ao pid,cmd | grep $DAEMON | grep -v grep | awk '{print $1}' | wc -l)
return $status
}

# Function that forcely-stops all running daemon/service
force_stop() {
echo $1
pids=$(ps -Ao pid,cmd | grep $DAEMON | grep -v grep | awk '{print $1}')
if [ ! -z "$pids" ] ; then
kill -9 $pids
fi
return $?
}

detailed_info() {
procs=$2
if [ $procs -eq 1 ] ; then
display 0 "$1"
echo "FINE, ${procs} ${DESC} is Running."
echo "Details :"
pid=`cat $PIDFILE`
echo "Start Time : $(ps -p $pid -wo lstart=)"
echo "Total UpTime: $(ps -p $pid -wo etime=)"
echo "Process ID : ${pid}"
echo ""
else
display 1 "WARNING !!!"
display 1 "${procs} ${DESC}s are Running !!!"
pids=$(ps -Ao pid,cmd | grep $DAEMON | grep -v grep | awk '{print $1}')
echo "Details :"
echo -n "Process IDs : "
echo $pids
# echo $pids | tr ' ' ,
echo "In order to fix, Hit command: $0 force-restart"
echo ""
fi
}
case "$1" in
start)
do_start "Starting ${DESC} "
display $?
;;
stop)
do_stop "Stopping ${DESC} "
display $?
;;
status)
check_status "Current Status of ${DESC}:"
procs=$?
if [ $procs -eq 1 ] ; then
detailed_info "RUNNING" $procs
elif [ $procs -eq 0 ] ; then
display 1 "STOPPED"
else
detailed_info "" $procs
fi
;;
restart|reload)
do_stop "Stopping ${DESC} "
display $?
sleep 1
do_start "Starting ${DESC} "
display $?
;;
force-restart)
force_stop "Forcely Restarting ${DESC} "
sleep 1
do_start "Starting ${DESC} "
display $?
;;
force-stop)
force_stop "Forcely Stopping all running ${DESC} "
display $?
;;
cs)
ps -Ao pid,cmd | grep $DAEMON | grep -v grep | awk '{print $1}' | wc -l
;;
*)
display 1 "Usage: $0 {start|stop|restart/reload|status|force-restart|force-stop}"
exit 1
;;
esac

exit 0

Then change ownership and permission

sudo chmod 755 /etc/init.d/odoo-server
sudo chown root: /etc/init.d/odoo-server

STEP 10 : Test the server running as service

To start the odoo server

sudo /etc/init.d/odoo-server start

Stop the odoo server

sudo /etc/init.d/odoo-server stop

To restart the odoo server

sudo /etc/init.d/odoo-server restart

View the odoo log files

tail /var/log/odoo/odoo-server.log

Now, if you want to add this service to begin on boot up run the bellow command

update-rc.d odoo-server defaults

STEP 11 : Run odoo locally

Switch to odoo user

sudo su - odoo -s /bin/bash
python3  /opt/odoo/src/odoo-bin

Then go to web browser to access odoo14,注意页面打开第一次的密码一定要记住xxxwt-5xxz-xxn8,否则提示没权限

http://localhost:8069

or

http://0.0.0.0:8069

STEP 12 : WKHTMLTOPDF,这个按需要安装

To print PDF reports need to install right version of wkhtmltopdf.

sudo wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6-1.bionic_amd64.deb
sudo cp /usr/local/bin/wkhtmltoimage  /usr/bin/wkhtmltoimage
sudo cp /usr/local/bin/wkhtmltopdf  /usr/bin/wkhtmltopdf

猜你喜欢

转载自blog.csdn.net/ccagy/article/details/113177704