设为首页 收藏本站
查看: 759|回复: 0

[经验分享] Installing Odoo 8 on CentOS 6 with Python 2.7-Permanent

[复制链接]

尚未签到

发表于 2018-8-4 13:48:56 | 显示全部楼层 |阅读模式
  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 Pythonenvironment (so we don’t interfere with the CentOS version) and installall the modules Odoo requires. Then it’s 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 ofthe 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 thePostgreSQL database. You will need at least 1GB of available RAM for
lxml to install,>  Odoo is a complicated installation with many dependencies and can be
quite resource intensive. I highly recommend you install on a server (orreal or virtual) that is dedicated to Odoo. Co-locating Odoo with
existing websites/applications is likely to cause problems at some
point.
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. Don’t 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 it’s 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  It’s 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 it’s compatible with the Python modules:
sed -i "/^host/s/ident/md5/g" /var/lib/pgsql/9.3/data/pg_hba.conf  Finally let’s add PostgreSQL to the list of services which will be
enabled at startup. We then start the PostgreSQL server and add the Odoouser with the password we generated in step 1.
/sbin/chkconfig --level 35 postgresql-9.3 on  
service postgresql-9.3 start
  

  
echo -e "$ODOO_POSTGRES_PASSWORD\n$ODOO_POSTGRES_PASSWORD\n" | su - postgres -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>  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 cabextract  We also need the wkhtmltopdf package in order to generate PDF reportsin Odoo. This link is for the 64bit version of CentOS. For 32bit change‘amd64′ to ‘i386′ in the filename below.
rpm -ivh http://sourceforge.net/projects/wkhtmltopdf/files/0.12.2/wkhtmltox-0.12.2_linux-centos6-amd64.rpm/downloadln -s /usr/local/bin/wkhtmltopdf /usr/bin/  Optional: You may wish to install Microsoft’s 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.rpmrpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/cabextract-1.3-3.el6.x86_64.rpmrpm -ivh https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.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.rpmrpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/cabextract-1.3-3.el6.i686.rpmrpm -ivh https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm  Now let’s 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.tgztar -xzf Python-2.7.8.tgz
  
cd Python-2.7.8
  
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
  
make
  
make altinstall
  With Python successfully installed it’s 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 let’s 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
  
do
  
if [ ! -d $NAME ]; then
  
   mkdir $NAME
  
   chown odoo.odoo $NAME
  
fi
  
done
4: Installing Python modules in a virtual environment
  Odoo requires a lot of Python modules to run. With the Python virtualenvironment 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 let’s 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 let’s install all the Python modules. Note we are replacing PIL
with pillow – it’s 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.gzpip 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 it’s 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 restof 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
  
exit
  Let’s create a basic Odoo server configuration file. The passwords wecreated earlier will be automatically populated. Note I’ve also
disabled the various RPC modules for extra security as I don’t use them.I’ve also dialled back the logging so we only see warnings and fatal
errors. I’m 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  
[options]
  
; This is the password that allows database operations:
  
admin_passwd = $ODOO_DB_ADMIN_PASSWORD
  
; DATABASE OPTIONS
  
db_host = localhost
  
db_port = 5432
  
db_user = odoo
  
db_password = $ODOO_POSTGRES_PASSWORD
  
; MISC SETTINGS
  
addons_path = /opt/odoo/addons
  
load = web
  
timezone = Europe/London
  
without-demo=all
  
no-xmlrpc = True
  
no-xmlrpcs = True
  
no-netrpc = True
  
; LOG SETTINGS
  
logfile = /var/log/odoo/odoo-server.loglog_handler = werkzeug:WARNING
  
log_level = warn
  
no-logrotate = True
  

  
EOF
  

  
chown root.odoo /etc/odoo-server.confchmod 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 {
  
    copytruncate
  
    missingok
  
    notifempty
  
}
  
EOF
  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/openerp-server.initsed -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/" /etc/init.d/odoo
  

  
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.logto 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/odoo-server.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”. Notethat you must only do the git pull as the odoo user.
/etc/init.d/odoo stop  
su - odoo
  
cd /opt/odoo
  
git pull
  
exit
  
/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 myother tutorials.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-546541-1-1.html 上篇帖子: Centos 编译安装Python 2.6.6 下篇帖子: 用python解析html[SGMLParser]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表