在Python WSGI环境中运行PHP脚本(Running a PHP script inside a Python WSGI enviroment)

编程入门 行业动态 更新时间:2024-10-26 16:26:58
在Python WSGI环境中运行PHP脚本(Running a PHP script inside a Python WSGI enviroment)

我有一个简单的PHP脚本,输出XML格式的dir列表。 我用它来让Flash幻灯片显示哪些文件可用。

我刚刚将Flash添加到由Django支持的网站,并且PHP文件现在按原样提供,而不是解析。

它位于我的媒体目录下的图像目录中。

我使用的服务器运行plesk,所以我在vhost.conf文件中为每个域配置我的配置(它被包含在我认为的主要appache conf中)

它看起来像这样:

WSGIScriptAlias / /var/www/vhosts/<domain>/conf/django.wsgi Alias /media/ /var/www/vhosts/<domain>/httpdocs/media/

我认为这意味着任何在/下的请求都会通过django来处理。 除了当他们用于/ media / ...时,它们都是由apache正常从指定的目录服务的。

这适用于图像,但不解析PHP文件。

我该怎么办?

I have a simple PHP script that outputs a dir listing in XML format. I use it to let a flash slideshow know what files are available to show.

I've just added the flash to a website that's powered by Django and the PHP file is now served up as it is, not parsed.

It's in the directory with the images under my media directory.

The server I use runs plesk so I do my config for each domain in a vhost.conf file (which gets included into the main appache conf I think)

It looks like this:

WSGIScriptAlias / /var/www/vhosts/<domain>/conf/django.wsgi Alias /media/ /var/www/vhosts/<domain>/httpdocs/media/

I thought this meant that requests for anything under / are passed django to handle. Except when they are for /media/... then they are served by apache as normal from the specified dir.

That works for the images, but does not parse the PHP file.

What should I do?

最满意答案

也许阅读这个线程,并将你的PHP脚本移植到Python:

os.walk()python:一个目录结构的递归表示,递归

So it turns out the problem was two things, making it hard to find.

Thanks Ignacio Vazquez-Abrams, I had my lines the wrong way around.

Once that was solved, PHP would not serve my file because it was in a dir that was symlinked from outside the allowed path(s). I resolved this by turning off open_basedir restrictions for this vhost. My new vhost.conf is below.

<Directory /var/www/vhosts/<domain>/httpdocs> php_admin_flag engine on php_admin_value open_basedir none </Directory> Alias /media/ /var/www/vhosts/<domain>/httpdocs/media/ WSGIScriptAlias / /var/www/vhosts/<domain>/conf/django.wsgi

更多推荐

本文发布于:2023-07-22 18:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222285.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   环境   Python   WSGI   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!