我提到了以下三个链接,将python升级到3.6.3版本并创建虚拟环境,然后尝试通过nginx / uwsgi服务器django。但是,我正在努力解决这个错误,并且#34;没有名为编码的模块"。 如果我使用下面的命令,那么可以访问django。但是,如果在配置文件上运行,它将引发错误,说“#34;没有名为编码的模块"。
"uwsgi --http :8080 --home /home/testuser1/myproject --chdir
/home/testuser1/myprojecttss -w myprojecttss.wsgi
"
错误日志:
(myproject) [test@VM_134_114_centos ~]$ systemctl status uwsgi -l
* uwsgi.service - uWSGI Emperor service
Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2018-01-20 20:29:47 CST; 9min ago
Main PID: 11381 (uwsgi)
Status: "The Emperor is governing 0 vassals"
CGroup: /system.slice/uwsgi.service
`-11381 /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: uwsgi socket 0 bound to UNIX address /run/uwsgi/myprojecttss.sock fd 3
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: uWSGI running as root, you can use --uid/--gid/--chroot options
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: setuid() to testuser1
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: Python version: 3.6.3 (default, Jan 17 2018, 14:02:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: Set PythonHome to /home/testuser1/myproject
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: Fatal Python error: Py_Initialize: Unable to get the locale encoding
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: ModuleNotFoundError: No module named 'encodings'
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: Current thread 0x00007fb1c7a04840 (most recent call first):
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: Sat Jan 20 20:38:16 2018 - [emperor] curse the uwsgi instance myprojecttss.ini (pid: 12256)
Jan 20 20:38:16 VM_134_114_centos uwsgi[11381]: Sat Jan 20 20:38:16 2018 - [emperor] removed uwsgi instance myprojecttss.ini
uwsgi配置文件:
[uwsgi]
project = myprojecttss
username = testuser1
base = /home/%(username)
env = myproject
chdir = %(base)/%(project)
module = %(project).wsgi
home = %(base)/%(env)
##module = %(project).wsgi:application
master = true
processes = 5
binary-path = %(base)/%(env)/bin/uwsgi
#virtualenv = %(base)/%(env)
uid = %(username)
socket = /run/uwsgi/%(project).sock
chown-socket = %(username):nginx
chmod-socket = 775
vacuum = true
die-on-term = true
uwsgi服务:
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStartPre=-/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown testuser1:nginx /run/uwsgi'
ExecStart=/usr/bin/bash -c 'cd /home/testuser1/myprojcettss; source /home/testuser1/myproject/bin/activate; uwsgi --ini /etc/uwsgi/sites/myprojecttss.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target