?????? Apache ? jail environment ??? FreeBSD
? ?????? ?????? ????? ??????????? ????????? Apache ? jail ?? ??????? ????? apache13-modssl. ?? ?????? ????????? ?????? ??? ???? ?????? apache+mod_ssl-1.3.28+2.8.15.
1. ?????? man jail(8) ?? ??????? ?????????, ??? ?? jail ?? ???? ????????????.
# man jail
2. ??????? ??????????, ??????? ????? ?????? ???????? ??????? jail environment:
# mkdir -p /usr/jails/apache
3. ????????????? apache13-modssl ?? ?????? ? ??? ??????????:
# cd /usr/ports/www/apache13-modssl
# make PREFIX=/usr/jails/apache install clean
4. ??????????? ???????????????? ???? /usr/jails/apache/etc/apache/httpd.conf. ?????????? ????????, ??? ?????? ???????? ??????? ??? ????????? ? jail ????? ??????? /usr/jails/apache, ? ?????????????? ????????? ??? ?????? ????. ????????, ?????? ?????????
ServerRoot "/usr/local"
?????????? ????????
ServerRoot "/"
, ? ??????
DocumentRoot "/usr/local/www/data"
??????
DocumentRoot "/www/data"
???????????????? ???? ??????? ????? ??? ?????? ?????????? ????????? sed(1), ????????, ???:
# cat /usr/jails/apache/etc/apache/httpd.conf | sed -e 's//usr/local////g' > temp.conf
# mv temp.conf /usr/jails/apache/etc/apache/httpd.conf
5. ??????? ??????????? ??? ?????? ????????.
# cd /usr/jails/apache
# mkdir -p dev usr/libexec usr/lib var/log var/run
6. ?????????? ??????????? ? jail environment ??? ??????????? ???????????? ????? httpd ??????????. ?????????? ?????? ??????? ??????? strings(1). ??????? strings ??????? ??? ????????? ?????? ?? ?????????? ?????. ????????? ??? ?????????? ?????? shared library, ?????????? grep(1) ??? ????????? ?????? ?????:
# strings /usr/jails/apache/sbin/httpd | grep ".so"
????? ??????? ????? ???????? ?????:
/usr/libexec/ld-elf.so.1
libcrypt.so.2
libmm.so.13
libc.so.4
????? ? ??????? ??? ?????? find(1) ??? locate(1) ??? ??????????, ????????? ?? ? ???????? jail environment:
# cd /usr/jails/apache
# cp /usr/libexec/ld-elf.so.1 usr/libexec
# cp /usr/lib/libcrypt.so.2 usr/lib
# cp /usr/local/lib/libmm.so.13 usr/lib
# cp /usr/lib/libc.so.4 usr/lib
???? ?? ???????? ???????????? OpenSSL, ??????????? ????? ????????? ??????????:
# cp /usr/lib/libssl.so.3 usr/lib
# cp /usr/lib/libcrypto.so.3 usr/lib
7. ???????? ?????? ????? ?? ???????? /etc:
# cd /usr/jails/apache
# cp /etc/passwd /etc/group /etc/spwd.db etc
# cp /etc/resolv.conf etc
8. ????? ????? ?????? ? jail, ???????? ?? ???? ?? ip-??????????? alias ???????? ifconfig(8):
# ifconfig xl0 alias 10.0.0.10/32
???????? ???? IP ? /usr/jails/apache/etc/hosts, ???? ???????? ?????? ???????? ? DNS:
# echo "10.0.0.10 test.mydomain.org" > /usr/jails/apache/etc/hosts
9. ????????? Apache ? jail:
# jail /usr/jails/apache test.mydomain.org 10.0.0.10 /sbin/httpd -DSSL -f /etc/apache/httpd.conf
?????????, ?????????? ?? httpd:
# ps x | grep httpd
????????? ?????? ???? ???????? ?????:
20617 ?? SsJ 0:00,07 /sbin/httpd -DSSL -f /etc/apache/httpd.conf
???? J ????????? ?? ??, ??? ??????? ??????? ? jail.
????????? ??????????? HTTP-???????:
# telnet 10.0.0.3 80
Trying 10.0.0.3...
Connected to 10.0.0.3.
Escape character is '^]'.
???? ???????? httpd ?? ?????-?? ??????? ?? ???????????, ??????? ??????? ?????? ? ???? (?? ????????? ? ????? ??????? ??? ???? /usr/jails/apache/var/log/httpd-error.log).
10. ???????? ????????? ?????? jailed-httpd ??? ???????? ???????. ????? ??????? ??????? ?????? /usr/local/etc/rc.d/apache.sh (?? ?????? ??????? chmod +x ?? ????):
<_CUT_>
#!/bin/sh
IFACE=xl0 # Jail IP interface name
case "$1" in
start)
ifconfig $IFACE alias 10.0.0.10/32
jail /usr/jails/apache test.mydomain.org 10.0.0.10 /sbin/httpd -DSSL -f /etc/apache/httpd.conf && echo -n ' apache'
;;
stop)
ifconfig $IFACE -alias 10.0.0.10
kill `cat /usr/jails/apache/var/run/httpd.pid` && echo -n ' apache'
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac
exit 0
<_CUT_>
--
??????: man: jail(8), chroot(2), httpd(8), grep(1), find(1), strings(1), rc.conf(5);
Apache documentation.
--
(c) Sergey V. Belov (aka Argail) 2003 mailto: argail@csite.ru
argail.csite.ru/unixdocs/freebsd/Apache_in_jail_on_FreeBSD.html
 |