`
zhanyingle_1981
  • 浏览: 321457 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Debian 6 Apache2 安装下 mod_wsgi

阅读更多

Debian Apache2 安装下 mod_wsgi:
下载源文件

./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/bin/python
[如果./configure 提示 apxs:command not found,要安装apache的dev包
apt-get install apache2-threaded-dev]
make
make install


在/etc/apache2/mods-available下创建文件mod_wsgi.load, 然后加入
LoadModule wsgi_module modules/mod_wsgi.so 保存

然后a2enmods mod_wsgi,将其加入/etc/apache2/mods-enable

【不知道为什么出现a2enmods: command not found 后来才发现/usr/sbin居然不在path中,奇怪。。。】

在/etc/apache2/apache.conf 下 添加:
WSGIScriptAlias /test /path/test.wsgi 其中path是test.wsgi的路径名


test.wsgi内容:
   def application(environ, start_response): 
       status = '200 OK'  
       output = 'Hello World!' 
    
       response_headers = [('Content-type', 'text/plain'), 
                           ('Content-Length', str(len(output)))] 
       start_response(status, response_headers) 
    
       return [output] 

重启apache2, sudo /etc/init.d/apache2 restart,然后访问http://localhost/test,显示“Hello World!”说明mod_wsgi安装完毕,并且正常。

 

接下来会看看如何把django project陪在Apache2下

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics