<-
Apache > HTTP Server > Documentation > Version 2.4 > How-To / Tutorials

����ġ ���丮��: Server Side Includes �Ұ�

������ ���:  en  |  es  |  fr  |  ja  |  ko 

�� ������ �ֽ��� ������ �ƴմϴ�. �ֱٿ� ����� ������ ���� ������ �����ϼ���.

Server-side includes�� ����Ͽ� HTML ������ ������ ������ �߰��� �� �ִ�.

Support Apache!

����

top

�Ұ�

�� ���� ���� SSI��� �θ��� Server Side Includes�� �����Ѵ�. SSI�� �����ϵ��� ������ �����ϴ� ����� HTML �������� ������ ������ �߰��ϴ� �⺻���� SSI ������ �Ұ��Ѵ�.

�� ���� �޺κ��� SSI ���þ� ���ǹ��� ���� ���ޱ���� �����Ѵ�.

top

SSI�� ������

SSI (Server Side Includes)�� HTML �������� ����ϴ� ���þ��, �������� �����Ҷ� ������ ó���Ѵ�. SSI�� ����ϸ� CGI ���α׷��̳� �ٸ� ������ ����� ������ ��ü�� ���� �������� �ʰ��� HTML �������� �������� ������ ������ �߰��� �� �ִ�.

SSI�� ������� �ƴϸ� ���α׷����� ������ ��ü�� �������� ������ ���������� ������ �κ��� �������� �������� ������ ������ ��������� �ٽ� ����ؾ������� �޷ȴ�. SSI�� ���� �ð��� ���� ���� ������ �߰��ϴµ� ����. �׷��� �������� �����Ҷ� �������� ��κ��� �����ؾ� �Ѵٸ� �ٸ� ����� ã�ƺ��� �Ѵ�.

top

SSI�� �����ϵ��� ���� �����ϱ�

������ SSI�� ó���Ϸ��� apache2.conf �����̳� .htaccess ���Ͽ��� ���� ���þ ����ؾ� �Ѵ�.

Options +Includes

�׷��� ����ġ�� ���Ͽ��� SSI ���þ ó���Ѵ�. �������� ���� ���� Options ���þ �ְ�, �� ���þ���� ���� ����Ἥ ��ȿ�� �����. �׷��� ���þ �Ǹ������� ó���ϱ����� ���� SSI�� ���ϴ� Ư�� ���丮���� Options�� ����Ѵ�.

��� ���Ͽ��� SSI ���þ ó���ϴ� ���� �ƴϴ�. ����ġ���� � ������ ó������ �˷���� �Ѵ�. �ΰ��� ����� �ִ�. �ϳ��� ������ ���� ���þ�� .shtml�� ���� Ư�� ���� Ȯ���ڸ� ���� ������ ó���ϴ� ����̴�.

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

�� ����� ������ �̹� �ִ� �������� SSI ���þ �߰��ϴ� ��� SSI ���þ ó���ϱ����� .shtml Ȯ���ڸ� �ο��ϱ⶧���� ���ϸ��� �� �������� ��� ��ũ�� �����ؾ� �ϴ� ���̴�.

�ٸ� ����� XBitHack ���þ ����ϴ� ����̴�.

XBitHack on

XBitHack�� ��������� �ִ� ���Ͽ��� SSI ���þ ó���Ѵ�. �׷��� �̹� �ִ� �������� SSI ���þ �߰��Ѵٸ� ���ϸ��� �������� �ʰ� chmod�� ���Ͽ� ��������� �ָ� �ȴ�.

chmod +x pagename.html

���� ���ƾ� �� �� �ϳ�. ���� .shtml ���ϸ��� ��ġ�� �������� ��� .html ������ SSI ó���϶�� ����ϴ� ����� �ִ�. �� ������� �Ƹ��� XBitHack�� ���� �𸣴� �� ����. ������ ���� �̷��� �ϸ� ����ġ�� ���Ͽ� SSI ���þ ������ Ŭ���̾�Ʈ�� ������ ��� ������ ������� �Ѵٴ� ���̴�. ������ �ſ� ������ �� ������, ���� ������ �ƴϴ�.

