给DirectAdmin装上IP黑名单杜绝密码穷举攻击

1.备份防火墙配置文件,并从DA官方下载新的防火墙配置文件:
cd /etc/init.d mv iptables iptables.backup wget http://files1.directadmin.com/services/all/iptables chmod 755 iptables

警告:DA官方提供的防火墙配置文件中打开的是SSH的默认端口22,如果你的SSH端口不是22,则会造成你无法远程登录!!!解决办法是下载DA的防火墙配置文件以后手动编辑它的端口白名单,使你自己定义的SSH端口为打开状态.

重启防火墙:
/etc/init.d/iptables restart

2.下载脚本block_ip.sh,该脚本可以列出IP黑名单,执行下述命令来安装这些脚本:
cd /usr/local/directadmin/scripts/custom wget http://files1.directadmin.com/services/all/block_ip.sh wget http://files1.directadmin.com/services/all/show_blocked_ips.sh wget http://files1.directadmin.com/services/all/unblock_ip.sh chmod 700 block_ip.sh show_blocked_ips.sh unblock_ip.sh

3.创建空的IP黑名单:
touch /root/blocked_ips.txt touch /root/exempt_ips.txt

4.最后一步不是必须的,但是为了避免自己被误拉黑,所以需要在进行上面设置后使用过一段时间而没有出现问题的时候再进行这一步。
自动将可疑IP加入黑名单,执行以下命令:
cd /usr/local/directadmin/scripts/custom wget http://files1.directadmin.com/services/all/brute_force_notice_ip.sh chmod 700 brute_force_notice_ip.sh

安装DirectAdmin后的常见问题

一.DirectAdmin磁盘和流量统计信息不正确,用户磁盘占用和流量统计始终为0

出现这种情况的原因通常是系统的计划任务有问题,DA官方给出的解决方案如下:
1.检查/usr/local/directadmin/data/task.queue文件是否存在,如果存在,且包含几条信息,那么就表示数据统计没有运行,因为这个文件正常情况下会定期删除。
2.检查/var/log/cron文件(如果是Debian的话,检查/var/log/syslog),看dataskq是否每分钟运行一次,如果不是,执行:
chmod 644 /etc/cron.d/directadmin_cron
/sbin/service crond restart

3.确保crond服务运行正常:
ps ax | grep cron
4.重启cron服务:
service crond restart
如果你的系统未安装crond,则先执行下述命令安装crond:
yum -y install vixie-cron cronie
启动crond:
service crond start
设置开机启动:
chkconfig crond on
5.如果上述一切都检查完毕,但是task.queue依旧不正常的话,执行下述命令手动运行dataskq:
/usr/local/directadmin/dataskq d

给PHP安装配置XCache3加速器

1.下载Xcache
wget http://xcache.lighttpd.net/pub/Releases/3.0.0/xcache-3.0.0.tar.gz
2.解压:
tar zxvf xcache-3.0.0.tar.gz
3.更改目录:
cd xcache-3.0.0
4.编译so:
/usr/local/php5/bin/phpize
5.安装:
./configure -with-php-config=/usr/local/php5/bin/php-config -enable-xcache --enable-xcache-optimizer make make install
6.修改php.ini文件:
vi /usr/local/etc/php5/cgi/php.ini
在文件末尾添加(记得把汉字替换为实际内容):
extension = "第5步编译后的xcache.so文件路径" xcache.admin.auth = On xcache.admin.user = "此处填写你设置的用户名" xcache.admin.pass = "此处填写你设置的密码的MD5值" xcache.size = 32M xcache.shm_scheme = "mmap" xcache.count = 4 xcache.slots = 8K xcache.ttl = 0 xcache.gc_interval = 0 xcache.var_size = 16M xcache.var_count = 1 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.test = Off xcache.readonly_protection = Off xcache.mmap_path = "/dev/zero" xcache.coredump_directory = "" xcache.cacher = On xcache.stat = On xcache.optimizer = Off

7.复制htdocs到网站根目录下xcache文件夹:
mkdir /var/www/html/xcache cp -R htdocs/* /var/www/html/xcache cd /var/www/html/xcache cp config.example.php config.php chown -R webapps:webapps *
在config.php文件末尾添加(把下面的汉字替换为实际内容):
$_SERVER["PHP_AUTH_USER"] = "此处填写你想要的用户名"; $_SERVER["PHP_AUTH_PW"] = "此处填写你想要的密码原文";

打开浏览器访问http://IP/xcache,输入上面设置的帐号和密码进入Xcache的测试页面

PHP5.3下加速器ZendGuardLoader安装

由于Zend新产品ZendGuardLoader的面世,Zend Optimizer已经不支持php5.3了,官方给出的版本是ZendGuardLoader代替,ZendGuardLoader的安装还是和原版差不多的:

官方下载地址,需要登录 http://www.zend.com/products/guard/downloads

下面的版本是已经找出来的下载地址,能直接下载。

Windows 版本Zend Guard Loader下载
http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-Windows.zip

Linux 32位Zend Guard Loader 下载:
wget -c http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz

Linux 64位Zend Guard Loader 下载:
wget -c http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz

解压源码包(注意如果是32位系统,记得把下面的x86_64替换成i386):

tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz mv ZendGuardLoader-php-5.3-linux-glibc23-x86_64 ZendGuardLoader cd ZendGuardLoader/ mkdir -p /usr/local/zend/ cp php-5.3.x/ZendGuardLoader.so /usr/local/zend/

在php.ini文件最后面加上:

[Zend Guard Loader] zend_extension="/usr/local/zend/ZendGuardLoader.so" zend_loader.enable=1 zend_loader.disable_licensing=0 zend_loader.obfuscation_level_support=3 zend_loader.license_path=

#结束后重启apache

在phpinfo 里能看到

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies

出现 Zend Guard Loader v3.3 则说明安装成功。