Perl로 만들어진 CGI화일..왜 실행이 안될까요

dogrice의 이미지

which perl 해보면
/usr/bin/perl 이라고 설치된 경로가 나타나고 :cry:

httpd.conf화일에서
Option ExecCGI
AddHandler .cgi-script .cgi 다해줬고
cgi화일도 cgi-bin 외에 다른 디렉토리에서도 실행 가능하게 해줬고 :cry:

*.cgi 소스 화일 상단에
#!/usr/bin/perl 이라고 perl의 경로도 명시해줬고 :cry:

cgi화일이 담겨있는 디렉토리와 cgi화일의 퍼미션도 755로 수정했는데.. :cry:

왜..Perl로 만들어진 cgi화일이 실행이 안되면서
Internal Server Error가 나는 것일까요...~~?? :oops: :oops:

ez8의 이미지

경험상 도스, 윈도우에서 만든 스크립트를 그냥 올려서

사용하면 internal 에러 나더군요.. 그때마다 해결 봤던게

telnet으로 접속해서 리눅스 상에서 맨 윗줄에

#!/usr/bin/perl 을 지우고 다시 쓰는 겁니다.

hexedit 따위로 보면 윈도우쪽에서 만들었던 스크립트는

맨 윗줄의 #!/usr/bin/perl 의 마지막 줄 바뀌는 부분이 0D 0A 이고 (CR LF)

리눅스에서 고친걸 보면 #!/usr/bin/perl 의 마지막 줄 바뀌는 부분이 0A 로 (LF)

끝나더군요.. 아마도 CR+LF 문제라고 생각되는데 잘 아시는 분 설명해 주세요.

dogrice의 이미지

여전히 잘 안됩니당...

:oops: :oops: :oops:

wooix의 이미지

cgi한지 너무 오래되서리 기억이 좀 아련한디요..

httpd.conf에 보면 cgi-bin과 같이 cgi실행 디렉토리가 있는뎅..

예전에 제가 cgi쓸땐.. (지금 아파치는 모르겠네용.. ^^;;) cgi-bin디렉토리가

아닌 다른곳에선 안되던 걸로 기억하걸랑요..

httpd.conf다시 확인하시고 cgi 파일 위치 다시 확인 해보세용..

이게 도움이 될랑가 ㅡㅡa 그럼이만~

평온하다~

sunyzero의 이미지

우선적으로 로그를 확인하시기 바랍니다.
rpm으로 설치했다면 /var/log/httpd/ 밑에 access와 error를 확인하시면 됩니다. 그리고나서 아무런 문제가 없다면, 해당 perl script를 그냥 프롬프트에서 실행해보시기 바랍니다. 하다못해서 에러메시지라도 떨어지지 않는다면 뭔가 문제가 있는것이겠죠?

보통 internal server error 이 나는 것으로 봐서, 프로그램을 애초에 잘못 작성하든지 혹은 dos 포맷때문에 그러는 경우가 가끔 있으니 ^M (vi -b 로 열면 dos format인경우는 보입니다.) 가 보이면 제거해주심 됩니다.

%s/^M//g 아시죠? ^M은 ctrl-V 다음에 M 누르면 됩니다. 한글자입니다.

========================================
* The truth will set you free.

dogrice의 이미지

역시 도스포맷 화일이 맞습니다..

^M이 라인마다 다 있네요..

그래서 다 지워줬고..했는데도 여전히 internal server에러가 자꾸만 뜨는 군요.... 무엇이 문제인지...

아 그리고 프롬프트 상에서는 잘 실행됩니다

[푸롬프트] perl xxx.cgi

하니깐 html마크업들이 쭉 나오는 군요

faye의 이미지

print "content-type: text/html\n\n";

헤더 넣어 주셨나요? 오래되서 위에것이 맞는지 모르겠내요..

gilsion의 이미지

아파치 로그를 먼저 봐 주세요.

error_log 에 보면 무었때문에 에러가 나있는지 명확히 나와 있습니다.

Perl 로 CGI 를 작성시에는 error_log 와 같이 살아야 합니다 : -)

dogrice의 이미지

넵 당근입니다

이런 간단한 예제로 가지고 실험하는 데도 안되네요

-----------------------------------------------------------------------------
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "<HTML><HEAD><TITLE>CGI TEST</TITLE></HEAD>\n";
print "<BODY BGCOLOR=FFFFFF>\n";
print "<CENTER><H1>THIS IS A TEST PAGE</H1>\n";
print "</CENTER>";
print "</BODY></HTML>\n";
exit;
-----------------------------------------------------------------------------

internal server 에러...웬수다..웬수..

dogrice의 이미지

-------------------------------------------------------------------------------

