Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

阿里云部署 CentOS7.4+Python3.6+Postgresql10+Odoo12+OpenResty1.13(Nginx1.13) 实例教程



  • 第一步:安装环境
    1.1 安装Python3.6

    # yum -y update
    # yum -y groupinstall "Development tools"
    # yum install glibc-static libstdc++-static
    # yum install python36-devel libxslt-devel libxml2-devel openldap-devel
    # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
    # mkdir /usr/local/python3
    # tar -xvJf  Python-3.6.6.tar.xz 
    (包从Python官网下载https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz)
    # cd Python-3.6.6
    # ./configure --prefix=/usr/local/python3
    # make && make install
    # ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
    # ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
    # pip3 install --upgrade pip
    # pip3 install --upgrade setuptools
    # cd  (返回根目录)
    

    1.2 安装Sass

    # pip3 install libsass (安装依赖库,若已安装无需执行)
    
    # yum install sassc
    

    1.3 安装wkhtmltopdf

    # yum install libXrender xorg-x11-fonts-75dpi xorg-x11-fonts-Type1 libXext libjpeg libpng 
    (若已安装了则无需再安装)     
    # rpm -ivh wkhtmltox-0.12.5-1.centos7.x86_64.rpm 
    (GitHub中https://github.com/wkhtmltopdf/wkhtmltopdf/releases下载在根目录即可)
    

    1.4 安装字体

    # yum install wqy*
    

    1.5 安装Postgresql数据库(Odoo12一定要PGSQL10,否则安装数据库的时候会出错)

    # yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
    # yum install postgresql10
    # yum install postgresql10-server
    # /usr/pgsql-10/bin/postgresql-10-setup initdb
    # systemctl enable postgresql-10
    # systemctl start postgresql-10
    # su - postgres -c "createuser -s odoo"
    

    第二步: 解压程序,安装Python组件及运行Odoo
    1.1 创建odoo用户及odoo用户组

    # groupadd odoo
    # adduser -g odoo -d /home/wwwroot/www.domain.com -m odoo (查看是否有/home/wwwroot文件夹,若没有则新增)
    # passwd odoo
    # *** (后面安装和登陆均会用到,请牢记!)
    

    1.2 授予odoo sudo权限

    # vi /etc/sudoers
    

    修改文件参考如下:

    ## Allow root to run any commands anywhere 
    root    ALL=(ALL:ALL) ALL
    odoo    ALL=(ALL:ALL) ALL (增加部分)
    

    保存退出,odoo用户就拥有了sudo权限。

    # reboot
    

    1.3 用odoo用户登陆SSH和WinSCP(SFTP)
    1.4 下载最新的程序包(默认登陆SSH在/home/odoo下面)

    # wget http://nightly.odoo.com/12.0/nightly/src/odoo_12.0.latest.tar.gz
    # tar –zxvf odoo_12.0.latest.tar.gz
    

    1.5 在WinSCP里面将odoo-12.post2018****文件夹的内容全部(含隐藏文件)copy到www.domain.com里面

    # cp -R /home/wwwroot/odoo-12.post2018****/. /home/wwwroot/www.domain.com 
    

    1.6 用SSH安装 Odoo所需的Python3组件.

    # cd ./www.domain.com
    # sudo pip3 install -r requirements.txt
    (根据git版的提示,建议在执行命令前在最后2行插入: 
    sphinx>=1.2
    sphinx-patchqueue>=1.0)
    

    1.7 进入odoo源码目录(/home/wwwroot/www.domain.com)运行odoo-bin (没有可以自行创建,并给与755权限, 内容可参考github里的对应文件)并生成配置文件.
    (备注,由于未改动原python2.X,因此需要修改odoo-bin第1行 #!/usr/bin/env python3为 #!/usr/bin/python3)

    # ./odoo-bin -s
    

    1.8 设置配置文件

    # sudo mkdir /etc/odoo
    # sudo cp /home/wwwroot/www.domain.com/.odoorc /etc/odoo/odoo.conf
    # sudo chown -R odoo:odoo /etc/odoo
    # sudo mkdir /var/log/odoo
    # sudo chown -R odoo:odoo /var/log/odoo
    

    1.9 编辑配置文件

    # sudo vi /etc/odoo/odoo.conf
    

    下面是2个建议增加的值 :

    [options]
    logfile = /var/log/odoo/odoo.log
    logrotate = True
    

    1.10 创建开机启动odoo

    # sudo vi /lib/systemd/system/odoo.service
    

    内容如下:

    [Unit]
    Description=Odoo
    After=postgresql-10.service
    [Service]
    Type=simple
    User=odoo
    Group=odoo
    ExecStart=/home/wwwroot/www.domain.com/odoo-bin -c /etc/odoo/odoo.conf
    [Install]
    WantedBy=multi-user.target
    

    注册新的服务:

    # sudo systemctl enable odoo.service
    

    开启这个新服务:

    # sudo systemctl start odoo
    

    检查它的状态:

    # sudo systemctl status odoo
    

    重启这个服务:

    # sudo systemctl restart odoo
    

    若显示如下内容则表示运行成功了:

    ● odoo.service - Odoo
       Loaded: loaded (/lib/systemd/system/odoo.service; enabled; vendor preset: enabled)
       Active: active (running) since Sun 2018-10-10 10:46:54 CST; 6s ago
     Main PID: 930 (python3)
       CGroup: /system.slice/odoo.service
               └─930 python3 /home/wwwroot/www.domain.com/odoo-bin -c /etc/odoo/odoo.conf
    

    如果您希望停止它,使用下面的命令:

    # sudo systemctl stop odoo
    

    也可以用 service odoo start 和 service odoo stop 来开启停止服务。
    现在可以确认我们的Odoo实例启动了,并能响应请求。
    如果Odoo正常运行,我们可以在日志文件中获得信息。我们可以检查Odoo是否响应HTTP请求:

    # curl http://localhost:8069
    

    要检查日志文件,我们可以使用:

    # sudo less /var/log/odoo/odoo.log (Q键退出)
    

    您还可以使用tail -f:

    # sudo tail -f /var/log/odoo/odoo.log (Ctrl+C退出)
    

    1.11 登录IP:8069, 按照提示安装数据库即可正常运行odoo
    1.12 安装好niginx并设置好vhost(建议用oneinstack的openresty)后, 将/usr/local/openresty/nginx/conf/vhost/www.domain.com备份,然后用下面的代码更换后重启服务器即可用域名访问(建议https).
    Nginx代码如下:

    upstream odoo12 {
        server 127.0.0.1:8069 weight=1 fail_timeout=0;
    }
    
    upstream odoo12-im {
        server 127.0.0.1:8072 weight=1 fail_timeout=0;
    }
    
    server {
      listen 80;
      listen 443 ssl http2;
      ssl_certificate /usr/local/openresty/nginx/conf/ssl/www.domain.com.crt;
      ssl_certificate_key /usr/local/openresty/nginx/conf/ssl/www.domain.com.key;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
      ssl_prefer_server_ciphers on;
      ssl_session_timeout 10m;
      ssl_session_cache builtin:1000 shared:SSL:10m;
      ssl_buffer_size 1400;
      add_header Strict-Transport-Security max-age=15768000;
      ssl_stapling on;
      ssl_stapling_verify on;
      server_name www.domain.com domain.com;
      access_log /home/wwwlogs/www.domain.com_nginx.log combined;
      error_log /home/wwwlogs/www.domain.com_nginx_err.log notice;
      index index.html index.htm index.php;
      root /home/wwwroot/www.domain.com;
      if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
      if ($host != www.domain.com) {  return 301 $scheme://www.domain.com$request_uri;  }
      include /usr/local/openresty/nginx/conf/rewrite/none.conf;
      #error_page 404 /404.html;
      #error_page 502 /502.html;
      
      #increase proxy buffer to handle some OpenERP web requests 
            proxy_buffers 16 64k;
            proxy_buffer_size 128k;
    
            #general proxy settings
            #force timeouts if the backend dies
            proxy_connect_timeout 600s;
            proxy_send_timeout 600s;
            proxy_read_timeout 600s;
    
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
    
            #set headers
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    
            #Let the OpenERP web service know that we’re using HTTPS, otherwise
            #it will generate URL using http:// and not https://
            proxy_set_header X-Forwarded-Proto https;
    
            #by default, do not forward anything
            proxy_redirect off;
            proxy_buffering off;
    
            location / {
            proxy_pass http://odoo12;
            }
    
            location /longpolling {
            proxy_pass http://odoo12-im;
            }
    
            #cache some static data in memory for 60mins.
            #under heavy load this should relieve stress on the OpenERP web interface a bit.
    
            location /web/static/ {
            proxy_cache_valid 200 60m;
            proxy_buffering on;
            expires 864000;
            proxy_pass http://odoo12;
            }
    }
    

    备注: 已根据1楼的朋友更新教程, 欢迎大家随时交流, 我的QQ:65016198. 谢谢.
    0_1539236432429_odoo12.png


  • 管理员

    @mugua 很棒,如果能用markdown语法编辑一下帖子就更赞👍了。

    另外,安装lessc的部分不对,Odoo V12 使用Sass不再使用Less,所以只要安装sassc就可以了:

    yum install sassc
    


  • @digitalsatori
    谢谢,已根据您的建议修正教程并Markdown了...



  • @mugua
    根据你的安装了sass,检查是否安装成功如下截图。但是在启动odoo12新建数据库的时候报错如下,请教下,安装了sass后,sassc命令还是不能生效的,哪里出问题?

    0_1539656940310_Screenshot from 2018-10-16 10-28-46.png

    '''
    2018-10-16 02:27:37,033 2747 WARNING test_v12 odoo.addons.base.models.assetsbundle: Could not execute command 'sassc'This error occured while compiling the bundle 'web.assets_common' containing:
    - /web/static/lib/bootstrap/scss/_functions.scss
    - /web/static/lib/bootstrap/scss/_mixins.scss
    - /web/static/src/scss/utils.scss
    - /web/static/src/scss/bs_mixins_overrides.scss
    - /web/static/src/scss/primary_variables.scss
    - /web_editor/static/src/scss/web_editor.variables.scss
    - /web/static/src/scss/secondary_variables.scss
    - /web/static/lib/bootstrap/scss/_variables.scss
    - /web/static/src/scss/fonts.scss
    - /web/static/src/scss/ui.scss
    - /web/static/src/scss/ui_extra.scss
    - /web/static/src/scss/navbar.scss
    - /web/static/src/scss/mimetypes.scss
    - /web/static/src/scss/modal.scss
    - /web/static/src/scss/animation.scss
    - /web/static/src/scss/rainbow.scss
    - /web/static/src/scss/datepicker.scss
    - /web/static/src/scss/banner.scss
    - /web/static/src/scss/colorpicker.scss
    - /web/static/src/scss/keyboard.scss
    - /web_tour/static/src/scss/tip.scss
    - /web_tour/static/src/scss/keyframes.scss
    2018-10-16 02:27:37,286 2747 WARNING test_v12 odoo.addons.base.models.assetsbundle: Could not execute command 'sassc'This error occured while compiling the bundle 'web.assets_backend' containing:
    - /web/static/lib/bootstrap/scss/_functions.scss
    - /web/static/lib/bootstrap/scss/_mixins.scss
    - /web/static/src/scss/utils.scss
    - /web/static/src/scss/bs_mixins_overrides.scss
    - /web/static/src/scss/primary_variables.scss
    - /web_editor/static/src/scss/web_editor.variables.scss
    - /web/static/src/scss/secondary_variables.scss
    - /web/static/src/scss/bootstrap_overridden.scss
    - /web_editor/static/src/scss/bootstrap_overridden.scss
    - /web/static/src/scss/import_bootstrap_part1.scss
    - /web/static/src/scss/bs_mixins_overrides.scss
    - /web/static/src/scss/import_bootstrap_part2.scss
    - /web/static/src/scss/bootstrap_review.scss
    - /web/static/lib/tempusdominus/tempusdominus.scss
    - /web/static/src/scss/webclient_extra.scss
    - /web/static/src/scss/webclient_layout.scss
    - /web/static/src/scss/webclient.scss
    - /web/static/src/scss/domain_selector.scss
    - /web/static/src/scss/model_field_selector.scss
    - /web/static/src/scss/progress_bar.scss
    - /web/static/src/scss/dropdown.scss
    - /web/static/src/scss/dropdown_extra.scss
    - /web/static/src/scss/tooltip.scss
    - /web/static/src/scss/debug_manager.scss
    - /web/static/src/scss/control_panel.scss
    - /web/static/src/scss/fields.scss
    - /web/static/src/scss/fields_extra.scss
    - /web/static/src/scss/views.scss
    - /web/static/src/scss/pivot_view.scss
    - /web/static/src/scss/graph_view.scss
    - /web/static/src/scss/form_view.scss
    - /web/static/src/scss/form_view_extra.scss
    - /web/static/src/scss/list_view.scss
    - /web/static/src/scss/list_view_extra.scss
    - /web/static/src/scss/kanban_dashboard.scss
    - /web/static/src/scss/kanban_examples_dialog.scss
    - /web/static/src/scss/kanban_column_progressbar.scss
    - /web/static/src/scss/kanban_view.scss
    - /web/static/src/scss/kanban_view_mobile.scss
    - /web/static/src/scss/web_calendar.scss
    - /web/static/src/scss/search_view.scss
    - /web/static/src/scss/search_view_mobile.scss
    - /web/static/src/scss/dropdown_menu.scss
    - /web/static/src/scss/search_view_extra.scss
    - /web/static/src/scss/data_export.scss
    - /base/static/src/scss/onboarding.scss
    - /web/static/src/scss/base_settings.scss
    - /web/static/src/scss/report_backend.scss
    - /base_import/static/src/scss/base_import.scss
    - /web_diagram/static/src/scss/diagram_view.scss
    - /web_editor/static/src/scss/web_editor.common.scss
    - /web_editor/static/src/scss/web_editor.backend.scss
    - /web_settings_dashboard/static/src/scss/dashboard.scss
    2018-10-16 02:27:37,390 2747 WARNING test_v12 odoo.addons.base.models.assetsbundle: Could not execute command 'sassc'This error occured while compiling the bundle 'web_editor.assets_editor' containing:
    - /web/static/lib/bootstrap/scss/_functions.scss
    - /web/static/lib/bootstrap/scss/_mixins.scss
    - /web/static/src/scss/utils.scss
    - /web/static/src/scss/bs_mixins_overrides.scss
    - /web/static/src/scss/primary_variables.scss
    - /web_editor/static/src/scss/web_editor.variables.scss
    - /web/static/src/scss/secondary_variables.scss
    - /web/static/lib/bootstrap/scss/_variables.scss
    - /web_editor/static/src/scss/web_editor.ui.scss
    2018-10-16 02:27:37,451 2747 INFO test_v12 odoo.modules.registry: At least one model cache has been invalidated, signaling through the database.
    '''



  • @hui @mugua 解决。
    在以前的帖子中有人提出了解决方法的:链接文本

    解决方法:(权限不够的话,加个sudo,python3的可以使用pip3安装的)

    pip install libsass
    


  • 你好 请教下 跟着步骤安装 出现以下问题,怎么解决? 谢谢

    [[email protected] ~]# sudo systemctl status odoo
    ● odoo.service - Odoo
    Loaded: loaded (/usr/lib/systemd/system/odoo.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Wed 2018-10-17 20:54:47 CST; 13min ago
    Process: 859 ExecStart=/home/wwwroot/crazytoucan.com/odoo-bin -c /etc/odoo/odoo.conf (code=exited, status=203/EXEC)
    Main PID: 859 (code=exited, status=203/EXEC)

    Oct 17 20:54:47 li1079-129.members.linode.com systemd[1]: Started Odoo.
    Oct 17 20:54:47 li1079-129.members.linode.com systemd[1]: Starting Odoo...
    Oct 17 20:54:47 li1079-129.members.linode.com systemd[859]: Failed at step EXEC spawning /home/wwwroot...ed
    Oct 17 20:54:47 li1079-129.members.linode.com systemd[1]: odoo.service: main process exited, code=exit...EC
    Oct 17 20:54:47 li1079-129.members.linode.com systemd[1]: Unit odoo.service entered failed state.
    Oct 17 20:54:47 li1079-129.members.linode.com systemd[1]: odoo.service failed.
    Hint: Some lines were ellipsized, use -l to show in full.



  • @mark7788阿里云部署 CentOS7.4+Python3.6+Postgresql10+Odoo12+OpenResty1.13(Nginx1.13) 实例教程 中说:

    Failed at step EXEC spawning /home/wwwroo

    把错误贴出来. 应该是这句错误导致的:
    Failed at step EXEC spawning /home/wwwroo....



  • @hui ,我的在安装Python3.6的时候已经安装了libsass...



  • @mugua 我的是python3.5。你是自己有意识的安装的libsass吗?



  • @hui 我装PY3.6的时候已经装好了,因此无需再安装.



  • @hui , 今天帮客户安装的时候就需要单独安装依赖包,因此我的教程也修改了下,谢谢你的提醒.



  • 2018-11-12 08:01:36,192 20761 INFO ? odoo.service.server: HTTP service (werkzeug) running on izj6ci10z86qmo44g0o5i6z:8069

    装到这一步卡了好久,不知道怎么回事。



  • @zhangodoo
    2018-11-18 02:37:40,454 3422 INFO ? odoo.service.server: HTTP service (werkzeug) running on localhost.localdomain:8069
    我也是执行./odoo-bin -s 后就一直停在那里,不动了



  • @CTF20007 @zhangodoo @mark7788 这个教程有个BUG,如果按照教程中所交代的从http://nightly.odoo.com/12.0/nightly/src/odoo_12.0.latest.tar.gz这里下载的odoo12安装包里面有一个坑,就是在odoo安装源中是不包含odoo-bin这个执行脚本的,所以你们在最后启动时会卡在Process: 859 ExecStart=/home/wwwroot/crazytoucan.com/odoo-bin -c /etc/odoo/odoo.conf (code=exited, status=203/EXEC)
    Main PID: 859 (code=exited, status=203/EXEC)这里,因为那里根本就没有odoo-bin文件。解决方法其实很简单,vi odoo-bin 创建一个odoo-bin文件,手动添加如下全部内容:
    #!/usr/bin/env python3

    set server timezone in UTC before time module imported

    import('os').environ['TZ'] = 'UTC'
    import odoo

    if name == "main":
    odoo.cli.main()

    保存退出后还要给odoo-bin提权,所以运行chmod +x odoo-bin命令即可。好了现在你可以reboot一下,odoo12就可以跑起来了。其实还有另一个解决方法更简单,那就是不要从nightly.odoo.com下载源,改为从Odoo GitHub存储库中克隆Odoo 12源代码:
    git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo12/odoo
    这个克隆代码里面原生带好了odoo-bin文件,不会出现上述问题,但是git在国内访问速度非常慢,你需要梯子。



  • @warlocks 我教程里面写了,若没有可以自行创建,rpm包里面有,但是tar包里没有,所以要自行创建。