http://www.lunarforums.com/index.php/topic,38721.0.htmlhttp://www.lunarforums.com/index.php/topic,40573.0.html############################
# install yum:
############################
rpm -ihv --nodeps
http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/yum-2.4.3-4.el4.centos.noarch.rpmrpm -ihv --nodeps
http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.i386.rpmrpm -ihv --nodeps
http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpmyum makecache
###########################
# enable centosplus
###########################
vim /etc/yum.repos.d/CentOS-Base.repo
enabled=1
###########################
# install gcc
###########################
yum remove glibc-dummy-centos-4
yum install gcc
yum install gcc-c++
###########################
# upgrade httpd from 2.0.52 -> 2.0.59, php5 mysql5
###########################
yum update httpd
yum update php
yum install httpd-devel # this is needed for compile apache modle
#######################################
# install eaccelerator
#######################################
cd ~/setup/
mkdir ea/
cd ea/
wget
http://bart.eaccelerator.net/source/0.9.5.1/eaccelerator-0.9.5.1.tar.bz2 bzip2 -d eaccelerator-0.9.5.1.tar.bz2
tar -xf eaccelerator-0.9.5.1.tar
cd eaccelerator-0.9.5.1/
export PHP_PREFIX="/usr"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make; make install
# modify php.ini
vim /etc/php.ini
Search for "Dynamic Extensions" without the quotes. In this section, paste:
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
# Now we need to make the cache directory where all the cache files will be stored.
# mkdir /tmp/eaccelerator/
# chmod 777 /tmp/eaccelerator/
It's configured completely now. Let's restart Apache and test:
# /sbin/service httpd restart
# php -v
##################################
# mod_security, i don't think this is a must have one
##################################
#
http://www.modsecurity.org/documentation/modsecurity-apache/2.1.0/html-multipage/02-installation.html wget
http://www.modsecurity.org/download/modsecurity-apache_2.1.1.tar.gz tar zxf modsecurity-apache_2.1.1.tar.gz
cd modsecurity-apache_2.1.1
cd apache2
vim Makefile
modify one line: top_dir = /etc/httpd
comment one line: # DEFS = -DWITH_LIBXML2
make
service httpd stop
make install
Add one line to your configuration to load ModSecurity: LoadModule security2_module
modules/mod_security2.so
# config it
cd /etc/httpd/conf.d
vim modsecurity.conf
##############################
# mod_evasive, if have CSF, i don't think this one is needed
##############################
wget
http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz tar zxf mod_evasive_1.10.1.tar.gz
cd mod_evasive
/usr/sbin/apxs -cia mod_evasive20.c
##############################
# install CSF , must have
##############################
http://www.configserver.com/free/csf/install.generic.txt###############################
# Portsentry
###############################
http://www.falkotimme.com/howtos/chkrootkit_portsentry/ #change here, to start portsentry after other port listening services#
ln -s /etc/init.d/portsentry /etc/rc3.d/S98portsentry
##############################
#secure Server SSH
##############################
# disable direct root login /Protocol 2
# useradd myrt
# passwd myrt
# vim /etc/ssh/sshd_config
...
# /sbin/service sshd reload
# sudo su -
# Rootkit Hunter /chkrootkit
wget
http://downloads.sourceforge.net/rkhunter/rkhunter-1.2.9.tar.gz?modtime=1159813366&big_mirror=0 wget
ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz tar zxf rkhunter-1.2.9.tar.gz
tar zxf chkrootkit.tar.gz
# cd rkhunter-1.2.9/
# /bin/sh installer.sh
# rkhunter --update; rkhunter -c
cd chkrootkit-0.47/
# make
# ./chkrootkit
This won't actually install a system-wide binary, so you'll have to keep the folder and its contents there for
future use:
##############################
# BFD (Brute Force Detection), if have CSF, don't need this one
##############################
wget
http://www.r-fx.ca/downloads/bfd-current.tar.gz tar -zxf bfd-current.tar.gz
cd bfd-0.9/
./install.sh
vim /usr/local/bfd/conf.bfd
You should enable BFD alerts, and specify your e-mail address so you know if and when your server is being hit,
so you can take additional action if necessary:
Code:
# Enable/disable user alerts [0 = off; 1 = on]
ALERT_USR="1"
# User alert email address
EMAIL_USR="
yourname@domain.com"
save it
# vim /usr/local/bfd/ignore.hosts
127.0.0.1
209.200.241.2
216.227.209.246
your.ip.address.here
After you're done, go ahead and start BFD:
# /usr/local/bfd/bfd -s
#####################################
# Apache OPTIMIZATION/SECURITY
#####################################
vim /etc/httpd/conf/httpd.conf
ServerSignature Off
ServerTokens ProductOnly
Timeout 3
KeepAlive Off
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 5000
</IfModule>
disable some Modules
service httpd restart
#############################
# DDOS
#############################
netstat -ntu | grep ESTAB | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
##################################
# MySql OPTMIZATION/SECURITY
##################################
vim /etc/my.cnf
Use the FLUSH QUERY CACHE statement to defragment the memory structure and avoid unnecessary pruning. No queries
are removed in this operation.
Use the RESET QUERY CACHE statement to clear the cache.
Issue the a SHOW STATUS LIKE 'qcache_%' to see statistics on cache usage.
#####################################
# BIND OPTIMIZATION/SECURITY
#####################################
# vim /etc/named.conf
options {
version "Not available";
fetch-glue no;
}
# service named restart
# service named status
############################
# vpsInfo:
http://www.labradordata.ca/home/13# vnstat : network traffic monitor;
http://humdi.net/vnstat/############################
wget
http://humdi.net/vnstat/vnstat-1.4.tar.gz tar zxf vnstat-1.4.tar.gz
cd vnstat-1.4
make ; make install
vnstat -u -i venet0
vnstat
# wget
http://www.labradordata.ca/downloads/install_beanc.sh # sh install_beanc.sh
vpsinfo.php modify one line so no error in error_log file:
$df_com = "df -h --exclude-type=tmpfs 2>&1";
*Links under Install yum topic updated to the current ones. - Perestrelka*