[Mon Apr 07 12:55:08 2003] [error] [client 218.233.19.172] File does not exist: /var/www/html/_mem_bin
[Mon Apr 07 12:55:09 2003] [error] [client 218.233.19.172] File does not exist: /var/www/html/msadc
[Mon Apr 07 12:55:09 2003] [error] [client 218.233.19.172] File does not exist: /var/www/html/scripts
[Mon Apr 07 12:55:09 2003] [error] [client 218.233.19.172] File does not exist: /var/www/html/scripts
[Mon Apr 07 12:55:09 2003] [error] [client 218.233.19.172] File does not exist: /var/www/html/scripts
[Mon Apr 07 12:55:09 2003] [error] [client 218.233.19.172] File does not exist: /var/www/html/scripts
[Mon Apr 07 12:55:09 2003] [error] [client 218.233.19.172] File does not exist: /var/www/html/scripts
[Mon Apr 07 12:55:22 2003] [warn] child process 11838 still did not exit, sending a SIGTERM
[Mon Apr 07 12:55:22 2003] [notice] caught SIGTERM, shutting down
[Mon Apr 07 12:57:49 2003] [warn] module php4_module is already loaded, skipping
[Mon Apr 07 12:57:51 2003] [notice] Digest: generating secret for digest authentication ...
[Mon Apr 07 12:57:51 2003] [notice] Digest: done
[Mon Apr 07 12:57:52 2003] [notice] Apache/2.0.40 (Red Hat Linux) configured -- resuming normal operations
[Mon Apr 07 12:58:53 2003] [error] [client 218.154.66.251] File does not exist: /var/www/html/default.ida
[Mon Apr 07 13:01:55 2003] [warn] child process 792 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:55 2003] [warn] child process 793 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:55 2003] [warn] child process 794 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:55 2003] [warn] child process 795 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:55 2003] [warn] child process 802 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:55 2003] [warn] child process 803 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:55 2003] [warn] child process 804 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:55 2003] [warn] child process 805 still did not exit, sending a SIGTERM
[Mon Apr 07 13:01:56 2003] [notice] caught SIGTERM, shutting down
-------------------------------------------------------------------------------

보시면 알겠지만 오늘날자로 등록된 에러로그도 없습니다...
뭣이 문제일까요
시스템 날자는 오늘날자 4월 10일이 정확합니다..date명령으로 확인을 해 보았습니다.

디망쉬의 이미지

전 잘 되는군요. 아무래도 cgi 자체 문제라기 보다는 apache 설정 문제 같습니다.

(위 소스를 vi 에서 붙여넣기로 작성)

제 apache 설정입니다.

<Directory /member1/*/public_html>
    AllowOverride None
    Options ExecCGI FollowSymLinks
    Order allow,deny
    Allow from all
    Deny from env=go_out       
</Directory>
Prentice의 이미지

안녕하세요, 검은해라고 합니다.

지금 현재 Apache에서 cgi를 실행할 수 있도록 mod_cgi등의 모듈이 로딩된 상태인가요? 아니면 Apache에 cgi기능이 같이 컴파일되어 있기라도 한건가요?

만약 아니라면 mod_cgi를 로딩하셔야 할 것 같습니다.

offree의 이미지

할것은 다 해주신 것 같은데...

콘솔상에서 vi test.cgi 로

#!/usr/bin/perl

이 부분을 직접 넣고 해 보시길..

안될 이유가 없는데 이상하군요.

ftp 업로드 방법 말고요.. 직접..

dogrice wrote:

-----------------------------------------------------------------------------
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "<HTML><HEAD><TITLE>CGI TEST</TITLE></HEAD>\n";
print "<BODY BGCOLOR=FFFFFF>\n";
print "<CENTER><H1>THIS IS A TEST PAGE</H1>\n";
print "</CENTER>";
print "</BODY></HTML>\n";
exit;
-----------------------------------------------------------------------------

internal server 에러...웬수다..웬수..

사용자가 바꾸어 나가자!!

= about me =
http://wiki.kldp.org/wiki.php/offree , DeVlog , google talk : offree at gmail.com

sunyzero의 이미지

혹시 아파치가 두개 떠있는 것은 아닌지요? 로그가 없다는 것은 좀 이상합니다.
아니면 가상호스팅을 사용하고 계신것은 아닌지?
internal server error 이라면 분명 로그에 남습니다.
혹시 access_log도 보셨나요? 그쪽에는 로그가 생기나요?

========================================
* The truth will set you free.

dormael의 이미지

>> perl abc.cgi
이방법 말고
>> ./abc.cgi
는 해보셨나요?

이것도 좀 다를 수 있습니다...

만일 밑에꺼만 안된다면 아직도 그 파일을 텍스트가 아닌 바이너리로 인식하고 있는 걸껍니다.

-- Signature --
青い空大好き。
蒼井ソラもっと好き。
파란 하늘 너무 좋아.
아오이 소라 더좋아.

brandon의 이미지

아파치에서 펄 모듈이 지원하게 되어 있나요?

그리고 퍼미션 문젠 아니라고 하셨고....

hi ~

macppc의 이미지

퍼미션 문제라고 생각들지 않네요.

먼저 .htaccess파일의 기술에 대해서 꼼꼼히 보시고 체크하세요.
AddType text/html .shtml
AddHandler server-parsed .shtml
AddHandler cgi-script .cgi

그리고 httpd.cof 파일의 cgi-bin 부분에서 옵션항목을 수정해 보시길 바랍니다.

#
# ScriptAlias This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "xxx/xxx/xxx/cgi-bin/"

#
# "xxx/xxx/xxx/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "xxx/xxx/xxx/cgi-bin">
AllowOverride None
#Options None
Options Indexes FollowSymLinks MultiViews ExecCGI
Order allow,deny
Allow from all
</Directory>

이상입니다만, 자세한 설명을 못드리것 같아서 죄송하네요.
그럼 해결하시길 바라며, 즐거운 하루되세요...^^

즐거운 하루되세요... 여러분.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.