# 1) Container mycgi 생성
docker run -it -d --name mycgi -p 8888:80 centos
# 2) 컨테이너 입성~~
docker exec -it mycgi bash
# 1) nginx yum 설치위한 리포지토리 생성
vi /etc/yum.repos.d/nginx.repo
------------------------------------------------------
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
------------------------------------------------------
# 2) install & 기동/정지
yum -y install nginx
/usr/sbin/nginx
/usr/sbin/nginx -s stop
# 1) 컴파일에 필요한 것들 다운
yum -y install epel-release
yum -y install fcgi-devel automake autoconf spawn-fcgi gcc make
# 2) fcgiwrap download
mkdir -p /emc/down
cd /emc/down
curl -L -O http://github.com/gnosek/fcgiwrap/tarball/master
mv master fcgiwrap.tar.gz
tar zxvf fcgiwrap.tar.gz
cd gnosek.....
autoreconf -i
./configure
make && make install
# 3) nginx 연동설치
vi /etc/nginx/conf.d/bash.conf
------------------------------------------------------------------------
server {
listen 80;
server_name 127.0.0.1;
location ~ \.sh$ {
root /usr/share/nginx/html/;
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
------------------------------------------------------------------------
# 4) fastcgi 설정
vi /etc/sysconfig/spawn-fcgi
>> 마지막 라인에 추가
OPTIONS="-u nginx -g nginx -a 127.0.0.1 -p 9001 -P /var/run/spawn-fcgi.pid -- /usr/local/sbin/fcgiwrap"
# 5) 기동/정지
/etc/init.d/spawn-fcgi start / stop
>>>>> 자동기동 설정
# chkconfig spawn-fcgi on
>>>> 확인
# chkconfig
## 확인 ...
yum -y install net-tools << netstat 사용위해
netstat -atunp | grep 9001 등
# cgi작성
# vi /usr/share/nginx/html/hello.sh
#!/bin/sh
echo 'Content-type: text/html'
echo ''
echo '<html>'
echo '<head></head>'
echo '<body>'
echo '<h1>This is my CGI-test</h1>'
echo '</body>'
echo '</html>'
### 실행권한
chmod 755 /usr/share/nginx/html/hello.sh
###systemctl restart nginx.service
/usr/sbin/nginx
/usr/sbin/nginx -s stop
http://192.168.99.100:8888/hello.sh