���� ����������� ��������̶� ���� ���⶧���� ���ڸ� ����� �� ����.

������ �����̿��� ����ϱ� ��Ʊ⶧���� ����ġ �⺻ ������ SSI �������� �ֱټ����ϰ� content length HTTP ����� ������ �ʴ´�. �׷��� ������ ij������ ���ϰ� Ŭ���̾�Ʈ�� ������ ������ ��������. �ΰ��� �ذ����� �ִ�.

  1. XBitHack Full ������ ����Ѵ�. �׷��� ����ġ�� �����ϴ�(include) ���ϵ��� �������� ������ü ���� ��û�� ������ ��¥�� ���� �ֱټ������� �˾Ƴ���.
  2. mod_expires�� �ִ� ���þ ����Ͽ� ���Ͽ� ���� �������� �����ϸ� �������� ���Ͻð� ������ ij���� �� �ִ�.
top

�⺻ SSI ���þ�

SSI ���þ��� ������ ������ ����.

<!--#element attribute=value attribute=value ... -->

HTML �ּ����� ����⶧���� SSI ����� �������� �ʾƵ� HTML �ҽ����� �������� �������� �����Ѵ�. SSI�� �ùٷ� �����ϸ� ���þ ��������� �ٲ۴�.

element�� ������ �ϳ���. ���� ȸ�� �� �ڼ��� ������ ���̴�. ������ SSI�� �� �� �ִ� ��� ���� ���δ�

���� ��¥

<!--#echo var="DATE_LOCAL" -->

echo element�� �������� �״�� ����Ѵ�. CGI ���α׷��� �����ϴ� ȯ�溯���� �ܿ��� ���� ǥ�� ������ �ִ�. ��, set element�� ����Ͽ� ���� ������ ������ ���� �ִ�.

��¥ ��� ������ ������ ���� �ʴ´ٸ�, ������ ���� config element�� timefmt attribute�� ����Ѵ�.

<!--#config timefmt="%A %B %d, %Y" -->
Today is <!--#echo var="DATE_LOCAL" -->

������ ������

�� ������ <!--#flastmod file="index.html" -->�� ���������� �����Ǿ���

�� element�� timefmt ���� ������ �޷ȴ�.

CGI ���α׷� ����� �����ϱ�

�Ϲ����� SSI ������ �ϳ���, ���̵� �ֿ��ϴ� ``�湮�� ī����'' ���� CGI ���α׷� ����� ����Ѵ�.

<!--#include virtual="/cgi-bin/counter.pl" -->

top

�߰� ����

������ HTML ������ ����� �� �ִ� ��� SSI ������.

�� ������ ���� ���������� �����Ǿ���?

�տ��� SSI�� ����Ͽ� ����ڿ��� ������ �ֱټ������� �˸� �� �ִٰ� ���ߴ�. �׷��� ���� ����� �˷����� �ʾҴ�. ���� �ڵ带 HTML ������ ����ϸ� �������� �ð� ����� �����. ���� ������ �����Ѵ�� SSI�� �ùٷ� �۵��ؾ� �Ѵ�.

<!--#config timefmt="%A %B %d, %Y" -->
�� ������ <!--#flastmod file="ssi.shtml" -->�� ���������� �����Ǿ���;

���� ssi.shtml��� ���ϴ� ���� ���ϸ��� ����Ѵ�. �ƹ� ���������� �ٿ����� �� �ִ� �����ڵ带 ���Ѵٸ�, ���ϸ� ��� LAST_MODIFIED ������ ����Ѵ�.

<!--#config timefmt="%D" -->
This file last modified <!--#echo var="LAST_MODIFIED" -->

timefmt ���Ŀ� ���� �ڼ��� ������ �˻��������� strftime�� ã�ƺ���. ������ ����.

ǥ�� ������ �ϴ��� �����ϱ�

���� �������� �ִ� ����Ʈ�� �����Ѵٸ� ������ ��ü�� �����ϴ� ����, Ư�� ���������� ǥ�� �ܰ��� �������� �����ϴ� ���� ������ ���Ӵ�.

