Odoo 部署windows server 2012
需要安装前置补丁
clearcompressionflag.exe、KB2919442、KB2919355、KB2932046、KB2959977、KB2937592、KB2938439、KB2934018。
使用odoo14官网安装包
地址:https://www.odoo.com/zh_CN/page/download
NSSM运行Nginx
下载新版的nginx-window http://nginx.org/en/download.html
系统找不到nssm则切到odoo安装目录下nssm\x64或\86下运行
注册服务 路径为nginx.exe的路径
nssm install Nginx "D:\Program Files\Odoo 14.0.20210710\nginx-1.21.3\nginx.exe"
运行服务
nssm start Nginx
停止服务
nssm stop Nginx
移除服务
nssm remove Nginx
nignx.conf配置文件
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 1800;
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
gzip on;
upstream odoo {
server 127.0.0.1:8069 fail_timeout=3000s;
}
upstream odoopoll {
server 127.0.0.1:8072 fail_timeout=3000s;
}
server {
listen 80;
server_name localhost;
charset utf-8;
access_log off;
location / {
proxy_pass http://odoo;
client_body_timeout 1200s;
proxy_connect_timeout 1200s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /longpolling/ {
proxy_set_header Host $host:8072;
proxy_pass http://odoopoll/longpolling/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 3600s;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
send_timeout 3600;
}
location ~* /[0-9a-zA-Z_]*/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo;
}
client_header_buffer_size 512k;
large_client_header_buffers 4 512k;
}
}
NSSM重启odoo
nssm restart odoo-server-14.0
问题汇总
安装后 localhost:8069无法显示此页,且server/odoo.log 中出现odoo.service.server: Initiating shutdown
原因:
创建项目是创建数据库连接时用户名/密码进行自定义, 造成的odoo连接不上数据库导致的初始化失败
代码运行时报错提示ValueError : embeddednullbyte
解决:
找到 项目文件夹/python/Lib/_strptime.py 文件,在文件的最前面部分,找到如下内容,追加一行locale.setlocale(locale.LC_ALL,'en')
后重启项目
"""Strptime-related classes and functions.
CLASSES:
LocaleTime -- Discovers and stores locale-specific time information
TimeRE -- Creates regexes for pattern matching a string of text containing
time information
FUNCTIONS:
_getlang -- Figure out what language is being used for the locale
strptime -- Calculates the time struct represented by the passed-in string
"""
import time
import locale
import calendar
from re import compile as re_compile
from re import IGNORECASE
from re import escape as re_escape
from datetime import (date as datetime_date,
timedelta as datetime_timedelta,
timezone as datetime_timezone)
try:
from _thread import allocate_lock as _thread_allocate_lock
except ImportError:
from _dummy_thread import allocate_lock as _thread_allocate_lock
# 追加一行
locale.setlocale(locale.LC_ALL,'en')
__all__ = []