如何使apache运行pyc文件

如何使apache运行pyc文件

本文介绍了如何使apache运行pyc文件(python编译文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在linux上使用apache2和python2.6.

I am using apache2 and python2.6 on linux.

我知道如何使apache运行* .py文件,只需将"AddHandler cgi-script .cgi .py"添加到httpd.conf文件中.但是如何使apache2运行* .pyc文件?

I know how to make apache run a *.py file, just add "AddHandler cgi-script .cgi .py" to httpd.conf file. But how to make apache2 run a *.pyc file?

添加"AddHandler cgi-script .cgi .pyc"无效.

Adding "AddHandler cgi-script .cgi .pyc" is not working.

我听说mod_python可以同时启用* .pyc和* .pyo在apache上运行.谁能告诉我mod_python是怎么做到的?

I've heard that mod_python can enable both *.pyc and *.pyo run on apache. Could anybody tell me how does mod_python make it?

顺便说一句,我目前不想学习mod_python或WSGI ...

By the way in the current I don't want to learn mod_python or WSGI...

谢谢大家!

推荐答案

问题在于httpd不知道如何运行.pyc文件,因为与.py文件(带有其shebang行)不同,.pyc该文件不包含有关应如何运行的信息.您将需要使用 binfmt_misc 来指导Linux如何运行.pyc文件.并且不要忘记使文件本身也可以执行.

The problem is that httpd doesn't know how to run a .pyc file, since unlike a .py file (with its shebang line), a .pyc file contains no information on how it should be run. You will need to use binfmt_misc to instruct Linux on how to run a .pyc file. And don't forget to make the file itself executable as well.

这篇关于如何使apache运行pyc文件(python编译文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 06:56