Skip to content

Commit 3e52c06

Browse files
author
dxr
committed
Update CHROOTED_DEBIAN_5.0.txt_beta
1 parent 0be9f67 commit 3e52c06

File tree

1 file changed

+60
-8
lines changed

1 file changed

+60
-8
lines changed

docs/CHROOTED_DEBIAN_5.0.txt_beta

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,38 @@
33
# dxr@brutalsec.net
44
# 01-09-2009
55
#
6+
# We can create a script for configure chroot enviroment but,
7+
# YOU MUST UNDERSTAND HOW TO WORK IT for can solve possible
8+
# problems in the future.
9+
#
10+
# Every service has its own chroot enviroment:
11+
# BIND -> chroot
12+
# Apache -> chroot
13+
# Dovecot -> chroot
14+
# Pureftpd -> Apache's chroot
15+
#
16+
# Only apache and php packages aren't installed in real system,
17+
# only in chroot enviroment with symbolic links from real system.
18+
#
19+
# Please, configure chroot enviroment if security is really
20+
# important for you and you known how to work it!
21+
#
22+
23+
exit 1
24+
25+
1. BACKUP before change something in the system
26+
2. Create partitions
27+
3. Remove possible apache or php installations on real system
28+
4. Prepair Chroot enviroment
29+
5. Linking Webserver aplication from real system
30+
6. mini_sendmail
31+
7. Test services
32+
8. Howto install ispconfig3
33+
9. Migration
634

7-
exit 1;
835

9-
1. If is not a new instalation, then
36+
1. BACKUP before change something in the system
37+
# If is not a new instalation, then
1038

1139
BACKUP BACKUP BACKUP BACKUP BACKUP BACKUP
1240
BACKUP BACKUP BACKUP BACKUP BACKUP BACKUP
@@ -31,12 +59,14 @@ mkdir -p /var/www/html/var/log/apache2 /var/www/html/var/www/html
3159
mount /dev/lvm_foobar2/apachelogs_lv /var/www/html/var/log/apache2
3260
mount /dev/lvm_foobar3/hosting_lv /var/www/html/var/www/html
3361

34-
3. Clear apache and php instalation
62+
63+
3. Remove possible apache or php installations on real system
3564
# We never wont install apache or php in non-chroot system, if we have installed, we only have do a backup of confgigurations, uninstall, and check every simbolic link
3665
dpkg -l|egrep --color -i 'apache|php'
3766

38-
4. Prepair chroot enviroment
39-
apt-get install debootstrap libpcre3 libaprutil1 libxml2 mime-support patch make gcc
67+
68+
4. Prepair Chroot enviroment
69+
apt-get install debootstrap libpcre3 libaprutil1 libxml2 mime-support patch make gcc mysql-server
4070
time debootstrap --arch=amd64 lenny /var/www/html/ ftp://ftp.fr.debian.org/debian/
4171

4272
echo "/proc /var/www/html/proc proc defaults 0 0">>/etc/fstab
@@ -63,7 +93,15 @@ mv /usr/lib/php5 /usr/lib/php5_old
6393
mv /etc/apache2 /etc/apache2_old
6494
mv /etc/suphp /etc/suphp_old
6595

66-
chroot /var/www/html apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp libopenssl-ruby libapache2-mod-chroot php-apc
96+
chroot /var/www/html apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp libopenssl-ruby libapache2-mod-chroot php-apc subversion vim
97+
# The non webserver will install outside of chroot
98+
apt-get install libdbi-perl postfix pure-ftpd-mysql amavisd-new clamav-getfiles clamav clamav-freshclam
99+
# If you will use courier:
100+
apt-get install courier-ssl courier-pop-ssl courier-pop courier-imap-ssl courier-imap courier-authdaemon
101+
# If you will use dovecot:
102+
apt-get install dovecot-imapd dovecot-pop3d
103+
# If you will use BIND:
104+
apt-get install bind9 bind9utils
67105

