下面把lighttpd送进笼子里.
(准确说还是把php送进去)
主要大难点: mysql, extension(如果有装的话)
似曾相识:
mkdir /webroot/{var/run/lighttpd,var/run/cache ,var/log/lighttpd ,var/www/localhost/htdocs} -p
mkdir /webroot/{usr/lib64,bin,usr/bin,lib64,dev,etc,tmp} -p
非64位的同学把lib64改成lib即可
64bit only:cd /webroot
ln -s lib64 lib
cd usr
ln -s lib64 lib
cd /webroot
设备文件,这次多了两个.mkdir dev/pts -p
mknod -m 666 dev/null c 1 3
mknod -m 666 dev/zero c 1 5
mknod -m 666 dev/tty c 5 0
mknod -m 666 dev/pts/0 c 136 0
mknod -m 666 dev/pts/1 c 136 1
mknod -m 644 dev/random c 1 8
mknod -m 644 dev/urandom c 1 9
用户大同小异egrep "(^root)|(lighttpd)" /etc/passwd > etc/passwd
egrep "(^root)|(lighttpd)" /etc/group > etc/group
不过注意一下,lighttpd这个用户还有组都是安装的时候生成的
非gentoo用户要手动建立用户和组.
万能,这就叫万能!APPS="/usr/bin/php-cgi /usr/sbin/lighttpd /usr/lib/libmysqlclient.so.15"
APPS="$APPS `find /usr/lib/php* -name "*.so"`"
find $APPS | xargs ldd | awk '{if ($3 ~ /^[^ (]/) print $3}' | sort | uniq | cpio -pdvuL /webroot
find $APPS | cpio -pdvuL /webroot
第一行对付php,lighttpd,还有该死的mysql client
第二行对付extension.
(lighttpd实际上不是必须的.不过为了兼容性起见还是留下吧)
权限处理chown lighttpd:lighttpd /webroot/var/log/lighttpd
chown lighttpd:lighttpd /webroot/var/run/lighttpd
chown lighttpd:lighttpd /webroot/var/www -R
chmod 1777 tmp
chmod 755 usr -R
最后一个usr这个,偶也不知道为什么,这样一弄就好了.
或许是最开始没做umask 0022?
配置文件,收尾工作cp /lib/ld-linux-* lib
cp -L /etc/{localtime,services,nsswitch.conf,hosts,resolv.conf} etc
cp -L /lib/{libnss_dns.so.*,libnss_files.so.*,libnss_compat.so.*} lib
cp -a /etc/php etc
最后最后最后最后:
/etc/lighttpd.confserver.chroot= "/webroot"
偶配置出来的环境21M大.
ps:
把lighttpd关进冰箱里需要几步?
ps2:
如果给你同样长的时间,
apache,lighttpd “两头大象”你能全关进去不?
方法大同小异.
ps3:
什么? suPHP? 没用过
ps4:
ldd /bin/su | awk '{ print $3; }' | sed 's/\(\/.*\/\(.*\)\)/\1 \2/g' -\
| xargs -l1 --no-run-if-empty cp