Apache2 서버에 CGI 셋팅

in apache •  7 years ago 

mkdir /var/cgi-bin

and create a file called /var/cgi-bin/echo.pl with the following content:

#!/usr/bin/perl
use strict;
use warnings;
print qq(Content-type: text/plain );
print "hi ";

chomd +x /var/cgi-bin/echo.pl

/var/cgi-bin/echo.pl

Content-type: text/plain

hi

Apache /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

와 같은 형식에 내부에 아래 내용을 추가
ScriptAlias /cgi-bin/ /var/cgi-bin/
<Directory "/var/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted

CGI 모듈 활성화

ls -l /etc/apache2/mods-enabled/ | grep cgi

ls -l /etc/apache2/mods-available/ | grep cgi

-rw-r--r-- 1 root root 115 Jul 20 2013 cgid.conf
-rw-r--r-- 1 root root 60 Jul 20 2013 cgid.load
-rw-r--r-- 1 root root 58 Jul 20 2013 cgi.load
-rw-r--r-- 1 root root 89 Jul 20 2013 proxy_fcgi.load
-rw-r--r-- 1 root root 89 Jul 20 2013 proxy_scgi.load

CGI 모듈 링크

ln -s /etc/apache2/mods-available/cgid.load /etc/apache2/mods-enabled/

ln -s /etc/apache2/mods-available/cgid.conf /etc/apache2/mods-enabled/

ls -l /etc/apache2/mods-enabled/ | grep cgi

lrwxrwxrwx 1 root root 37 Mar 19 14:39 cgid.conf -> /etc/apache2/mods-available/cgid.conf
lrwxrwxrwx 1 root root 37 Mar 19 14:39 cgid.load -> /etc/apache2/mods-available/cgid.load

서비스 재 시작

service apache2 reload

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!