������ ���(header)�� �ϴ�(footer)�� ���Ϸ� �����Ͽ� �̷� ������ �δ��� �� �� �ִ�. ��� ���������� include SSI ���ɾ ����Ͽ� ������ �ϴ� ���� �ϳ��� �����ϸ� �ȴ�. include element�� file attribute�� virtual attribute�� ������ ������ �����Ѵ�. file attribute�� ���� ���丮�� ������� ���ϰ�δ�. ��, (/�� �����ϴ�) �������ϰ�γ� ��� �ȿ� ../�� ����� �� ����. �Ƹ��� �����ϴ� ������ ��� URL�� ������ �� �ִ� virtual attribute�� �� ������ ���̴�. ��θ� /�� ������ �� ������, �����Ϸ��� ������ �����ϴ� ���ϰ� ���� ������ �־�� �Ѵ�.

<!--#include virtual="/footer.html" -->

���� ���� �� �ΰ����� ���ļ� ������ ������ �ϴ� ���Ͽ� LAST_MODIFIED ���þ �ִ´�. �����Ϸ��� ���Ͽ��� SSI ���þ ���� �� ������, �̷��� ������ ������ �ٸ� ������ �����ϴ� ������ ������ ��� ������ ���� �ִ�.

top

�̿ܿ� ������ �� �ִ� ����?

�ð� ���� config(����) �ܿ� �ΰ����� �� config(����)�� �� �ִ�.

���� SSI ���þ �߸��Ǹ� ������ ���� ������ ���´�

[an error occurred while processing this directive]

�� ������ �����ϰ� �ʹٸ� config element�� errmsg attribute�� ����Ͽ� �����Ѵ�.

<!--#config errmsg="[It appears that you don't know how to use SSI]" -->

����Ʈ�� �����ϱ� ���� ��� SSI ���þ� ������ �ذ��Ͽ� ����ڰ� �̷� ������ ���� �ʱ� �ٶ���. (�׷���?)

�׸��� sizefmt attribute�� ��ȯ�ϴ� ����ũ�� ������ config(����)�� �� �ִ�. ����Ʈ�� ũ�⸦ �����ַ��� bytes, ������ Kb�� Mb�� ũ�⸦ �����ַ��� abbrev�� ����Ѵ�.

top

���ɾ� �����ϱ�

���� ���� �޿� ���� CGI ���α׷��� SSI�� ���� ����ϴ� ���� �� �����̴�. ������ exec element�� �� �� �ִ� �ٸ� �͵��� ������ ���̴�. SSI�� ���� ���� (��Ȯ���� /bin/sh�� Win32�� ����Ѵٸ� DOS ��) ����Ͽ� ���ɾ �����Ѵ�. ���� ���, ������ ���丮 ����� �����ش�.

<pre>
<!--#exec cmd="ls" -->
</pre>

or, on Windows

<pre>
<!--#exec cmd="dir" -->
</pre>

dir ��¿� �������� ȥ���� ``<dir>'' ���ڿ��� ���Ե��ֱ⶧����, ��������� �� ���þ ����ϸ� ����� ���� �̻��� ���̴�.

�� ����� exec �±׿� ����� � ���ɾ�� ������ �� �ֱ⶧���� �ſ� �����ϴ�. ``�����''�� ���� ����ڰ� �������� ������ ������ �� �ִ� ȯ���̶��, �� ����� ����� ����ؼ� �ȵȴ�. Options ���þ IncludesNOEXEC �ƱԸ�Ʈ�� ����Ͽ� SSI�� ��������� exec ����� ���� �� �ִ�.

top

���� SSI ���

������ ����ϴ� ��� �ܿ� ����ġ SSI�� ���� ������ �����ϰ�, �񱳹��� ���ǹ��� �� ������ ����� �� �ִ�.

���

�� �ۿ��� �����ϴ� ��κ��� ����� ����ġ 1.2 ���ĺ��� ����� �� �ִ�. ����, ����ġ 1.2 �̻��� ������� �ʴ´ٸ� �Ƹ��� ���� ���׷��̵��ؾ� �Ѵ�. �ض�. ���� �ض�. ��ٸ� ���̴�.

