标签 DirectAdmin 下的文章

DirectAdmin组件ZendGuardLoader,明明安装了探针却显示红叉叉,是因为一般是根据zend_loader.enable判断的,DA没加这些在php.ini,我们手动加上就好了

编辑php.ini,搜索:zend_extension,在底下加上

zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=

然后 service httpd restart 重启下apache使修改生效
至于DirectAdmin PHP.INI的位置可以参考:http://www.cnweed.com/2743.html

[Sun Sep 21 17:37:10 2014] [emerg] (28)No space left on device: Couldn't create accept lock (/var/log/httpd/accept.lock.8411) (5)

下午收到监控邮件有台DirectAdmin服务器Apache服务无法启动,检查错误日记后,发现如上错误。首先df -h检查硬盘是否饱和,然后ipcs -s检查ipc,发现是ipc不足。如下所示

# ipcs -s 
------ Semaphore Arrays -------- 
key semid owner perms nsems 
0x00000000 19234816 apache 600 1 
0x00000000 19267585 apache 600 1 
0x00000000 19300354 apache 600 1 
0x00000000 19398659 apache 600 1 
0x00000000 19431428 apache 600 1 
0x00000000 19464197 apache 600 1 
0x00000000 19562502 apache 600 1
………………

执行如下命令清除然后重启Apache即可

ipcs -s | grep apache | perl -lane 'print `ipcrm sem $F[1]`'
service httpd restart

引起这个问题的原因可能是apache没有被正确的关闭。写了个简单的shell可以加入crontab定期执行

#!/bin/bash
rm -rf /var/log/weed/ipcs.log
ipcs -s >> /var/log/weed/ipcs.log
ipcslist=`grep -c "" /var/log/weed/ipcs.log`
if [ "$ipcslist" -ge "20" ]; then
ipcs -s | perl -ane '/^0x00000000/ && `ipcrm -s $F[1]`'
echo $(date) "Ipc crowded, clean up" >> /var/log/weed/ipcs_clean.log
fi

Named is not reloading correctly when I add a domain

On some systems, the named boot script provided with the bind rpms don't seem to reliably reload the named program. You can obtain a new named boot script by running the following:

RedHat:

cd /etc/init.d
mv named named.backup
wget -O named http://www.directadmin.com/named
chmod 755 named
/sbin/chkconfig named reset

This boot script uses a more direct method of reloading named.

其他操作系统请访问来源:http://help.directadmin.com/item.php?id=40

最近发现有台DA机器的Apache总是自动重启,每次大概1-3分钟,检查apache日记、tcp和80端口连接后发现是挂QQ的程序导致的,接下来扫描用户php文件就好了

