【发布时间】:2017-08-03 12:04:24
【问题描述】:
我的“controller.py”脚本
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
def application(environ, start_response):
# the ouput string to respuesta var
respuesta = "<p>Página web construida con <strong>Python!!!</strong></p>"
# generating the response OK
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
return respuesta
在'error.log'中:
[2017 年 3 月 13 日星期一 12:36:32.656669] [wsgi:error] [pid 28767:tid 139926041507584] [客户端 127.0.0.1:56382] mod_wsgi (pid=28767): 处理 WSGI 脚本时发生异常 '/var/www/python/app/controller.py'。 [2017 年 3 月 13 日星期一 12:36:32.656761]
[wsgi:error] [pid 28767:tid 139926041507584] [client 127.0.0.1:56382] TypeError:预期的字节字符串值序列,str 类型的值 发现 ubuntu@ip----:/var/www/python/logs$ TypeError: 预期的字节字符串值序列,找到类型 str 的值
我已阅读this questions,但答案无效。
我的站点.conf
<VirtualHost *:80>
ServerName app.salvaj.es
ServerAdmin salvajgb@salvaj.es
DocumentRoot /var/www/python/static
WSGIScriptAlias / /var/www/python/app/controller.py
ErrorLog /var/www/python/logs/error.log
CustomLog /var/www/python/logs/access.log combined
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/python/static>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
【问题讨论】:
-
你安装了mod-wsgi吗? sudo aptitude install libapache2-mod-wsgi
-
@PierangeloOrizio 是的,并通过
sudo a2enmod wsgi启用 -
你能发布虚拟主机配置吗?域.conf
-
@PierangeloOrizio 完成! site.conf 添加了
标签: linux python-3.x ubuntu apache2 mod-wsgi