Centos 安装tengine

http://tengine.taobao.org/

安装pcre和openssl

yum install pcre-devel
yum -y install openssl openssl-devel
wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
tar -zxvf tengine-2.1.0.tar.gz
cd tengine-2.1.0.
./configure
make
sudo make install

ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx

PHP 判断上传文件的mime类型

Drupal默认的上传我也不知道是不是属于bug. 当你只允许上传.jpg的图片时。如果我将一个.php的文件后缀改成.jpg也能够正常上传。以下我写了一个修复脚本

/**
 * Implements hook_file_validate
 */
function mymodulename_file_validate($file) {
  $errors = array();
  $mime = mime_content_type(drupal_realpath($file->uri));
  if($mime != $file->filemime) {
    $errors[] = t('Upload error, the file format is not valid.');
  }
  return $errors;
}