cygwin + init + httpd(apache)
글쓴이: idlock / 작성시간: 화, 2004/05/11 - 9:20오전
cygwin을 이용하여 개인 서버 하나 구축하려는생각에 --;;;;
일단 cygwin에다가 init 를 설치할수가 있더군요. 물론 윈도우즈 서비스로 돌아가고요..
그래서 initd + sshd(성공)를 설치하고.
httpd를 다른곳에서 잘 긁어 와서.. chkconfig --add httpd 하고.
httpd 를 admin 계정으로 실행하면 잘되는데
initd로 실행하면 않된다는거죠 -.-
initd, sshd는 잘 뜨는데 아무리해도 -- httpd는 않뜨는..ㅠ.ㅠ..
var/log
usr/logs
윈도우즈 이벤트 찾아봤는데 어떤 에러로그도 떠있지 않더군요 -.-;;..
자그마한 힌트도 환영합니다. ^^
설정은 아래와 같습니다
$ ./chkconfig.exe --list httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off stunnel 0:off 1:off 2:off 3:off 4:off 5:off 6:off
$ cat inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Things to run in every runlevel. #ud::once:/sbin/update # Trap CTRL-ALT-DELETE (SIGINT on cygwin) #ca::ctrlaltdel:/sbin/shutdown -t3 -r now # When our UPS tells us power has failed, assume we have a few minutes # of power left. Schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powerd installed and your # UPS connected and working correctly. #pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down" # If power was restored before the shutdown kicked in, cancel it. #pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled" # Run agettys in standard runlevels #S0:2345:respawn:/sbin/agetty -L -T vt100 -n ttyS0 9600 ttyS0 # Run xdm in runlevel 5 # xdm is now a separate service #x:5:respawn:/etc/X11/prefdm -nodaemon
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /etc/apache/access.conf
# config: /etc/apache/httpd.conf
# config: /etc/apachesrm.conf
# source function library
. /etc/rc.d/init.d/functions
# the location of the file that will be used to record the process
# id of the running apache server
#
# PIDFILE=/var/run/httpd.pid
PIDFILE=/var/run/httpd.pid
#
# the location of the apache daemon binary
# BINFILE=/usr/sbin/httpd
BINFILE=/usr/sbin/httpd
# See how we were called.
case "$1" in
start)
echo -n "Starting httpd: "
daemon $BINFILE
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down http: "
[ -f "$PIDFILE" ] && {
kill `cat "$PIDFILE"`
echo -n httpd
}
echo
rm -f /var/lock/subsys/httpd
rm -f "$PIDFILE"
;;
status)
status "$BINFILE"
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading httpd: "
[ -f "$PIDFILE" ] && {
kill -HUP `cat "$PIDFILE"`
echo -n httpd
}
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
Forums:


