2014年4月

DirectAdmin 主机开通后有个临时访问地址:http://ServerIP/~username/
如果安装了suPHP,通过该地址是无法解析PHP文件的,会抛出500错误。

关于原因引用DirectAdmin官方帮助文档

By default, suPhp is compiled in "paranoid" mode. This means that the settings in the user httpd.conf files:
“suPHP_UserGroup username username
will require all php files to be owned by username or suPhp will throw a "500 Internal Server Error".

This does not apply to domains, when used normally, because each domain has it's own VirtualHost with the suPHP_UserGroup inside it using the correct settings.

The ~username (UserDir) method will fail in paranoid mode, because there is not a virtualhost for each ~username path, and no suPHP_UserGroup settings for each user, hence you get the 500 error.

因为suPHP_UserGroup默认安装是owner模式,所以通过http://ServerIP/~username/地址访问suPHP不会通过,PHP程序用域名访问才会通过。解决办法是将owner模式修改为paranoid模式。可以登入SSH输入以下命令完成:

cd /usr/local/directadmin/custombuild
mkdir -p custom/suphp
cp -fp configure/suphp/configure.suphp custom/suphp/configure.suphp
perl -pi -e 's/paranoid/owner/' custom/suphp/configure.suphp
./build clean
./build suphp
cd /usr/local/directadmin/data/templates/custom
cp -f ../virtual_host* .
perl -pi -e 's/suPHP_UserGroup/#suPHP_UserGroup/' virtual_host*.conf
perl -pi -e 's/suPHP_UserGroup/#suPHP_UserGroup/' /etc/httpd/conf/httpd.conf
perl -pi -e 's/suPHP_UserGroup/#suPHP_UserGroup/' /etc/httpd/conf/extra/httpd-directories-*.conf
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

Which will change all references of suPHP_UserGroup to #suPHP_UserGroup, basically, just commenting them out.



还有一种方法不需要改变suPhp,但只针对但个用户,如果需要尝试的话编辑文件

/etc/httpd/conf/extra/httpd-includes.conf

添加以下内容

<Directory "/home/username">
      <IfModule mod_suphp.c>
               suPHP_Engine On
               suPHP_UserGroup username username
               SetEnv PHP_INI_SCAN_DIR /usr/local/directadmin/data/users/username/php/
       </IfModule>
</Directory>

重启apache服务:service httpd restart

本文档内容参考引用自DirectAdmin官方帮助中心:http://help.directadmin.com/item.php?id=176

#!/bin/bash
runck=`ps -fe |grep "httpd" |grep -v "grep" |wc -l`
if [ $runck -eq 0 or 1 ]; then
  sudo service httpd restart
else
  echo “run status starting” >>/var/log/run.log
fi

本文参考学习:
http://www.linuxqq.net/archives/160.html
http://wangyan.org/blog/pid-auto-reboot-shell-html.html
http://www.fushanlang.com/blog/linux-shell-jin-cheng-jian-kong-yu-zi-dong-zhong-qi-2236/

有个用户的MySQL数据库表在phpMyAdmin中显示使用中,提示已经损坏
MySQL的错误日记提示:Table ‘xxx’ is marked as crashed and should be repaired

如果和野草主机一样服务器安装了phpMyAdmin,登入进去,选中有问题的表,滑倒网页底部,有“选中项”的,打开选项,点击“修复表”,即可修复。

1.显示最后20行

tail -n 20 文件名

如tail -n 20 log.txt

2.显示中间20,从1000开始

cat log.txt|tail -n +1000|head -n 20

注:tail -n +行号 意思为 从第多少行开始 ,如果是 tail -n -行 == tail -n 行 意思为文件末尾多少行的数据
head -n 20 前20行的数据

3.也可以用sed命令

如 sed -n '100,120p' log.txt 100 到120行的数据。

参考学习:http://www.cnblogs.com/tuozi001/archive/2013/01/10/2855617.html