简体   繁体   English

配置php以通过require识别shebang

[英]configure php to recognize shebang by require

I want to do something like that in php (running on apache2): 我想在php中运行(在apache2上运行):

require("somecgi.py")

where somecgi.py is a python file with a valid shebang. somecgi.py是一个有效shebang的python文件。 My apache is configured to execute the cgi-script when opened directly in brower. 我的apache配置为在brower中直接打开时执行cgi脚本。 But i can't bring php to recognize the script as a cgi-script and instead inserts the source code of the script. 但我不能让php将脚本识别为cgi脚本,而是插入脚本的源代码。 For campatibility with text based browsers i don't want to use frames. 对于基于文本的浏览器的可营性,我不想使用框架。 I googled about that problem and found that there is a configuration option cgi.check_shebang_line. 我搜索了这个问题,发现有一个配置选项cgi.check_shebang_line。 I think this could be related to that, but i'm also very new to php and don't kno where to set this option. 我认为这可能与此有关,但我也是非常新的PHP,并不知道在哪里设置此选项。

My OS: linuxmint KDE 14 (Kubuntu 12.10 derivate) 我的操作系统:linuxmint KDE 14(Kubuntu 12.10衍生)

Read up on require / include . 阅读require / include It will execute php code, not python code. 它将执行PHP代码,而不是python代码。 In order to execute the python code you will need to run a shell_exec type command from php, which should execute the python code like you would call it from the shell. 为了执行python代码,你需要从php运行一个shell_exec类型的命令,它应该像你从shell中调用它一样执行python代码。

The gist, the include / require options are used for including php files to be parsed by the php engine. gist,include / require选项用于包含要由php引擎解析的php文件。 Including random files with commands that are not php will attempt to parse the file using the php engine. 包含非php命令的随机文件将尝试使用php引擎解析文件。

EDIT 编辑

If the shell_exec is not what you are looking for, maybe a redirect is or you may have to elaborate on your question to get down to what you really need. 如果shell_exec不是您正在寻找的,可能是重定向,或者您可能需要详细说明您的问题以了解您真正需要的内容。

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

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