VPS server init

From campisano.org
Jump to navigation Jump to search

Virtual Private Server basic config


32bit vs 64bit


Outside chroot

  • SSHD on port 10022
nano /etc/ssh/sshd_config # Port 10022

Hostname

echo SERVERNAME > /etc/hostname
cd /etc
git add .
git commit -m "hostname set up"

Timezone

dpkg-reconfigure tzdata # Choose Etc -> UTC

rsyslog

apt-get install rsyslog
cd /srv/config/init.d/
ln -s /etc/init.d/rsyslog
cd ../rc.d/
ln -s ../init.d/rsyslog S10_rsyslog
ln -s ../init.d/rsyslog K90_rsyslog
/srv/config/init.d/rsyslog start

cron

apt-get install cron

echo "*/10 * * * * root run-parts /etc/cron.10min" >> /etc/crontab
echo "00 5 * * * root run-parts /etc/cron.daily_5h" >> /etc/crontab
mkdir /srv/config/etc/cron/cron.daily_4h
mkdir /srv/config/etc/cron/cron.10min
mkdir /srv/config/etc/cron/cron.1min
mkdir /srv/config/etc/cron/cron.daily
mkdir /srv/config/etc/cron/cron.hourly
mkdir /srv/config/etc/cron/cron.monthly
mkdir /srv/config/etc/cron/cron.weekly
cat > /srv/config/etc/cron/crontab << EOF
# /srv/config/etc/cron/crontab

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin

#m h   dom   mon   dow   user   command
07 *   *     *     *     root   cd /tmp && run-parts --report /srv/config/etc/cron/cron.hourly
15 5   *     *     *     root   cd /tmp && run-parts --report /srv/config/etc/cron/cron.daily
40 5   *     *     7     root   cd /tmp && run-parts --report /srv/config/etc/cron/cron.weekly
50 5   1     *     *     root   cd /tmp && run-parts --report /srv/config/etc/cron/cron.monthly

00 4   *     *     *     root   cd /tmp && run-parts --report /srv/config/etc/cron/cron.daily_4h
*/1 *  *     *     *     root   cd /tmp && run-parts --report /srv/config/etc/cron/cron.1min
*/10 * *     *     *     root   cd /tmp && run-parts --report /srv/config/etc/cron/cron.10min

ln -s /srv/config/etc/cron/crontab /etc/cron.d/srv_crontab
cd /srv/config/init.d/
ln -s /etc/init.d/cron
cd ../rc.d/
ln -s ../init.d/cron S30_cron
ln -s ../init.d/cron K70_cron
/srv/config/init.d/cron start
cd /etc
git add .
git commit -m "cron set up"

exim

apt-get install exim4
dpkg-reconfigure exim4-config # choose 'internet site; mail is sent and received directly using SMTP'
nano /etc/default/exim4 # QUEUERUNNER='queueonly'
cd /srv/config/init.d/
ln -s /etc/init.d/exim4
cd ../rc.d/
ln -s ../init.d/exim4 S20_exim4
ln -s ../init.d/exim4 K80_exim4
/srv/config/init.d/exim4 start
cd /etc
git add .
git commit -m "exim set up"

Email Monitor

WARNING: The packages gawk and bc are a prerequisite:

apt-get install gawk bc


  • Create the runnable file /etc/cron.10min/HiLoadMonitor

HiLoadMonitor


  • Create the runnable file /etc/cron.10min/HiMemoryMonitor

HiMemoryMonitor


  • Create the runnable file /etc/cron.hourly/hiDiskEmailer

HiDiskMonitor


  • Save the history
cd /etc
git add .
git commit -m "email monitor set up"