产生perl CGI错误"Premature end of script headers"的可能原因
2006-02-10 13:27
851 查看
产生perl CGI错误"Premature end of script headers"的可能原因
今天我在为公司配置website 时遇到了这个错误,这个site 的CGI是用perl写的,折腾了半天,并且查阅了相关资料终于搞定了,所以在此罗列以下,希望对大家有所帮助。
在讲错误产生的原因之前,有个基本的要点是:要让CGI程序能正常运作,必须配置Apache以允许CGI的执行。下面列出了产生这个错误可能的原因:
原因1)perl 解释器路径不对
在CGI程序的第一行中指明解释器(通常是perl),形如:
#!/usr/bin/perl
必须保证它的确指向解释器。
原因2)文件的权限不对
记住,服务器不是以你的用户身份运行的,就是说,在服务器启动后,拥有的是一个非特权用户的权限-通常是``nobody''或者``www'' -而需要更大的权限以允许文件的执行。通常,给予``nobody''足够的权限以执行文件的方法是,对文件赋予everyone execute权限:
chmod a+x first.pl
另外,如果需要对其他文件进行读取或写入,也必须对这些文件赋予正确的权限。
原因3)CGI中有语法错误
在运行你的CGI之前,你可以用一个简单的perl CGI文件test.pl测试一下,文件内容如下:
#!/usr/local/bin/perl -w
print "Content-type: text/html/n/n";
print "Hello, World.";
别忘了修改该文件的权限chmod a+x test.pl.
今天我在为公司配置website 时遇到了这个错误,这个site 的CGI是用perl写的,折腾了半天,并且查阅了相关资料终于搞定了,所以在此罗列以下,希望对大家有所帮助。
在讲错误产生的原因之前,有个基本的要点是:要让CGI程序能正常运作,必须配置Apache以允许CGI的执行。下面列出了产生这个错误可能的原因:
原因1)perl 解释器路径不对
在CGI程序的第一行中指明解释器(通常是perl),形如:
#!/usr/bin/perl
必须保证它的确指向解释器。
原因2)文件的权限不对
记住,服务器不是以你的用户身份运行的,就是说,在服务器启动后,拥有的是一个非特权用户的权限-通常是``nobody''或者``www'' -而需要更大的权限以允许文件的执行。通常,给予``nobody''足够的权限以执行文件的方法是,对文件赋予everyone execute权限:
chmod a+x first.pl
另外,如果需要对其他文件进行读取或写入,也必须对这些文件赋予正确的权限。
原因3)CGI中有语法错误
在运行你的CGI之前,你可以用一个简单的perl CGI文件test.pl测试一下,文件内容如下:
#!/usr/local/bin/perl -w
print "Content-type: text/html/n/n";
print "Hello, World.";
别忘了修改该文件的权限chmod a+x test.pl.
相关文章推荐
- Premature end of script headers 的原因
- Premature end of script headers 错误的终极处理方法 (CGI的相关程序)
- Premature end of script headers: test-cgi 错误
- 解决Premature end of script headers
- Premature end of script headers 错误的终极处理方法
- python脚本放到linux的cgi-bin下出现Premature end of script headers问题
- cgi程序报 Premature end of script headers:
- [Python]python CGI脚本在apache服务器上运行时出现“Premature end of script headers”错误
- apache+wsgi+python: Premature end of script headers: mytest.py
- Qt5:"Designer: An error has occurred while reading the UI file at line 1, column 0: Premature end of document."错误
- horizon error:End of script output before headers: django.wsgi(kolla-ansible部署在容器)
- openstack访问horizon出现End of script output before headers: django.wsgi
- jQuery的ready函数不执行,报错:Unexpected end of input "",原因是js有语法错误,js文件中的所有东西即变量,一点也没有创建到内存中
- 【2017.11.28】编译可能产生的原因
- warning: no newline at end of file的原因
- Runtime Error可能产生的原因
- vc提示unexpected end of file found的原因分析
- [转]Null value was assigned to a property of primitive type setter of"原因及解决方法
- java读取xml文件报“org.xml.sax.SAXParseException: Premature end of file
- 解决"当前命令发生了严重错误。应放弃任何可能产生的结果。"的问题