问题在Apache执行CGI脚本 [英] Problem with Executing CGI Scripts on Apache

查看:213
本文介绍了问题在Apache执行CGI脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pretty在这里多一个完整的Linux / Apache的新手,我在从共享主机到VPS的Linode移动网站的过程。这一切都进展顺利,直到我开始尝试移动它运行使用一系列CGI脚本我活字印刷博客。我运行Ubuntu 10.04和Apache2的。后折腾了我得到了一个PERL的Hello World脚本(hello.cgi)从根HTML目录中的Web浏览器来执行的时间。这里的脚本:

 #!的/ usr / bin中/ perl的-w
使用严格的;
打印内容类型:text / html的\\ n \\ nHello的世界!

我通过添加下面的/etc/apache2/sites-available/mysitename.com文件得到了这个工作。

 <目录/srv/www/mysitename.com/public_html/>
    选项​​+ ExecCGI
    AddHandler的CGI脚本的CGI
< /目录>

但我想在/srv/www/mysitename.com/public_html/mt/目录下执行CGI脚本,所以我改变了目录中的条目上面这条道路时,我该文件夹中查看的hello world脚本通过浏览器我看到的hello.cgi脚本而不是输出端的源。显然,事情是不对的。我已经花了足够的时间更努力工作,这一点我自己,时间已经到了寻求帮助。因此,任何人有什么建议吗?请保持简单的答案,我真的很刚学踩水的Linux / Apache2的智慧在这里!

解决方案找到:

 <虚拟主机*:80>
  服务器名www.sitename.com
  的ServerAdmin general@sitename.com
  ServerAlias​​ sitename.com
  DocumentRoot的/srv/www/mysitename.com/public_html/
  错误日志/srv/www/mysitename.com/logs/error.log
  的CustomLog /srv/www/mysitename.com/logs/access.log结合
  AddHandler的CGI脚本的CGI特等
< /虚拟主机><目录/srv/www/mysitename.com/public_html/>
    所有的AllowOverride
    为了允许,拒绝
    所有允许
    选项​​所有+ SymLinksIfOwnerMatch +的FollowSymLinks + ExecCGI -Indexes -MultiViews
< /目录><目录/srv/www/mysitename.com/public_html/mt/>
    所有的AllowOverride
    为了允许,拒绝
    所有允许
    选项​​所有+ SymLinksIfOwnerMatch +的FollowSymLinks + ExecCGI -Indexes -MultiViews
< /目录>


解决方案

你有没有加入MOD-perl的?

添加这些行

 将AddType的perl脚本特等
AddHandler的的perl脚本的.htm

指定的DirectoryIndex

(目录外块)

您使用虚拟主机呢?我通常不会做的事情,你正在做他们是诚实的方式。

Pretty much a complete Linux/Apache newbie here, I am in the process of moving a site from a shared host to a Linode VPS. It's all been going smoothly until I starting trying to move my Moveable Type blog which runs using a series of CGI scripts. I am running Ubuntu 10.04 and Apache2. After hours of messing about I got a PERL hello world script (hello.cgi) to execute from a the web browser in the root HTML directory. Here's the script:

#!/usr/bin/perl -w
use strict;
print "Content-Type: text/html\n\nHello world!";

I got this working by adding the following to the /etc/apache2/sites-available/mysitename.com file.

<Directory /srv/www/mysitename.com/public_html/>
    Options +ExecCGI
    AddHandler cgi-script .cgi
</Directory>

But I want to execute CGI scripts in the /srv/www/mysitename.com/public_html/mt/ directory, so I changed the directory in the entry above to that path and when I view the hello world script in that folder via a browser I see the source for the hello.cgi script rather than the output. Clearly something isn't right. I've spent more than enough time trying to work this out myself and the time has come to ask for help. So, anyone got any suggestions? Please keep answers simple I really am just learning to tread water Linux/Apache2 wise here!

Solution Found:

<VirtualHost *:80>
  ServerName www.sitename.com
  ServerAdmin general@sitename.com
  ServerAlias sitename.com
  DocumentRoot /srv/www/mysitename.com/public_html/
  ErrorLog /srv/www/mysitename.com/logs/error.log
  CustomLog /srv/www/mysitename.com/logs/access.log combined
  AddHandler cgi-script .cgi .pl
</VirtualHost>

<Directory /srv/www/mysitename.com/public_html/>
    AllowOverride All
    Order allow,deny
    Allow from all
    Options All +SymLinksIfOwnerMatch +FollowSymLinks +ExecCGI -Indexes -MultiViews
</Directory>

<Directory /srv/www/mysitename.com/public_html/mt/>
    AllowOverride All
    Order allow,deny
    Allow from all
    Options All +SymLinksIfOwnerMatch +FollowSymLinks +ExecCGI -Indexes -MultiViews
</Directory>

解决方案

Have you added mod-perl?

Add these lines

AddType perl-script .pl
AddHandler perl-script .htm

specify a DirectoryIndex

(outside the Directory block)

Are you using vhosts too? I wouldn't normally do things the way you're doing them to be honest.

这篇关于问题在Apache执行CGI脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