1<?xml version="1.0" encoding="EUC-KR"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko"><head><!--
4        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5              This file is generated from xml source: DO NOT EDIT
6        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7      -->
8<title>����ġ ���丮��: CGI�� ����� ���� ������ �� - Apache HTTP Server</title>
9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
12<script src="/style/scripts/prettify.min.js" type="text/javascript">
13</script>
14
15<link href="/images/favicon.ico" rel="shortcut icon" /></head>
16<body id="manual-page"><div id="page-header">
17<p class="menu"><a href="/mod/">���</a> | <a href="/mod/directives.html">���þ��</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">���</a> | <a href="/sitemap.html">����Ʈ��</a></p>
18<p class="apache">Apache HTTP Server Version 2.4</p>
19<img alt="" src="/images/feather.gif" /></div>
20<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
21<div id="path">
22<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.4</a> &gt; <a href="./">How-To / Tutorials</a></div><div id="page-content"><div id="preamble"><h1>����ġ ���丮��: CGI�� ����� ���� ������ ��</h1>
23<div class="toplang">
24<p><span>������ ���: </span><a href="/en/howto/cgi.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
25<a href="/fr/howto/cgi.html" hreflang="fr" rel="alternate" title="Fran&#231;ais">&nbsp;fr&nbsp;</a> |
26<a href="/ja/howto/cgi.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
27<a href="/ko/howto/cgi.html" title="Korean">&nbsp;ko&nbsp;</a></p>
28</div>
29<div class="outofdate">�� ������ �ֽ��� ���� �ƴմϴ�.
30            �ֱٿ� ����� ������ ���� ������ ����ϼ���.</div>
31</div>
32<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#intro">�Ұ�</a></li>
33<li><img alt="" src="/images/down.gif" /> <a href="#configuring">CGI�� ����ϵ��� ����ġ �����ϱ�</a></li>
34<li><img alt="" src="/images/down.gif" /> <a href="#writing">CGI ���α׷� �ۼ��ϱ�</a></li>
35<li><img alt="" src="/images/down.gif" /> <a href="#troubleshoot">�׷��� ���� �������� �ʾƿ�!</a></li>
36<li><img alt="" src="/images/down.gif" /> <a href="#behindscenes">�ڿ����� ���� ���� ������°�?</a></li>
37<li><img alt="" src="/images/down.gif" /> <a href="#libraries">CGI ���/���̺귯��</a></li>
38<li><img alt="" src="/images/down.gif" /> <a href="#moreinfo">�� ���� ����...</a></li>
39</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
40<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
41<div class="section">
42<h2><a name="intro" id="intro">�Ұ�</a></h2>
43    
44
45    <table class="related"><tr><th>��õ� ���</th><th>��õ� ���þ�</th></tr><tr><td><ul><li><code class="module"><a href="/mod/mod_alias.html">mod_alias</a></code></li><li><code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code></li></ul></td><td><ul><li><code class="directive"><a href="/mod/mod_mime.html#addhandler">AddHandler</a></code></li><li><code class="directive"><a href="/mod/core.html#options">Options</a></code></li><li><code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code></li></ul></td></tr></table>
46
47    <p>CGI (Common Gateway Interface)�� �������� ���� CGI ���α׷�
48    Ȥ�� CGI ��ũ��Ʈ��� �θ���, (�������� ������ �����) �ܺ�
49    ���α׷��� ����ϴ� ����� �����Ѵ�. ������Ʈ���� ������
50    �������� ����� ���� ���ϰ� ������ ����̴�. �� ������ ����ġ
51    �������� CGI�� �����ϴ� ����� �Ұ��ϰ�, CGI ���α׷���
52    �ۼ��غ���.</p>
53  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
54<div class="section">
55<h2><a name="configuring" id="configuring">CGI�� ����ϵ��� ����ġ �����ϱ�</a></h2>
56    
57
58    <p>CGI ���α׷��� �ùٷ� �����Ϸ��� CGI ������ �����ϵ���
59    ����ġ�� �����ؾ� �Ѵ�. �����ϴ� ����� ����������.</p>
60
61    <h3><a name="scriptalias" id="scriptalias">ScriptAlias</a></h3>
62      
63
64      <p><code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code>
65      ���þ ����ϸ� ����ġ�� Ư�� ���丮�� CGI ���α׷�������
66      �д�. ����ġ�� �� ���丮�� �ִ� ��� ������ CGI
67      ���α׷��̶�� �����Ͽ� Ŭ���̾�Ʈ�� �ڿ��� ��û�ϸ� �ڿ���
68      �����Ϸ��� �õ��Ѵ�.</p>
69
70      <p><code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code>
71      ���þ�� ������ ���� ����Ѵ�.</p>
72
73      <div class="example"><p><code>
74        ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
75      </code></p></div>
76
77      <p>�� ������ ����ġ�� �⺻ ��ҿ� ��ġ�� ���
78      <code>httpd.conf</code> �������Ͽ� �ִ� �����̴�. <code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code> ���þ�� <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code> ���þ�� ���� URL
79      �պκ��� Ư�� ���丮�� �����Ѵ�.
80      <code class="directive">Alias</code>��
81      <code class="directive">ScriptAlias</code>�� ���� <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code> ���丮 �ۿ� �ִ�
82      ���丮�� ����Ѵ�. <code class="directive">Alias</code>��
83      <code class="directive">ScriptAlias</code>�� ��������
84      <code class="directive">ScriptAlias</code>�� �߰��� URL �պκ�����
85      �����ϴ� ��� ������ CGI ���α׷����� ����ϴ� ���̴�.
86      �׷��� ���� ������ ����ġ���� <code>/cgi-bin/</code>����
87      �����ϴ� �ڿ��� ��û�ϸ�
88      <code>/usr/local/apache2/cgi-bin/</code> ���丮����
89      ã�Ƽ� CGI ���α׷����� ó���϶�� �˸���.</p>
90
91      <p>���� ���, URL
92      <code>http://www.example.com/cgi-bin/test.pl</code>��
93      ��û�ϸ� ����ġ��
94      <code>/usr/local/apache2/cgi-bin/test.pl</code> ������
95      �����Ͽ� ��� ��ȯ�Ѵ�. ���� ������ �����ϰ� ���డ���ϸ�
96      � ������ε� ����� �ؾ� �Ѵ�. �׷��� ������ ����ġ��
97      ������ ������.</p>
98    
99
100    <h3><a name="nonscriptalias" id="nonscriptalias">ScriptAlias ���丮 �ۿ� �ִ� CGI</a></h3>
101      
102
103      <p>���� ���Ȼ� ���������� CGI ���α׷��� <code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code>�� ���丮��
104      �����Ѵ�. �׷��� ���ڴ� ���� CGI ���α׷��� ����� ��
105      �ִ��� ������ ������ �� �ִ�. �׷��� ����� ������ġ��
106      ���ߴٸ� �ƹ� ���丮������ CGI ���α׷��� �������� ����
107      ������ ���. ���� ���, <code class="directive"><a href="/mod/mod_userdir.html#userdir">UserDir</a></code> ���þ ����Ͽ�
108      ����ڰ� �ڽ��� Ȩ���丮�� ���������� ������ ��츦
109      ��������. ����ڰ� �ڽ��� CGI ���α׷��� ����ϰ� ������
110      <code>cgi-bin</code> ���丮�� ���ٱ����� ��ٸ�, �ٸ�
111      �������� CGI ���α׷��� �����ϰ� ���� ���̴�.</p>
112
113      <p>�ƹ� ���丮������ CGI ������ ����Ϸ��� �� ������
114      �ʿ��ϴ�. ����, <code class="directive"><a href="/mod/mod_mime.html#addhandler">AddHandler</a></code>�� <code class="directive"><a href="/mod/core.html#sethandler">SetHandler</a></code> ���þ ����Ͽ�
115      <code>cgi-script</code> �ڵ鷯�� �۵��ؾ� �Ѵ�. �ι�°��,
116      <code class="directive"><a href="/mod/core.html#options">Options</a></code> ���þ
117      <code>ExecCGI</code>�� �����ؾ� �Ѵ�.</p>
118    
119
120    <h3><a name="options" id="options">Options�� ����Ͽ� ��������� CGI ������ ����ϱ�</a></h3>
121      
122
123      <p>������ �ּ������Ͽ� ���� <code class="directive"><a href="/mod/core.html#options">Options</a></code> ���þ ����Ͽ� Ư��
124      ���丮���� CGI ������ ����� �� �ִ�.</p>
125
126      <div class="example"><p><code>
127        &lt;Directory /usr/local/apache2/htdocs/somedir&gt;<br />
128        <span class="indent">
129          Options +ExecCGI<br />
130        </span>
131        &lt;/Directory&gt;
132      </code></p></div>
133
134      <p>�� ���þ�� ����ġ�� CGI ������ ������ ����Ѵ�. �
135      ������ CGI ���������� �������� �˷��� �Ѵ�. ���� <code class="directive"><a href="/mod/mod_mime.html#addhandler">AddHandler</a></code> ���þ�� ��������
136      Ȯ���ڰ� <code>cgi</code>�� <code>pl</code>�� ������ ���
137      CGI ���α׷��̶�� �˸���.</p>
138
139      <div class="example"><p><code>
140        AddHandler cgi-script .cgi .pl
141      </code></p></div>
142    
143
144    <h3><a name="htaccess" id="htaccess">.htaccess ����</a></h3>
145      
146
147      <p><a href="htaccess.html"><code>.htaccess</code> ���丮��</a>��
148      <code>httpd.conf</code>�� ���ٱ����� ��� ��쿡 CGI ���α׷���
149      ����� �� �ִ� ����� �˷��ش�.</p>
150    
151
152    <h3><a name="userdir" id="userdir">����� ���丮</a></h3>
153      
154
155      <p>�Ʒ� ������ ����ϸ� ����� ���丮���� <code>.cgi</code>��
156      ������ ������ CGI ���α׷����� �����Ѵ�.</p>
157
158      <div class="example"><p><code>
159      &lt;Directory /home/*/public_html&gt;<br />
160      <span class="indent">
161        Options +ExecCGI<br />
162        AddHandler cgi-script .cgi<br />
163      </span>
164      &lt;/Directory&gt;
165      </code></p></div>
166
167      <p>������ ����ϸ� ����� ���丮�� <code>cgi-bin</code>
168      �������丮�� �ִ� ��� ������ CGI ���α׷����� �ν��Ѵ�.</p>
169
170      <div class="example"><p><code>
171      &lt;Directory /home/*/public_html/cgi-bin&gt;<br />
172      <span class="indent">
173        Options ExecCGI<br />
174        SetHandler cgi-script<br />
175      </span>
176      &lt;/Directory&gt;
177      </code></p></div>
178
179    
180
181  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
182<div class="section">
183<h2><a name="writing" id="writing">CGI ���α׷� �ۼ��ϱ�</a></h2>
184    
185
186    <p>``�Ϲ�����'' ���α׷��ְ� CGI ���α׷��� ���̿��� �ΰ���
187    �ֵ� �������� �ִ�.</p>
188
189    <p>ù��° ���̴� CGI ���α׷��� �ٸ� ����� �ϱ��� ����
190    MIME-type ����� ����ؾ� �Ѵٴ� ���̴�. HTTP �����
191    Ŭ���̾�Ʈ���� Ŭ���̾�Ʈ�� � ������ �ްԵ��� �̸� �˸���.
192    ���� ������ ����.</p>
193
194    <div class="example"><p><code>
195      Content-type: text/html
196    </code></p></div>
197
198    <p>�ι�° ���̴� HTML Ȥ�� ������ ������ �� �ִ� �������
199    ����ؾ� �Ѵٴ� ���̴�. ��κ��� ��� HTML�� ���������,
200    ������ gif �׸��� ���� HTML�� �ƴ� ������ ����ϴ� CGI
201    ���α׷��� �ۼ��ϴ� ��쵵 �ִ�.</p>
202
203    <p>�ΰ����� �����ϰ�� CGI ���α׷� �ۼ��� �̹� ����� ������
204    �ٸ� ���α׷���� �ſ� ����ϴ�.</p>
205
206    <h3><a name="firstcgi" id="firstcgi">ó������ ���� CGI ���α׷�</a></h3>
207      
208
209      <p>������ ������ �� ���� ��� CGI ���α׷� ������.
210      �״�� <code>first.pl</code>�̶�� ���Ͽ� �����ϰ�,
211      <code>cgi-bin</code> ���丮�� �����Ѵ�.</p>
212
213      <div class="example"><p><code>
214        #!/usr/bin/perl<br />
215        print "Content-type: text/html\n\n";<br />
216        print "Hello, World.";
217      </code></p></div>
218
219      <p>Perl�� �ͼ����� �ʴ��� ���� ���� �Ͼ���� �� ��
220      �ִ�. ù��° ���� ����ġ(Ȥ�� ����ϴ� ��)����
221      <code>/usr/bin/perl</code> ��ġ�� �ִ� ������������ ����Ͽ�
222      �� ���α׷� ������ �����϶�� �˸���. �ι�° ���� ���
223      ���� content-type ������ ����ϰ� carriage-return �ٹٲ���
224      �ι� ����Ѵ�. �׷��� ��� �ڿ� HTTP ����� ���� ���ϴ�
225      ������ ����, ������ �����Ѵ�. ����° ���� "Hello, World."
226      ���ڿ��� ����Ѵ�. �̰����� ���̴�.</p>
227
228      <p>������ �����ϰ� �ּҸ� �Է��Ѵ�</p>
229
230      <div class="example"><p><code>
231        http://www.example.com/cgi-bin/first.pl
232      </code></p></div>
233
234      <p>���� ��Ҹ� �Է��ϸ�, ������â�� <code>Hello, World.</code>
235      �� ���� ���δ�. ��е����� ������, �ѹ� �����ϴ� ����
236      �������� ���� �ٸ� ���� �õ��� �� �� �ִ�.</p>
237    
238  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
239<div class="section">
240<h2><a name="troubleshoot" id="troubleshoot">�׷��� ���� �������� �ʾƿ�!</a></h2>
241    
242
243    <p>������ CGI ���α׷��� �����Ҷ� ������ ���� �� �ִ�
244    ������ �⺻������ �װ�����.</p>
245
246    <dl>
247      <dt>CGI ���α׷��� ���</dt>
248      <dd>����! ��� ���� �� �����Ѵٴ� ���̴�. ����� ��Ȯ������
249      ������ �ùٷ� ó������ ���Ѵٸ�, CGI ���α׷�����
250      �ùٸ� <code>Content-Type</code>�� �����Ͽ����� Ȯ���Ѵ�.</dd>
251
252      <dt>CGI ���α׷� �ҽ��ڵ� Ȥ�� "POST Method Not Allowed"
253      ����</dt>
254      <dd>CGI ���α׷��� �����ϵ��� ����ġ�� ������ ��������
255      �ʾҴٴ� ���̴�. <a href="#configuring">����ġ �����ϱ�</a>
256      ���� �ٽ� �а� ������ �κ��� �ִ��� ã�ƺ���.</dd>
257
258      <dt>"Forbidden"���� �����ϴ� ����</dt>
259      <dd>���� ������ �ִٴ� ���̴�. <a href="#errorlogs">����ġ
260      ���� �α�</a>�� �Ʒ� <a href="#permissions">���ϱ���</a>
261      ���� Ȯ���϶�.</dd>
262
263      <dt>"Internal Server Error"��� ����</dt>
264      <dd><a href="#errorlogs">����ġ ���� �α�</a>�� ���� �Ƹ���
265      CGI ���α׷��� ����� ����� �Բ� "Premature end of
266      script headers"�� ���� ���̴�. �� ��� �Ʒ� ������� �ϳ���
267      Ȯ���Ͽ� � ������ CGI ���α׷��� ������ HTTP �����
268      ������� ���ߴ��� �˾ƺ���.</dd>
269    </dl>
270
271    <h3><a name="permissions" id="permissions">���ϱ���</a></h3>
272      
273
274      <p>������ ��Ű� ������ �������� �������� ������ ����϶�.
275      ��, ������ �����ϸ� ������ ��Ư�� ����� ����(����
276      <code>nobody</code>�� <code>www</code>)���� �����Ѵ�.
277      �׷��� ����� ������ ������ �����Ϸ��� ������ �ʿ��ϴ�.
278      ���Ͽ� <code>nobody</code>�� �����ϱ⿡ ����� ������
279      �ֱ����� ���� ��ο��� ������ ���� ������ �ش�.</p>
280
281      <div class="example"><p><code>
282        chmod a+x first.pl
283      </code></p></div>
284
285      <p>��, ���α׷��� �ٸ� ������ �аų� ���ٸ� �� ���Ͽ���
286      ������ ������ �ʿ��ϴ�.</p>
287
288    
289
290    <h3><a name="pathinformation" id="pathinformation">��� ������ ȯ��</a></h3>
291      
292
293      <p>����࿡�� ���α׷��� �����ϸ� �ڵ����� � ������
294      ���� ��޵ȴ�. ���� ���, <code>PATH</code>�� ������ �����
295      ���� ������ ã�� ��Ҹ� �˷��ش�.</p>
296
297      <p>�������� ���α׷��� CGI ���α׷����� �����Ҷ���
298      <code>PATH</code>�� �ٸ� �� �ִ�. (���� ���,
299      <code>sendmail</code> ����) CGI ���α׷� �ȿ��� �����ϴ�
300      ��ɾ�� ������ ��η� ����ؾ� ���� ��ɾ ã�� ��
301      �ִ�.</p>
302
303      <p>��� ������ ������ ���� CGI ���α׷� ù��° �ٿ� ������
304      ��ũ��Ʈ ���������� (���� <code>perl</code>) ��ο���
305      ���� �߻��Ѵ�.</p>
306
307      <div class="example"><p><code>
308        #!/usr/bin/perl
309      </code></p></div>
310
311      <p>������ ������������ ������� Ȯ���Ѵ�.</p>
312
313      <p>��, CGI ���α׷��� �ٸ� <a href="#env">ȯ�溯��</a>��
314      ����Ѵٸ� ����ġ�� �� �������� ���α׷����� ����ؾ�
315      �Ѵ�.</p>
316
317    
318
319    <h3><a name="syntaxerrors" id="syntaxerrors">���α׷� ����</a></h3>
320      
321
322      <p>CGI ���α׷��� �����ϴ� ��� ��κ� ���α׷� ��ü
323      ���������̴�. Ư�� ���� �ΰ��� �Ǽ��� ���� �ʾҰ� �� ����
324      ��� ���� �ִٸ� ������ �׷���. ���� ���������� �����ϱ�
325      �� ����࿡�� ���α׷��� �����غ���. ���� ���, ������
326      ���� �����Ѵ�.</p>
327
328      <div class="example"><p><code>
329      cd /usr/local/apache2/cgi-bin<br />
330      /first.pl
331      </code></p></div>
332
333      <p>(<code>perl</code> ���������͸� �������� ����. ����
334      ����ġ�� ��ũ��Ʈ ù��° �ٿ� �ִ� <a href="#pathinformation">��� ����</a>�� ����Ͽ� ���������͸�
335      ã�ƾ� �Ѵ�.)</p>
336
337      <p>���α׷��� ���� ���� <code>Content-Type</code>�� ������
338      HTTP ������� ����ϰ� �� ���� ����ؾ� �Ѵ�. �ٸ� ����
339      ����Ѵٸ� ���������� ������ ��� ����ġ�� <code>Premature
340      end of script headers</code>�� ��ȯ�Ѵ�. �ڼ��� ������
341      ���� <a href="#writing">CGI ���α׷� �ۼ��ϱ�</a>�� ����϶�.</p>
342    
343
344    <h3><a name="errorlogs" id="errorlogs">���� �α�</a></h3>
345      
346
347      <p>���� �α״� ��� ���̴�. ���� �߸�Ǹ� ���� �α׿�
348      ������ ����. ���� �α׸� ���� ���� ������� �Ѵ�. ������Ʈ��
349      ȣ�����ϴ� ������ ���� �α׸� ���� ���ϰ� �Ѵٸ�, �Ƹ���
350      �ٸ� ��ü�� �˾ƺ��� �Ѵ�. ���� �α׸� ���� ����� ������,
351      ��κ��� ������ ���� �ľ��Ͽ� �ذ��� �� �ִ�.</p>
352    
353
354    <h3><a name="suexec" id="suexec">Suexec</a></h3>
355      
356
357      <p><a href="/suexec.html">suexec</a> ���� ���α׷���
358      ����ϸ� � ����ȣ��Ʈ Ȥ�� � ����� ���丮�� �ִ�����
359      ��� CGI ���α׷��� �ٸ� ����� �������� ������ �� �ִ�.
360      Suexec�� �ſ� �����ϰ� ������ �˻��ϸ�, �˻縦 �ϳ���
361      ������� ���ϸ� CGI ���α׷��� �������� �ʰ� <code>Premature
362      end of script headers</code>�� ��ȯ�Ѵ�.</p>
363
364      <p>suexec�� ����ϰ� �ִ��� �˷��� <code>apachectl -V</code>��
365      �����Ͽ� <code>SUEXEC_BIN</code> ��ġ�� Ȯ���Ѵ�. ����ġ��
366      �����Ҷ� �� ��ҿ��� suexec ���������� �߰��ϸ�, suexec��
367      ����� �� �ִ�.</p>
368
369      <p>suexec�� ������ �������� ���ߴٸ� ����ؼ��� �ȵȴ�.
370      suexec�� ������� �������� <code>SUEXEC_BIN</code> ��ġ��
371      �ִ� <code>suexec</code> ���������� ����� (Ȥ�� ���ϸ���
372      �ٲٰ�) ������ ������ϸ� �ȴ�. <a href="/suexec.html">suexec</a>�� ���� ���� ���� �׷���
373      ����ϰ� �ʹٸ�, <code>suexec -V</code>�� �����Ͽ� suexec
374      �α����� ��ġ�� �˾Ƴ��� �α����Ͽ��� ����� � ��Ģ��
375      ���� �ִ��� ã�´�.</p>
376    
377  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
378<div class="section">
379<h2><a name="behindscenes" id="behindscenes">�ڿ����� ���� ���� ������°�?</a></h2>
380    
381
382    <p>CGI ���α׷��ֿ� �ͼ�������� �ڿ��� ������� ���� �����ϸ�
383    ������ �ȴ�. ��ü������ ������� ������ ���� ����ϴ�
384    ����� ���ϴ� ���̴�. ���� "Hello, World."�� ����ϴ�
385    ���α׷��� �ۼ��� �� ������ �̷� ���α׷��� ���� ����
386    ��⶧���̴�.</p>
387
388    <h3><a name="env" id="env">ȯ�溯��</a></h3>
389      
390
391      <p>ȯ�溯���� ����� ��ǻ�͸� ����ϴ� ���� ��� ������
392      ���ٴϴ� ���̴�. ȯ�溯���� path (��ǻ�Ͱ� ����� �Է���
393      ��ɾ �ش��ϴ� ���� ������ ã�� ���), ����ڸ�, �͹̳�
394      ����� ���� ������ ������. �Ϲ����� ȯ�溯���� ��� ������
395      ����� ������Ʈ���� <code>env</code>�� �Է��Ѵ�.</p>
396
397      <p>CGI�� �����Ҷ��� ������ ������� ������ ȯ�溯����
398      ���� ��ȯ�Ѵ�. �� �������� ������ ���� (Netscape, IE,
399      Lynx), ���� ���� (����ġ, IIS, WebSite), �����ϴ� CGI
400      ���α׷��� ���� �ִ�.</p>
401
402      <p>CGI ���α׷��Ӵ� �̷� �������� ����� �� �ְ�,
403      ȯ�溯���� Ŭ���̾�Ʈ-���� ��ſ��� �Ϻκ��� �����Ѵ�.
404      ��ü �ʼ� ���� ����� <a href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html">http://hoohoo.ncsa.uiuc.edu/cgi/env.html</a>�� �ִ�.</p>
405
406      <p>�Ʒ� ������ Perl CGI ���α׷��� �ڽſ��� ��޵� ���
407      ȯ�溯���� �����ش�. ����ġ �������� <code>cgi-bin</code>
408      ���丮�� �̿� ����� ���α׷��� �ΰ� �ִ�. ��� ������
409      �ʼ��̰� �������� �������̴�. �׷��� ��� ��Ͽ� ���
410      ������ ���δ�. ��, ����ġ�� �⺻������ �����ϴ� ȯ�溯��
411      �ܿ� �������� ������� <a href="/env.html">���� ȯ�溯����
412      �߰��� �� �ִ�</a>.</p>
413
414      <div class="example"><p><code>
415        #!/usr/bin/perl<br />
416        print "Content-type: text/html\n\n";<br />
417        foreach $key (keys %ENV) {<br />
418        <span class="indent">
419          print "$key --&gt; $ENV{$key}&lt;br&gt;";<br />
420        </span>
421        }
422      </code></p></div>
423    
424
425    <h3><a name="stdin" id="stdin">STDIN�� STDOUT</a></h3>
426      
427
428      <p>��, ������ Ŭ���̾�Ʈ�� ǥ���Է�(<code>STDIN</code>)��
429      ǥ�����(<code>STDOUT</code>)���� ����Ѵ�. �ϻ����� ���
430      <code>STDIN</code>�� Ű���峪 ���α׷��� ó���ϴ� ������
431      ��Ÿ����, <code>STDOUT</code>�� ���� �ܼ��̳� ȭ���� ���Ѵ�.</p>
432
433      <p>CGI ���α׷����� �� ���(form)�� <code>POST</code>�ϸ�
434      ��Ŀ� �Է��� �ڷḦ Ư���� ������� ��� CGI ���α׷���
435      <code>STDIN</code>���� ����Ѵ�. �׷��� ���α׷��� Ű���峪
436      ���Ͽ��� ���� �ڷḦ ó���ϵ��� �ڷḦ ó���� �� �ִ�.</p>
437
438      <p>"Ư���� ���"�� �ſ� �����ϴ�. �׸� �̸��� ���� ��ȣ(=)��
439      �����ϰ�, �׸� �̸��� ���� �ֵ��� ���� ���ۻ���(&amp;)��
440      �����Ѵ�. ���, ���ۻ���, ��ȣ ���� ���ڿ������� ���ڴ�
441      ȥ������ �ʵ��� 16����� ��ȯ�Ѵ�. ������ �ڷ� ���ڿ���
442      ������ ���� ����.</p>
443
444      <div class="example"><p><code>
445        name=Rich%20Bowen&amp;city=Lexington&amp;state=KY&amp;sidekick=Squirrel%20Monkey
446      </code></p></div>
447
448      <p>���� URL �ڿ��� �̷� ���ڿ��� ���� �ȴ�. �� ��� ������
449      ���ڿ��� <code>QUERY_STRING</code>�̶�� ȯ�溯���� �����Ѵ�.
450      �̸� <code>GET</code> ��û�̶�� �Ѵ�. <code>FORM</code>
451      �±��� <code>METHOD</code> �Ӽ��� �����Ͽ� HTML ���(form)��
452      �ڷḦ <code>GET</code>���� <code>POST</code>���� �����Ѵ�.</p>
453
454      <p>���� ���α׷��� �̷� ���ڿ��� ������ ������ �ɰ���
455      �Ѵ�.  �������� �̷� �ڷ� ó���� ���� CGI ���α׷��� �ٸ�
456      ���� ���� ���Ǵ� ���̺귯���� ������ �ִ�.</p>
457    
458  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
459<div class="section">
460<h2><a name="libraries" id="libraries">CGI ���/���̺귯��</a></h2>
461    
462
463    <p>CGI ���α׷��� �ۼ��Ҷ� ������ �۾��� ������ִ� �ڵ�
464    ���̺귯�� Ȥ�� ����� ������� ����غ��� �Ѵ�. �̷� ����
465    ����ϸ� ���װ� �ٰ� �� ���� ���α׷��� ������ �� �ִ�.</p>
466
467    <p>Perl�� CGI ���α׷��� �ۼ��Ѵٸ� <a href="http://www.cpan.org/">CPAN</a>���� ��� ������ ã��
468    �� �ִ�. CGI ���߿� ���� �θ� ���Ǵ� �����
469    <code>CGI.pm</code>�̴�. ��κ��� ���α׷��� ����� �ּ�
470    ����� ������ <code>CGI::Lite</code>�� ����� �� �� �ִ�.</p>
471
472    <p>C�� CGI ���α׷��� �ۼ��Ѵٸ� ������ ������ ����. ����
473    �ϳ��� <a href="http://www.boutell.com/cgic/">http://www.boutell.com/cgic/</a>��
474    �ִ� <code>CGIC</code> ���̺귯����.</p>
475  </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
476<div class="section">
477<h2><a name="moreinfo" id="moreinfo">�� ���� ����...</a></h2>
478    
479
480    <p>���� �ſ� ���� CGI ������ �ִ�. �����׷� <a href="news:comp.infosystems.www.authoring.cgi">comp.infosystems.www.authoring.cgi</a>���� ���� ������
481    CGI ������ ������ �� �ִ�. HTML Writers Guild�� -servers
482    ���ϸ�����Ʈ�� �� ���� ���� ã�⿡ �Ǹ��� ��Ҵ�. <a href="http://www.hwg.org/lists/hwg-servers/">http://www.hwg.org/lists/hwg-servers/</a>���� �� ���� ����
483    �� �� �ִ�.</p>
484
485    <p>�׸��� ���� CGI ���α׷� ���ۿ� ���� ��� ������ ������
486    CGI �Ծ��� �о�� ������ ����. <a href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html">NCSA</a>��
487    �� ������ �ְ�, ������ �ʾ��� <a href="http://web.golux.com/coar/cgi/">Common Gateway Interface
488    RFC ������Ʈ</a>�� �ִ�.</p>
489
490    <p>���ϸ�����Ʈ�� �����׷쿡 ���� �ݰ� �ִ� CGI ������ ����
491    ���Ҷ��� �߻��� ����� �� ����� ���, ������ �߻���
492    ������ ��� �ٸ���, ����ϴ� ����, CGI ���α׷��� �ۼ���
493    ���, �����ϸ� �ش� �ڵ带 �ڼ��� ����. �׷��� �ذ�å��
494    � �������.</p>
495
496    <p>����ġ �ҽ��ڵ尡 �߸�Ǿ�ٰ� Ȯ������ �ʴ� �� CGI ����
497    ����ġ ���� �����ͺ��̽��� �ø��� <strong>����</strong>
498    �ȵȴ�.</p>
499  </div></div>
500<div class="bottomlang">
501<p><span>������ ���: </span><a href="/en/howto/cgi.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
502<a href="/fr/howto/cgi.html" hreflang="fr" rel="alternate" title="Fran&#231;ais">&nbsp;fr&nbsp;</a> |
503<a href="/ja/howto/cgi.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
504<a href="/ko/howto/cgi.html" title="Korean">&nbsp;ko&nbsp;</a></p>
505</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
506<script type="text/javascript"><!--//--><![CDATA[//><!--
507var comments_shortname = 'httpd';
508var comments_identifier = 'http://httpd.apache.org/docs/2.4/howto/cgi.html';
509(function(w, d) {
510    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
511        d.write('<div id="comments_thread"><\/div>');
512        var s = d.createElement('script');
513        s.type = 'text/javascript';
514        s.async = true;
515        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
516        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
517    }
518    else { 
519        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
520    }
521})(window, document);
522//--><!]]></script></div><div id="footer">
523<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
524<p class="menu"><a href="/mod/">���</a> | <a href="/mod/directives.html">���þ��</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">���</a> | <a href="/sitemap.html">����Ʈ��</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
525if (typeof(prettyPrint) !== 'undefined') {
526    prettyPrint();
527}
528//--><!]]></script>
529</body></html>