Apache 2.4.1配置

时间:2012-05-18 06:12:21

标签: apache

我面临一个独特的问题。我已经设置了Apache 2.4.1,以下是我的配置:

ServerRoot "prakash_prasad/bin"
AddHandler cgi-script .py
ScriptAlias /~prakash_prasad/ "/x/home/prakash_prasad/public_html/"
ScriptAlias /test/ "/x/test/prakash_prasad/public_html/"
DocumentRoot "/mybox/prakash_prasad/bin/htdocs"
<Directory "/x/test/*/public_html/">
    Options +ExecCGI
    Options ExecCGI
    Order allow,deny
    Allow from all
    Options All
    SetHandler cgi-script
    AddHandler cgi-script .py
    AllowOverride None
    Require all granted
    AddHandler cgi-script .py
    SetHandler cgi-script
    AllowOverride None
    Require all granted
    Options ExecCGI
    Order allow,deny
    Allow from all
    Options All
    SetHandler cgi-script
    AddHandler cgi-script .py
    AllowOverride None
    Require all granted
</Directory>

<Directory "/x/home/prakash_prasad/public_html/*">
    Options +ExecCGI
    Options ExecCGI
    Order allow,deny
    Allow from all
    Options All
    SetHandler cgi-script
    AddHandler cgi-script .py
    AllowOverride None
    Require all granted
    AddHandler cgi-script .py
    SetHandler cgi-script
    AllowOverride None
    Require all granted
</Directory>

现在我有一个示例'first.py'程序转储“Hello World!”我在浏览器中输入以下网址时工作正常

  

的http://:IP /测试/ first.py

但是当我尝试加载HTML页面时:

  

的http://:IP /测试/ index.html中

我在浏览器中遇到以下错误:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请通过you@example.com与服务器管理员联系,告知他们此错误发生的时间以及您在此错误发生之前执行的操作。

服务器错误日志中可能提供了有关此错误的更多信息。

在LOGS中我看到:

[Thu May 17 23:07:10.664648 2012] [cgid:error] [pid 10386:tid 47977877412864] (13)Permission denied: AH01241: exec of '/x/test/prakash_prasad/public_html/index.html' failed
[Thu May 17 23:07:10.665034 2012] [cgid:error] [pid 9849:tid 1232931136] [client 10.239.40.209:54712] End of script output before headers: index.html

请告诉我需要纠正的配置?

:: UPDATES ::

我缩小到一定程度,但不确定问题可能是:

当我发表评论时,cgid模块为我解决了这个问题:

# LoadModule cgid_module modules/mod_cgid.so

我的HTML页面很好但不是我的Python脚本

虽然我取消注释

LoadModule cgid_module modules/mod_cgid.so

我的脚本运行正常但HTML文件错误。

知道问题是什么?

2 个答案:

答案 0 :(得分:2)

使用“Options + ExecCGI”指令,webserver会将public_html下的所有文件视为可执行文件。所以你必须将你的opython文件放在一个单独的目录中

ScriptAlias /pyfiles/ /home/x/public_html/pyfiles/

然后把你的htmls /home/x/public_html/

答案 1 :(得分:0)

尝试删除配置中的重复指令,因为这些可能导致问题,即第一个目录:

<Directory "/x/test/*/public_html/">
    Options +ExecCGI
    Options ExecCGI
    Order allow,deny
    Allow from all
    Options All
    SetHandler cgi-script
    AddHandler cgi-script .py
    AllowOverride None
    Require all granted
</Directory>