screen -S scan
find /home/* -type f -name "*.php" |xargs grep "pt.3g.qq.com" > scan.txt

现在挂QQ程序一般是用手机网页QQ,关键词是 pt.3g.qq.com ,扫描完成后会保存在 scan.txt 文件中

从DA 1.24版本开始,就有了这项功能,可以使用DirectAdmin创建自己的服务监控。可以将自己的服务名称加入/usr/local/directadmin/data/admin/services.status页面,DirectAdmin的dataskq会一直保持该服务的监测。

在services.status其中添加:

servicename=ON

或者:

servicename=OFF

如果服务名称在此列表中,ON表示dataskq会监测这个服务,OFF则意味着不会监测,和其他的功能类似,如果你在DirectAdmin面板中点击“停止”按钮,DirectAdmin也会将上面的值设置为OFF。

除此之外,下面的代码依旧有用,可以用它来自定义需要监测监控的服务。

很多的管理员会在Linux系统上运行很多的软件,DirectAdmin不会核对和监控他们,来确保它们一直运行,下面的脚本会让管理员能够监测 程序的运行状况,作为一个例子,我们在这里监测一个spamd程序。用你自己的具体信息,替换下面的部分内容:

#!/bin/sh
COUNT=`ps -ax | grep -v grep | grep -c spamd`
if [ $COUNT -eq 0 ]; then
    #the command used to start spamd
    /usr/bin/spamd -d -c -m 5
 
    sleep 3
 
    COUNT=`ps -ax | grep -v grep | grep -c spamd`
    if [ $COUNT -eq 0 ]; then
    echo -e "Subject: spamd is downnnspamd is downn.nn" | /usr/sbin/exim your@email.com
    fi
fi
exit 0;

将这段脚本改为自己的脚本之后,用chmod命令将其权限改为755,然后设置一个定时的脚本来检测这个脚本是否运行即可,DirectAdmin将会每分钟检测一次程序的运行状况,但是,脚本不能在程序挂掉之后确定是否发了邮件,所以如果你的程序一直挂在那里,那么你的邮箱估计会在每一分钟就收到一封警告邮件,所以监控的时间间隔设置为5到10分钟就足够了。

参考:http://www.defel.net/create-your-own-service-monitoring-with-directadmin.html

增加 Pure-FTPD 的支持

unified_ftp_password_file 选项必须为 1 和所有 passwords 要转换:
参考:http://www.directadmin.com/features.php?id=1134

pureftp=1

该选项也要设置为 1.

After any change to the /etc/proftpd.passwd file, DA will add a task.queue entry:
action=rewrite&value=pureftp_db

and the dataskq will call:
/usr/bin/pure-pw mkdb /etc/pureftpd.pdb -f /etc/proftpd.passwd

安装方式:
使用custombuild安装:

cd /usr/local/directadmin/custombuild
./build set proftpd no
./build set pureftpd yes
./build pureftpd

请记住,这是在测试阶段,可能会发生错误。

如果你发现proftpd仍然在运行,运行以下命令

chkconfig proftpd off
service proftpd stop

需要提醒,Pure-FTPD可能会面临被爆破扫描的危险,DA目前无法屏蔽Pure-FTPD穷举的IP,CSF也是。
如果需要转换回来,在安装方式那替换下开启proftpd,关闭pureftpd,然后编译proftpd。

参考:http://www.directadmin.com/features.php?id=1143

比方你现在运行PHP 5.2.11,希望降级/升级到5.2.2。你可以通过编辑versions.txt文件来实现。

cd /usr/local/directadmin/custombuild
./build set autover no
vi versions.txt

在文件中查找这两行

php5:5.2.11:0223d71f0d6987c06c54b7557ff47f1d
php5-mail:5.2.11:85a62ef3d069403c29604730e02da9c8

替换为

php5:5.2.2:
php5-mail:5.2.2:

保存文件退出,输入以下命令

./build update_data
./build php n

下载地址:http://www.custombuild.eu/plugin/custombuild.tar.gz
登入 DirectAdmin 管理员,插件管理,增加插件,输入下载地址以及DA管理员密码,点击安装。

完成后登入SSH执行以下命令

cd /usr/local/directadmin
wget -O custombuild.tar.gz http://files1.directadmin.com/services/custombuild/2.0/custombuild.tar.gz
tar xvzf custombuild.tar.gz
cd custombuild
./build

登入DA控制面板,进入CustomBuild配置。首次需要进入SSH执行以下命令:

cd /usr/local/directadmin
cd custombuild
./build all d

更多详细介绍以及注意事项:
http://forum.directadmin.com/showthread.php?t=44743
http://forum.directadmin.com/showthread.php?t=48989

2015年1月13日更新!

在DirectAdmin管理员面板的Brute Force Monitor(穷举监视器)里,我们可以看到proftpd、sshd、exim等一直被暴力猜解,系统消息一封又一封的发过来遭到暴力猜解成百上千次都是同一个IP的行为,这是非常危险的,但我们不可能时刻关注消息手动一个一个的去封锁。我们可以结合CSF来实现自动封锁穷举IP!

cd /usr/local/directadmin/scripts/custom/
cp block_ip.sh block_ip.sh.bak
cp unblock_ip.sh unblock_ip.sh.bak

如果你没有 block_ip.sh 和 unblock_ip.sh 文件,会提示如下警告:

cp: cannot stat `block_ip.sh': No such file or directory
cp: cannot stat `unblock_ip.sh': No such file or directory

现在获取文件:

cd /usr/local/directadmin/scripts/custom/
wget -O block_ip.sh http://files.plugins-da.net/dl/csf_block_ip.sh.txt
wget -O unblock_ip.sh http://files.plugins-da.net/dl/csf_unblock_ip.sh.txt
wget -O show_blocked_ips.sh http://files.plugins-da.net/dl/csf_show_blocked_ips.sh.txt
chmod 700 block_ip.sh show_blocked_ips.sh unblock_ip.sh

创建白名单和黑名单文件

touch /root/blocked_ips.txt
touch /root/exempt_ips.txt

这时候你已经可以从 Brute Force Monitor 里手动选择IP地址禁止,但不会自动封锁。如果你想自动封锁,安装以下脚本

cd /usr/local/directadmin/scripts/custom
wget -O brute_force_notice_ip.sh http://files.directadmin.com/services/all/brute_force_notice_ip.sh
chmod 700 brute_force_notice_ip.sh

如果没有意外,这时候应该可以自动封锁穷举IP了。