简体   繁体   English

无法从别名运行Perl脚本

[英]Perl scripts can't be run from an alias

I created the following Alias in httpd.conf: 我在httpd.conf中创建了以下别名:

alias /aliasedfolder /some/location/on/the/server/folder
<Location /aliasedfolder>
  AddHandler cgi-script .pl
  Options +FollowSymLinks +ExecCGI
  Order allow,deny
  Allow from all
  AllowOverride None
</Location>

The problem is that i can view images within "aliasedfolder" but i am getting a "file does not exist" error when i run a perl script there, eg /aliasedfolder/script.pl. 问题是我可以在“ aliasedfolder”中查看图像,但是当我在其中运行perl脚本(例如/aliasedfolder/script.pl)时遇到“文件不存在”错误。 The physical perl script exist in "/some/location/on/the/server/folder". 物理perl脚本位于“ / some / location / on / the / server / folder”中。 I made sure the script has 755 permission. 我确保脚本具有755权限。

Below is the contents of the perl script: 以下是perl脚本的内容:

#!/usr/bin/perl
use CGI qw/:standard/;
print "Content-type:text/html;\n\n";
print "Hello world";
1;

What seems to be the problem? 似乎是什么问题? Thanks 谢谢

After checking the ownership of /some/location/on/the/server/folder, I found out that the owner is the "root" username, whileas I was trying to access the folder through an account (domain name) on Apache that has a different username, eg domain.com/aliasedfolder/script.pl 在检查了/ some / location / on / the / server / folder的所有权后,我发现所有者是“ root”用户名,而当时我正试图通过Apache上具有以下名称的帐户(域名)访问该文件夹:不同的用户名,例如domain.com/aliasedfolder/script.pl

The suexec mechanism is preventing this as a security feature. suexec机制阻止了此操作的安全性。 So, I changed the ownership of the /some/location/on/the/server/folder and the script.pl file inside it from "root" to my account's username and group, and it is working now. 因此,我将/ some / location / on / the / server / folder的所有权和其中的script.pl文件的所有权从“ root”更改为我帐户的用户名和组,并且现在可以使用了。

This will prevent other domains pointing to my server from accessing this file (script.pl), as suexec prevents a single file to be shared by multiple domains (which have different usernames). 这将防止指向我的服务器的其他域访问此文件(script.pl),因为suexec阻止单个文件由多个域(具有不同用户名)共享。

I can disable the suexec mechanism altogether, but I was advised not to do so due to security concerns. 我可以完全禁用suexec机制,但是出于安全考虑,建议我不要这样做。

Thanks for all who tried to help. 感谢所有尝试提供帮助的人。

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

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