반응형
1. ScriptAlias : 아파치는 특정 디렉토리를 CGI 프로그램용으로 둔다. 보안상 이유때문에 CGI 프로그램은 ScriptAlias한 디렉토리에 한정
예제 :
# vi /etc/httpd/conf/httpd.conf
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
# cat /var/www/cgi-bin/hello.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";
print "Content-type: text/html\n\n";
print "Hello, World.";
# chmod 755 /var/www/cgi-bin/hello.cgi
# service httpd restart
http://xxx.xxx.xxx.xxx/cgi-bin/hello.cgi
2. 아무 디렉토리에서나 CGI 실행을 허용
1) AddHandler나 SetHandler 지시어를 사용하여 cgi-script 핸들러를 작동
AddHandler cgi-script .cgi .pl
2) Options 지시어에 ExecCGI를 지정
<Directory /usr/local/apache2/htdocs/somedir>
Options +ExecCGI
</Directory>
Options +ExecCGI
</Directory>
예제 :
<VirtualHost *:80>
<Directory /var/www/cgitest>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
DirectoryIndex index.html index.cgi
ServerAdmin iksubyeon@gmail.com
DocumentRoot /var/www/cgitest
ServerName cgitest.kobic.kr
ErrorLog logs/cgitest.kobic.kr_log
CustomLog logs/cgitest.kobic.kr_log common
</VirtualHost>
<Directory /var/www/cgitest>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
DirectoryIndex index.html index.cgi
ServerAdmin iksubyeon@gmail.com
DocumentRoot /var/www/cgitest
ServerName cgitest.kobic.kr
ErrorLog logs/cgitest.kobic.kr_log
CustomLog logs/cgitest.kobic.kr_log common
</VirtualHost>
반응형
'Linux > Apache' 카테고리의 다른 글
Update Apache HTTP Server(2.4.48->2.4.52) (0) | 2021.12.23 |
---|---|
Install Apache HTTP Server (0) | 2021.09.03 |
최근댓글