0

3427

xapian安装(PHP版)

1、scws安装

sudo wget http://www.xunsearch.com/scws/down/scws-1.2.2.tar.bz2
sudo tar -jxvf scws-1.2.2.tar.bz2
cd scws-1.2.2/
./configure --prefix=/usr/local/scws
sudo make && make install
sudo mkdir /usr/include/scws
ln -sf /usr/local/scws/include/scws /usr/include
sudo ln -s /usr/local/scws/lib/libscws.so.1.1.0 /usr/lib/libscws.so
sudo ln -s /usr/local/scws/lib/libscws.so.1.1.0 /usr/lib/libscws.so.1

安装scws扩展 cd phpext phpize ./configure –with-php-config=PHP_HOME/bin/php-config make make install

下载分词库

http://www.xunsearch.com/scws/down/scws-dict-chs-utf8.tar.bz2
sudo tar -jxvf scws-dict-chs-utf8.tar.bz2
cd scws-dict-chs-utf8
sudo mv dict.utf8.xdb /usr/local/scws/

2、安装xapian核心服务

sudo wget http://oligarchy.co.uk/xapian/1.2.17/xapian-core-1.2.17.tar.xz
sudo xz -d xapian-core-1.2.17.tar.xz
sudo tar xvf xapian-core-1.2.17.tar
cd xapian-core-1.2.17
sudo ./configure –prefix=/usr/local/xapian  

如果 报错:

configure: error: Neither uuid/uuid.h nor uuid.h found - required for brass, chert and flint (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)

ubuntu环境下安装依赖库即可:

sudo apt-get install uuid-dev 

报错:

You need a working C++ compiler to compile Xapian
....
xapian ./configure CXX=/opt/bin/c++

ubuntu环境下安装依赖库即可:

sudo apt-get install g++

3、安装xapian客户端(php扩展)

sudo wget http://oligarchy.co.uk/xapian/1.2.17/xapian-bindings-1.2.17.tar.xz
sudo xz -d xapian-bindings-1.2.17.tar.xz
sudo tar xvf xapian-bindings-1.2.17.tar
cd xapian-bindings-1.2.17
sudo ./configure XAPIAN_CONFIG=/usr/local/xapian/bin/xapian-config --with-php PHP_CONFIG=/opt/service/php/bin/php-config

乐果   发表于   2014 年 11 月 29 日 标签:xapianPHPubuntu 继续阅读

0

5861

nginx图片过滤处理模块http_image_filter_module安装配置

一、http_image_filter_module说明

http_image_filter_module是nginx提供的集成图片处理模块,支持nginx-0.7.54以后的版本,在网站访问量不是很高磁盘有限不想生成多余的图片文件的前提下可,就可以用它实时缩放图片,旋转图片,验证图片有效性以及获取图片宽高以及图片类型信息,由于是即时计算的结果,所以网站访问量大的话,不建议使用。

安装还是很简单的,默认HttpImageFilterModule模块是不会编译进nginx的,所以要在configure时候指定

    ./configure arguments: --prefix=/usr/local/nginx --with-http_image_filter_module

PS: HttpImageFilterModule模块需要依赖gd-devel的支持,可以使用yum或apt-get方便地安装,如果未安装回报“/configure: error: the HTTP image filter module requires the GD library.”错误

yum install gd-devel

ubuntu系统:

    apt-get install libgd2-xpm libgd2-xpm-dev

make&&make install后就可以进行配置了,做最简单的配置,先让模块可以跑起来^^

location ~ /simg/.*\.jpg$ {
    #proxy_pass     http://10.11.11.11;
    #rewrite "/simg/(.*\.jpg)$" /img/$1 break ;
    image_filter   resize  100 100;
    error_page     415   = /empty;
}

最后开启nginx,这样访问/simg/目录下的图片,都会按照高度最高100并且宽度最高100按照原图比例进行截取出来,并输出给浏览器。当然也可以开启重写去读取本机另一个目录下源文件;如果不在一台机器上就可以开启proxy_pass,并加上重写即可。

http_image_filter_module支持5种指令:

image_filter:测试图片文件合法性(image_filter test);3个角度旋转图片(image_filter rotate 90 | 180 | 270);以json格式输出图片宽度、高度、类型(image_filter size);最小边缩小图片保持图片完整性(resize width height);以及最大边缩放图片后截取多余的部分(image_filter crop [width] [height]);

image_filter_jpeg_quality:设置jpeg图片的压缩质量比例(官方最高建议设置到95,但平时75就可以了);

image_filter_buffer:限制图片最大读取大小,默认为1M;

image_filter_transparency:用来禁用gif和palette-based的png图片的透明度,以此来提高图片质量。

image_filter_sharpen:这个指令在nginx-1.1.8和1.0.11版本后增加的,目前还不知道是干啥用

二、配置实例

场景:

假如图片请求为(例子): /img001/2015/02/27/sd/gf/df/asdgasdgasgdasldgjhk.jpg

缩略图请求规则为(例子):/img001/2015/02/27/sd/gf/df/asdgasdgasgdasldgjhk.jpg?w=100&h=100