init으로 실행하는 것은 해보질 않았는데.서비스 등록으로 윈도우즈
init으로 실행하는 것은 해보질 않았는데.
서비스 등록으로 윈도우즈 서비스로 사용하실 수 있지 않을까요?
http://tech.erdelynet.com/cygwin-sshd.html
sshd도 그렇게 실행할 수 있는데..
cygrunsrv -S sshd
식으로 말이죠.
rommance.net
답변에 감사드리며. ^^.. initd 하나로 모아놓으면 관리상
답변에 감사드리며. ^^..
initd 하나로 모아놓으면 관리상 편하고 그렇것 같아서요..
최후의 방법은 cygrunsrv가 될듯합니다. ^^
[절반의 성공] cygwin에서 httpd(apache), sshd, xinetd under i
거의 2달 만이군요 -.-
cygwin 상에서 initd 를 기반으로 httpd, sshd, xinetd를 띄우는 데 성공 햇습니다.
문제가 있긴하군요.. -.-.. httd가 initd를 서비스 중지할때 같이 죽지 않는다는... .. 혹시 테스트하시다가 아시면 리플 부탁드리겠습니다.
이하 설치 순서 입니다.(간략)
=-==-=-=-==-=-=-==-=-=-==-=-=-==-=-=-==-=-=-==-=-=-==-=-
0. initd 설정
0.1. cygwin 을 받아서 설치한다. (http://www.cygwin.org)
본인설정 : 몽땅 설치 햇습니다. 머가 필요한지 몰라서 -.-;;;
0.2. windows 환경 변수에 CYGWIN=ntsec를 세팅한다.
본인설정 : CYGWIN=binmode tty ntsec
0.3.
$ /usr/bin/init-config실행본인 설정 :
나머지 질문 다 yes 위 설정 yes하면 linux init 부분 다 자기가 설정해야되는. 고통이.. 전 능력부족으로.. default가 있는것으로하기위하여 no를 선택하였습니다.
0.4. 자동으로 서비스에 등록되는되.. 이름이 init로 되어 있어 구분하기가 불명확합니다.
$ cygrunsrv -R init $ cygrunsrv -I init -d "CYGWIN initd" -p /sbin/init -a -i -s INT1. sshd 설정
1.1.설정 끝
$ ssh-host-config -y세부설정하시고싶으시면 끝에 -y 빼면 되겟죠?
1.2. sshd initd에 추가
$/usr/sbin/chkconfig --add sshd2. xinetd 설정 : xinetd 사용할일이 별로 -.-;;; 없을듯..
2.1. 설정 끝 -.-
$ /usr/bin/xinetd-config -y2.2. xinetd initd에 추가
$ /usr/sbin/chkconfig --add xinetd2.3. /etc/xinetd.d 디렉토리 하위에서 않쓰는 서비스 파일열어서 disable=yes변경
3. httpd
3.1. httpd 실행 가능 여부 판단
3.2. 설정 변경(나머지 설정은 apache 관련 faq 참고할것)
# vi /etc/apache/httpd.conf User nobody Group nobody여기서 중요 windows에 nobody 계정이 없으면, httpd 실행되지않고, log, 파일 처리 등등등의 문제를 처리하기 위하여 신중한 계정 설정이필요
본인 설정 : SYSTEM으로 통일
3.3. init script 설정
init 스크립트를 구해서 설치해봣으나. /proc의 문제로 인하여(다른문제면 알려주심 감사) apachectl 스크립터의 header에 httpd init 스크립트 헤더 추가및 수정
본인 설정 :
#!/bin/sh # # Startup script for the Apache Web Server # # chkconfig: 345 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd < # pidfile: /var/run/httpd.pid # config: /etc/apache/httpd.conf <<<<<<<<<<<<<<<<<<< 수정 # <<<<<<<<<<<<, 여기위 로 추가했음 # Apache control script designed to allow an easy command line interface # to controlling Apache. Written by Marc Slemko, 1997/08/23 # # The exit codes returned are: # 0 - operation completed successfully # 1 - # 2 - usage error # 3 - httpd could not be started # 4 - httpd could not be stopped # 5 - httpd could not be started during a restart # 6 - httpd could not be restarted during a restart # 7 - httpd could not be restarted during a graceful restart # 8 - configuration syntax error # # When multiple arguments are given, only the error from the _last_ # one is reported. Run "apachectl help" for usage info # # # |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| # -------------------- -------------------- # # the path to your PID file PIDFILE=/var/run/httpd.pid # # the path to your httpd binary, including options if necessary HTTPD=/usr/sbin/httpd # # a command that outputs a formatted text version of the HTML at the # url given on the command line. Designed for lynx, however other # programs may work. LYNX="lynx -dump" # # the URL to your server's mod_status status page. If you do not # have one, then status and fullstatus will not work. STATUSURL="http://localhost/server-status" # # -------------------- -------------------- # |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| ERROR=0 ARGV="$@" if [ "x$ARGV" = "x" ] ; then ARGS="help" fi for ARG in $@ $ARGS do # check for pidfile if [ -f $PIDFILE ] ; then PID=`cat $PIDFILE` if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then STATUS="httpd (pid $PID) running" RUNNING=1 else STATUS="httpd (pid $PID?) not running" RUNNING=0 fi else STATUS="httpd (no pid file) not running" RUNNING=0 fi case $ARG in start) if [ $RUNNING -eq 1 ]; then echo "$0 $ARG: httpd (pid $PID) already running" continue fi if $HTTPD ; then echo "$0 $ARG: httpd started" else echo "$0 $ARG: httpd could not be started" ERROR=3 fi ;; stop) if [ $RUNNING -eq 0 ]; then echo "$0 $ARG: $STATUS" continue fi if kill $PID ; then echo "$0 $ARG: httpd stopped" else echo "$0 $ARG: httpd could not be stopped" ERROR=4 fi ;; restart) if [ $RUNNING -eq 0 ]; then echo "$0 $ARG: httpd not running, trying to start" if $HTTPD ; then echo "$0 $ARG: httpd started" else echo "$0 $ARG: httpd could not be started" ERROR=5 fi else if $HTTPD -t >/dev/null 2>&1; then if kill -HUP $PID ; then echo "$0 $ARG: httpd restarted" else echo "$0 $ARG: httpd could not be restarted" ERROR=6 fi else echo "$0 $ARG: configuration broken, ignoring restart" echo "$0 $ARG: (run 'apachectl configtest' for details)" ERROR=6 fi fi ;; graceful) if [ $RUNNING -eq 0 ]; then echo "$0 $ARG: httpd not running, trying to start" if $HTTPD ; then echo "$0 $ARG: httpd started" else echo "$0 $ARG: httpd could not be started" ERROR=5 fi else if $HTTPD -t >/dev/null 2>&1; then if kill -USR1 $PID ; then echo "$0 $ARG: httpd gracefully restarted" else echo "$0 $ARG: httpd could not be restarted" ERROR=7 fi else echo "$0 $ARG: configuration broken, ignoring restart" echo "$0 $ARG: (run 'apachectl configtest' for details)" ERROR=7 fi fi ;; status) $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' ;; fullstatus) $LYNX $STATUSURL ;; configtest) if $HTTPD -t; then : else ERROR=8 fi ;; *) echo "usage: $0 (start|stop|restart|fullstatus|status|graceful|configtest|help)" cat <<EOF start - start httpd stop - stop httpd restart - restart httpd if running by sending a SIGHUP or start if not running fullstatus - dump a full status screen; requires lynx and mod_status enabled status - dump a short status screen; requires lynx and mod_status enabled graceful - do a graceful restart by sending a SIGUSR1 or start if not running configtest - do a configuration syntax test help - this screen EOF ERROR=2 ;; esac done exit $ERROR3.4. httpd init 스크립트 복사
$ cp <만든initscript명> /etc/rc.d/init.d/3.5. httpd initd 추가
$ /usr/sbin/chkconfig --add httpd4. 마무리 작업(졸라 중요)
4.1. /var/하위에 기타 파일들이 쌓이는데(lock, log.. 그다음은 저도 모름니다.)여기 권한 문제가 발생하여 않뜨는경우가 많습니다. 특히 httpd 같은 경우에서는 user를 따로 지정가능하기때문에... initd = httpd = xinetd 하부 user 등을 잘 고려하셔서 /var/ 하위 디렉토릐 쓰기 읽기 권한 설정을 해주시면 됩니다.
본인 설정:
drwxr--r--+ 13 SYSTEM SYSTEM 4096 Jul 7 12:58 var5. 시동(서비스 창에서 마우스로 시작 종료하셔도 됩니다. -.-;; )
6. 프로세스및 서비스 확인
문제점
httpd가 initd가 기동될때는 잘 기동되는데. 멈추면 같이 죽지 않는 문제가 발생합니다.
참고한 link
http://www.bitlink.co.jp/server/cyg_apache.htm
http://ftp.ucr.ac.cr/solrhe/chap29sec247.html
http://www.steadfast.co.jp/technicalinfo/cygwin_install.php
http://www.cygwin.com/ml/cygwin/2003-05/msg00340.html
댓글 달기