68106
chroot /var/www/html /etc/init.d/apache2 stop
69107

@@ -72,11 +110,15 @@ chroot /var/www/html a2enmod suexec
72110
echo "ChrootDir /var/www/html" > /var/www/html/etc/apache2/conf.d/mod_chroot.conf
73111
sed -i -e 's#DocumentRoot /var/www/#DocumentRoot /var/www/html/#' /var/www/html/etc/apache2/sites-enabled/000-default
74112
sed -i -e 's#x-httpd-php=php:/usr/bin/php-cgi#x-httpd-php=php:/usr/bin/php-cgi\nx-httpd-suphp=php:/usr/bin/php-cgi\nx-httpd-php=php:/usr/bin/php-cgi#' /var/www/html/etc/suphp/suphp.conf
113+
sed -i -e 's#/var/run/apache2.pid#/var/run/apache2/apache2.pid#' /var/www/html/etc/apache2/envvars
114+
sed -i -e 's/^"syntax on/syntax on/' /etc/vim/vimrc
115+
sed -i -e 's/^"syntax on/syntax on/' /var/www/html/etc/vim/vimrc
75116

76117
# Protect apache configuration. ONLY root can read it
77118
chown root:root /var/www/html/etc/apache2/ && chmod 700 /var/www/html/etc/apache2/
78119
chmod 711 /var/www/html/etc/php5/
79120

121+
80122
5. # Is good idea to add nagios alarm for check every simbolic link is correct.
81123
ln -s /var/www/html/etc/apache2 /etc/apache2
82124
ln -s /var/www/html/etc/suphp /etc/suphp
@@ -93,8 +135,13 @@ ln -s /var/www/html/var/log/apache2 /var/log/apache2
93135
ln -s /var/www/html/var/lock/apache2 /var/lock/apache2
94136
ln -s /var/www/html/var/lib/apache2 /var/lib/apache2
95137
ln -s /var/www/html/usr/lib/php5 /usr/lib/php5
138+
#ln -s /var/www/html/usr/bin/php5 /usr/bin/php5
139+
#ln -s /var/www/html/etc/alternatives/php /etc/alternatives/php
140+
#ln -s /var/www/html/usr/bin/php /usr/bin/php
141+
96142

97143
6. # Install mini_sendmail for chroot
144+
# We can use mini_sendmail for delivery emails directy in remote servers, but i prefer to control it in central mailserver for check spammers and limit it.
98145

99146
cd /tmp/
100147
wget http://acme.com/software/mini_sendmail/mini_sendmail-1.3.6.tar.gz
@@ -119,8 +166,10 @@ sendmail_path = /usr/sbin/mini_sendmail -t -i -fhosting@alojamientotecnico.com -
119166

120167
sed -i -e 's#^;sendmail_path =$#sendmail_path = /usr/sbin/mini_sendmail -t -i -fhosting@alojamientotecnico.com -s127.0.0.1#' /var/www/html/etc/php5/apache2/php.ini /var/www/html/etc/php5/cli/php.ini /var/www/html/etc/php5/cgi/php.ini
121168

169+
170+
7.
122171
# Test
123-
chroot /var/www/html/ apache2ctl restart
172+
apache2ctl restart
124173
chroot /var/www/html/
125174

126175
# php -i|grep --color sendmail
@@ -131,9 +180,12 @@ Path to sendmail => /usr/sbin/mini_sendmail -t -i -fhosting@alojamientotecnico.c
131180

132181
# Sould be good idea check /var/www/html/usr/lib/sendmail /var/www/html/usr/sbin/sendmail and /var/www/html/usr/sbin/mini_sendmail with nagios alarm ;)
133182

134-
8. Install ispconfig ........
135183

184+
8. Install ispconfig ........
136185

186+
chroot /var/www/html/
187+
cd /tmp/
188+
svn co svn://svn.ispconfig.org/ispconfig3 svn.ispconfig.org
137189

138190
### Migration to other server ###
139191
Really easy:

0 commit comments

Comments
 (0)