则,nginx的配置如下:

    location ~* "^/src/(.*)\.(jpg|png|gif)$" {
        root /home/root4/imgServer/data;
        try_files /$1.$2 /img/notfount.jpg;
    }

    location ~* "^/img(.*)\.(jpg|png|gif)" {
        root /home/root4/imgServer/data;
        set $img_width "0";
        set $img_height "0";
        set $img_path $uri;
        set $resize_width "-";
        set $resize_height "-";

        if ($arg_h != "") {
            set $img_height $arg_h;
            set $resize_height $arg_h;
        }
        if ($arg_w != ""){
            set $img_width $arg_w;
            set $resize_width $arg_w;
        }

        set $img_empty $img_width$img_height;
        if ($img_empty = "00") {
            rewrite /(.*)\.(jpg) /src/$1.$2 last;
        }

        if ($img_height = "0"){
            set $resize_height "-";
        }
        if ($img_width = "0"){
            set $resize_width "-";
        }
        image_filter resize $resize_width $resize_height;
        image_filter_buffer 10M;
        try_files $img_path /img/notfount.jpg;
    }

乐果   发表于   2014 年 11 月 27 日 标签:nginx 继续阅读

0

2551

ubuntu下编译安装php

先安装必须的依赖库:

sudo apt-get install autoconf
sudo apt-get install libxml2-dev
sudo apt-get install bzip2
sudo apt-get install libcurl3-openssl-dev
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libxpm-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libt1-dev
sudo apt-get install libmcrypt-dev
sudo apt-get install libmysql++-dev
sudo apt-get install libxslt1-dev 
sudo apt-get install libbz2-dev

开始编译安装:

sudo ./configure \
--prefix=/data/service/php53 \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-config-file-path=/data/service/php/etc \
--with-zlib \
--with-curl \
--with-curlwrappers \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-jpeg-dir \
--with-png-dir \
--with-xpm-dir \
--with-freetype-dir \
--with-zlib-dir \
--enable-shared \
--enable-fpm \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap 

##...过程省略

sudo make && sudo make install

ubuntu可能需要的步骤—软链接库文件:

cd /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so .
ln -s /usr/lib/x86_64-linux-gnu/libXpm.a .
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so.4 .
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0 .

需要注意的

有可能因为系统缺少libiconv依赖库libiconv依赖库的路径不对,导致在make或make install步骤中报错。 此时,因检查系统中是否存在libiconv.so等动态库,

    find /usr -name libiconv.so

确定缺少该依赖库时,则下载安装。例如下载了libiconv-1.13.1版本时,安装步骤如下:

cd libiconv-1.13.1
./configure --prefix=/usr/local/lib/libiconv-1.13.1
sudo make
sudo make install

最后重新编译安装php,编译安装前先清除下:

    sudo make clean

在configure参数中加入iconv依赖库的路径

    --with-iconv=/usr/local/lib/libiconv-1.13.1

可能容易出现的报错:

configure: error: freetype.h not found.

freetype明明是使用apt-get安装了的。也可以查询到这个文件 但是就是不行

root@ubuntu:/c2ms/packages/php-5.3.28# cat configure |grep freetype.h      if test -f "$i/include/freetype2/freetype/freetype.h"; then
      { echo "configure: error: freetype.h not found." 1>&2; exit 1; }
      if test -f "$i/include/freetype2/freetype/freetype.h"; then
      { echo "configure: error: freetype.h not found." 1>&2; exit 1; }

结果我按照这个路径查找,果然没这个文件 ubuntu安装的目录文件只是这个:

include/freetype2/freetype.h 

所以

ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype

下次记得cat 不要太相信源码了

乐果   发表于   2014 年 11 月 25 日 标签:ubuntuPHP 继续阅读

0

1356

ubuntu下nginx编译安装

安装依赖库:

sudo apt-get install libgd2-xpm 
sudo apt-get install libgd2-xpm-dev
sudo apt-get install libgeoip-dev
sudo apt-get install libpcre3 
sudo apt-get install libpcre3-dev
sudo apt-get install libssl-dev 
sudo apt-get install openssl
sudo apt-get install libxslt-dev  

编译配置:

./configure \
--prefix=/data/service/nginx \
--sbin-path=/data/service/nginx/sbin/nginx \
--conf-path=/data/service/nginx/conf/nginx.conf \
--pid-path=/data/service/nginx/logs/nginx.pid \
--lock-path=/data/service/nginx/lock/nginx.lock \
--error-log-path=/data/service/nginx/logs/error.log \
--http-log-path=/data/service/nginx/logs/access.log \
--http-scgi-temp-path=/data/service/nginx/scgi \
--http-uwsgi-temp-path=/data/service/nginx/uwsgi \
--http-proxy-temp-path=/data/service/nginx/proxy \
--http-fastcgi-temp-path=/data/service/nginx/fastcig \
--http-client-body-temp-path=/data/service/nginx/body \
--user=www-data \
--group=www-data \
--with-ipv6 \
--with-debug \
--with-file-aio \
--with-rtsig_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_xslt_module \
--with-http_geoip_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-http_random_index_module \
--with-http_image_filter_module 

编译安装:

make && make install

乐果   发表于   2014 年 11 月 22 日 标签:ubuntunginx 继续阅读

0

6937

诱惑美人图

记得在傲基做项目的时候,在mongodb的一个什么技术社区中看到了一张图。

IT的宅男们,看了是不是很提神啊

乐果   发表于   2014 年 11 月 15 日 标签:图片 继续阅读

较旧的文章 较新的文章
热评文章