[原]centos搭建EvaThumber自动生成缩略图

10 篇文章 0 订阅

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 '<pre>';
        //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;
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值