EvaThumber部署文档
[1] 安装curl,composer.phar组件
yum -y install curl ##已安装跳过 cd /usr/local/bin alias php='/usr/local/php/bin/php' ##已映射跳过 curl -s http://getcomposer.org/installer | php chmod a+x composer.phar alias composer='/usr/local/bin/composer.phar'
[2] 安装EvaThumber
cd /home/wwwroot/img0.xxx.com git clone git://github.com/AlloVince/EvaThumber.git mv EvaThumber evathumber ##重命名符合各个项目命名 cd evathumber composer install composer -V ##检查是否安装成功
[3] 配置Nginx的URL重写
1>mkdir /usr/local/nginx/conf/img0.xxx.com.conf 2>log_format img0.xxx.com.conf '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; server { listen 80; server_name img0.xxx.com; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/evathumber/; include img0.xxx.com.conf; location / { if (!-e $request_filename){ rewrite ^/(.*)$ /index.php last; } } location ~ .*\.(php|php5)?$ { try_files $uri =404; include fastcgi_params; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; fastcgi_param SCRIPT_FILENAME /home/wwwroot/evathumber/$fastcgi_script_name; } access_log /home/wwwlogs/test.img.com.log test.img.xxx.com; }
[4] EvaThumber添加项目配置
cd /home/wwwroot/evathumber/ cp config.default.php config.local.php vim config.local.php //输入格式: return array( 'thumbers' => array( 'item' => array( 'source_path' => '/home/wwwroot/test.img.com/item/upload', 'system_file_encoding' => 'UTF-8', 'zip_file_encoding' => 'GB2312', 'thumb_cache_path' => '/home/wwwroot/test.img.com/item/upload/thumb', ) ) );
[5] 修改EvaThumber项目,添加可以识别类似http://img0.xxx.com/thumb/item/logo-20140530-538842f8990b8,w_400.jpg
cd /home/wwwroot/evathumber/src/EvaThumber vim Url.php //修改下面两个方法 public function getImagePath() { $urlImagePath = $this->getUrlImagePath(); $urlImagePathArray = explode('/', ltrim($urlImagePath, '/')); $urlImageOtherArray = explode('-', ltrim($urlImagePath, '/')); //echo ''; //print_r($urlImageOtherArray); if(count($urlImageOtherArray) == 0) { if(count($urlImagePathArray) < 4){ return ''; } //remove url key array_shift($urlImagePathArray); //remove imagename array_pop($urlImagePathArray); $this->imagePath = '/'. implode('/', $urlImagePathArray); } else { $endNode = end($urlImagePathArray); $leftNode = explode(",", $endNode); $childNode = explode("-", $leftNode[0]); array_pop($childNode); $this->imagePath = '/' . implode('/', $childNode) . '/'; } return $this->imagePath; } public function getImageName() { $urlImageName = $this->getUrlImageName(); if(!$urlImageName){ return $this->imageName = ''; } $fileNameArray = explode('.', $urlImageName); if(!$fileNameArray || count($fileNameArray) < 2){ return $this->imageName = ''; } $fileExt = array_pop($fileNameArray); $fileNameMain = implode('.', $fileNameArray); $fileNameArray = explode(',', $fileNameMain); if(!$fileExt || !$fileNameArray || !$fileNameArray[0]){ return $this->imageName = ''; } $fileNameMain = array_shift($fileNameArray); $extNameList = explode("-", $fileNameMain); //update by kewen if(count($extNameList) > 0) { $this->imageName = end($extNameList) . '.' . $fileExt; } else { $this->imageName = $fileNameMain . '.' . $fileExt; } return $this->imageName; //return $this->imageName = $fileNameMain . '.' . $fileExt; }