简体   繁体   English

如何设置TERM环境变量Apache + mod_wsgi + django

[英]How to set TERM environment variable Apache + mod_wsgi + django

I used Apache + mod_wsgi in my Ubuntu 12.04 LTS in deploying my django application. 在部署django应用程序时,我在Ubuntu 12.04 LTS中使用了Apache + mod_wsgi。 Set-up and deployment is OK, given that the method in views.py returns a value when I access the URL associated with it. 设置和部署是可以的,因为当我访问与其关联的URL时,views.py中的方法会返回一个值。 And also, there are no errors in the Apache error.log. 而且,Apache error.log中没有错误。

However, when I added an: 但是,当我添加一个:

os.system("java -jar <java application name>")

to the method implementation in the views.py, a "TERM environment variable set" is displayed on Apache's error log, and the java applications is not executed. 对于views.py中的方法实现,在Apache的错误日志上显示“ TERM环境变量集” ,并且不执行Java应用程序。 The java application, when successfully ran, outputs a simple text file. Java应用程序成功运行后,将输出一个简单的文本文件。 But as expected (and since the java app was not executed), no text file was generated. 但是正如预期的那样(并且由于未执行Java应用),没有生成文本文件。

Having that explained, my question is How will I properly set the TERM environment variable to successfully run the java application? 解释完之后 ,我的问题是如何正确设置TERM环境变量以成功运行Java应用程序? I already tried this: 我已经试过了:

SetEnv TERM /usr/bin/xterm

but it did not solve the problem. 但这并不能解决问题。 I also tried these 2: 我也尝试了这些2:

SetEnv TERM /usr/bin/xterm:$PATH
SetEnv TERM /bin/bash

but again, it did not work. 但同样,它没有用。 Hoping to hear your ideas. 希望听到您的想法。 Thanks in advance! 提前致谢!

When having issues executing sub processes from mod_wsgi, have never seen TERM as being an issue before and is generally for other reasons. 当在执行来自mod_wsgi的子进程时遇到问题时,以前从未将TERM视为问题,并且通常是出于其他原因。

If you still believe it is non existence of TERM in your environment, then in your WSGI script file add: 如果您仍然认为环境中不存在TERM,请在WSGI脚本文件中添加:

import os
os.environ['TERM'] = 'xterm'

Note though that TERM isn't set to either a path or even a single executable, but a terminal type. 请注意,尽管TERM既不是设置为路径,也不是单个可执行文件,而是终端类型。 Would suggest you go read up about what TERM is even for. 建议您去阅读一下TERM的用途。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM