首页 > 解决方案 > 无法使用 apache2 mod_wsgi 设置 odoo

问题描述

我在 ubunu 18.04 (apache2) 上设置 odoo v13 时遇到问题

我能够通过 odoo-bin 进行测试/开发,但试图从我的本地机器上运行它(我们的网络上有一个代理,但现在我想让它运行,所以我可以得到它)我将 odoo.conf 设置为吐出错误 odoo-error.log 很好,它确实吐出了一些错误。但只有在systemctl restart apache2 那之后它才会停止

从守护进程“管理员”收到的截断或过大的响应标头:/opt/odoo13/E-Forms/odoo/setup/odoo-wsgi.py

我完成了对目录的所有权限访问,但我发现 apache 奇怪的是在默认错误文件中我得到了这个

致命的 Python 错误:Py_Initialize:无法获取语言环境编码 ModuleNotFoundError:没有名为“编码”的模块

如果我告诉虚拟主机嘿把我所有的错误都放在 odoo-error.log 中,它的连续性让我感到困惑,为什么 error.log 仍然不断被填充,但我希望这与我的问题无关

这是我的会议

    ServerName test.eforms.com
    ServerAlias test.eforms.com 127.0.0.1

    ErrorLog ${APACHE_LOG_DIR}/odoo-error.log
    CustomLog ${APACHE_LOG_DIR}/odoo-access.log combined
    LogLevel info

    <Directory /opt/odoo13/E-Forms>
        Require all granted
    </Directory>
    <Directory /opt/odoo13/E-Forms/odoo/setup>
        <Files odoo-wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess admin user=admin group=admin processes=1 python-home=/opt/odoo13/Venv/odoovenv/bin/ python-path=/opt/odoo13/E-Forms/odoo
    WSGIProcessGroup admin
    WSGIScriptAlias / /opt/odoo13/E-Forms/odoo/setup/odoo-wsgi.py
    WSGIApplicationGroup %{GLOBAL}

</VirtualHost>

这是我的 odoo-wsgi.py (这是克隆的副本)

import odoo

#----------------------------------------------------------
# Common
#----------------------------------------------------------
odoo.multi_process = True # Nah!
# Equivalent of --load command-line option
odoo.conf.server_wide_modules = ['base','web']
conf = odoo.tools.config
# Path to the OpenERP Addons repository (comma-separated for
# multiple locations)
conf['addons_path'] = '/opt/odoo13/E-Forms/odoo/addons,/opt/odoo13/E-Forms/odoo/custom'
# Optional database config if not using local socket
conf['db_name'] = 'EForm'
conf['db_host'] = 'localhost'
conf['db_user'] = 'odoo'
conf['db_port'] = 5432
conf['db_password'] = 'password'
#----------------------------------------------------------
# Generic WSGI handlers application
#----------------------------------------------------------
application = odoo.service.wsgi_server.application

odoo.service.server.load_server_wide_modules()
#----------------------------------------------------------
# Gunicorn
#----------------------------------------------------------
# Standard OpenERP XML-RPC port is 8069
bind = '127.0.0.1:80'
pidfile = '.gunicorn.pid'
workers = 1
timeout = 1200

和我的 apache2.conf 这里

ServerName test.eforms.com


DefaultRuntimeDir ${APACHE_RUN_DIR}


PidFile ${APACHE_PID_FILE}

Timeout 900


KeepAlive On


MaxKeepAliveRequests 100


KeepAliveTimeout 5

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}


HostnameLookups On

ErrorLog ${APACHE_LOG_DIR}/error.log


#LogLevel info

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf



<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

AccessFileName .htaccess


<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LoadModule wsgi_module modules/mod_wsgi.so

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent


# see README.Debian for details.


IncludeOptional conf-enabled/*.conf


IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我从源代码下载了 mod_wsgi.so 并安装它下面是所有已安装 apt 包的列表,仅适用于 apache2

apache2/bionic-updates,bionic-security,now 2.4.29-1ubuntu4.11 amd64 [installed] apache2-bin/bionic-updates,bionic-security,now 2.4.29-1ubuntu4.11 amd64 [installed,automatic] apache2-数据/仿生更新,仿生更新,仿生安全,仿生安全,现在 2.4.29-1ubuntu4.11 所有 [已安装,自动] apache2-dev/bionic-updates,仿生安全,现在 2.4.29-1ubuntu4 .11 amd64 [已安装] apache2-utils/bionic-updates,bionic-security,现在 2.4.29-1ubuntu4.11 amd64 [已安装,自动] libapache2-mod-wsgi-py3/bionic,现在 4.5.17-1 amd64 [安装]

我的点子冻结

Babel==2.3.4 certifi==2019.9.11 chardet==3.0.4 decorator==4.0.10 Django==2.2.6 docopt==0.6.2 docutils==0.12 h11==0.8.1 h2==3.1 .1 hpack==3.0.0 html2text==2019.9.26 hyperframe==5.2.0 idna==2.8 image==1.5.27 Jinja2==2.10.3 libsass==0.19.3 lxml==4.4.1 MarkupSafe= =1.1.1 num2words==0.5.10 passlib==1.7.1 Pillow==6.2.0 pkg-resources==0.0.0 polib==1.1.0 psutil==5.6.3 psycogreen==1.0.1 psycopg2= =2.8.4 psycopg2-binary==2.8.4 pyasn1==0.4.7 pyasn1-modules==0.2.7 pyldap==3.0.0.post1 PyPDF2==1.26.0 python-dateutil==2.8.0 python- ldap==3.2.0 python-openid==2.2.5 python-stdnum==1.11 pytz==2016.7 reportlab==3.5.28 requests==2.22.0 rfc3986==1.3.2 六==1.12.0 sqlparse= =0.3.0 urllib3==1.25.6 Werkzeug==0.16.0 xlwt==1.3.0

标签: deploymentapache2odoomod-wsgiodoo-13

解决方案


经过三天的挠头,我终于发现了问题,就是这条线

python-home=/opt/odoo13/Venv/odoovenv/bin/

应该是这个

python-home=/opt/odoo13/Venv/odoovenv/

所以任何人将来都会遇到这样的问题,这里有一些建议

  • 仔细检查您的 mod_wsgi 是否使用与您的 virtualenv 相同版本的 python
  • 确保更新所有软件包(我使用 ubuntu,这样会很合适)
  • 确保 wsgiprocessgroup 具有您托管应用程序的目录和SUB DIRECTORIES的所有 rwx(可能不是 write )

推荐阅读