���� ����

set ���þ ����Ͽ� ���߿� ����� ������ ������ �� �ִ�. ������ ������ �ʿ��ϱ⶧���� ���� �����Ѵ�. ������ ������ ����.

<!--#set var="name" value="Rich" -->

������ ���� ���� ���ڱ״�� �������� �ʰ� ȯ�溯���� ������ ������ ����(���� ���, LAST_MODIFIED)�� ���� �ٸ� ������ ����Ͽ� �������� ������ ���� �ִ�. �̶� ������ �տ� �޷� ǥ��($)�� �ٿ��� ���ڿ��� �ƴ� �������� ǥ���Ѵ�.

<!--#set var="modified" value="$LAST_MODIFIED" -->

�������� �޷� ���ڸ� �״�� �Է��Ϸ��� �޷� ǥ�� �տ� �齽������ ����Ѵ�.

<!--#set var="cost" value="\$100" -->

���������� �� ���ڿ� �߰��� ������ ����ϴµ� �ڿ� �ִ� ���ڵ� ���������� �����Ͽ� ȥ���Ǵ� ���, �������� ���ȣ�� ��� Ȯ���� �Ѵ�. (���� ���� ã�� ��������, ���� ������ �����ϱ� �ٶ���.)

<!--#set var="date" value="${DATE_LOCAL}_${DATE_GMT}" -->

���� ǥ����

������ �����ϰ� ���� �� ������ ���ǹ��� �����ϴ�. ���� SSI�� ������ ������ ���α׷��־� �ȴ�. mod_include�� ���ǹ��� ����� if, elif, else, endif ������ �����Ѵ�. ���� �� �������� ���� �������� �������� ���� �� �ִ�.

���ǹ� ������ ������ ����.

<!--#if expr="test_condition" -->
<!--#elif expr="test_condition" -->
<!--#else -->
<!--#endif -->

test_condition���� � �����񱳶� ����� �� �ִ�. ���� �ٸ� ���� ���ϰų�, Ư�� ���� ``��''���� �˻��Ѵ�. (���ڿ��� ������� ������ ���̴�.) ��밡���� �� �����ڸ� ��� ������, mod_include ������ �����϶�. ������ ���ǹ��� ����� ��� ������.

�������Ͽ� ���� ���� �߰��Ѵ�.

BrowserMatchNoCase macintosh Mac
BrowserMatchNoCase MSIE InternetExplorer

Ŭ���̾�Ʈ�� ��Ų��ÿ��� �����ϴ� Internet Explorer��� ȯ�溯�� ``Mac''�� ``InternetExplorer'' ��� ������ �����Ѵ�.

�׸��� SSI ������ ������ ���� ���´�.

<!--#if expr="${Mac} && ${InternetExplorer}" -->
���⿡ ������� ���´�
<!--#else -->
���⿡ ���� JavaScript �ڵ尡 ���´�
<!--#endif -->

���� ��Ų��� IE�� �ݰ��� �ִ� ���� �ƴϴ�. ���� ���� �����ֿ� �ٸ� �������� ������ ���� JavaScript �ڵ尡 ��Ų��� IE������ �������� �ʾƼ� ��ð��� �����ߴ�. ���� �ӽ� �ذ�å�̴�.

(���� �����Ͽ��� �Ϲ� ȯ�溯���̰�) � ������ ���ǹ��� ����� �� �ִ�. �ƶ�ġ�� SetEnvIf�� �ٸ� ���� ���þ�� ȯ�溯���� ������ �� �ֱ⶧���� CGI ���̵� ������ ������ ������ ���� �� �ִ�.

top

���

SSI�� Ȯ���� CGI�� ������ ���������� �����ϴ� �ٸ� ����� ��ü�� �� ����. �׷��� ���� �߰� �۾����� �������� ������ ������ ���� �߰��ϱ⿡�� �Ǹ��� ����̴�.

������ ���:  en  |  es  |  fr  |  ja  |  ko 

top

Comments

Notice:
This is not a Q&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 mailing lists.