Skip to content

Instantly share code, notes, and snippets.

@mauricioprado00
Last active November 1, 2017 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricioprado00/737044bb689afe3e6b4d627956d9a394 to your computer and use it in GitHub Desktop.
Save mauricioprado00/737044bb689afe3e6b4d627956d9a394 to your computer and use it in GitHub Desktop.
apache chrooted debian
# requires (on ubuntu: apt-get install -y debootstrap)
thisdir=./squeeze-distro
# create chroot system
# debootstrap stable ${thisdir} http://ftp.us.debian.org/debian
debootstrap --arch i386 squeeze ${thisdir} http://archive.debian.org/debian/
# mount devices
dirs=(/dev /dev/pts /dev/shm /tmp)
for d in "${dirs[@]}"; do
mount -o bind $d ${thisdir}${d}
done #mount -o bind /array_x $thisdir/array_x
mount -t proc none ${thisdir}/proc
mount -t sysfs none ${thisdir}/sys
# install apache
linux32 chroot ${thisdir} /usr/bin/apt-get install -y --allow-unauthenticated apache2
# change apache index
mv ${thisdir}/var/www/index.html ${thisdir}/var/www/index.html.orig
cat <<MYINDEX > ${thisdir}/var/www/index.html
<html>
<body>
<h1>this is my chrooted apache</h2>
</body>
</html>
MYINDEX
#start server
linux32 chroot ${thisdir} /etc/init.d/apache2 start
exit
# stop server
linux32 chroot ${thisdir} /etc/init.d/apache2 stop
# unmounting it
umount $thisdir/{proc,sys}
dirs=(/dev /dev/pts /dev/shm /tmp)
for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
umount "$thisdir${dirs[i]}"
done
#umount $thisdir/array_x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment