月度归档:2014年05月

ubuntu安装php的redis扩展

下载安装扩展

首先下载包,http://pecl.php.net/package/redis

sudo aptitude install php5-dev
sudo wget http://pecl.php.net/get/redis-2.2.5.tgz
sudo tar zxf redis-2.2.5.tgz 
cd redis-2.2.5/
sudo phpize
sudo ./configure
sudo make
sudo make install

修改ini配置

sudo vim /etc/php5/fpm/conf.d/redis.ini

extension=redis.so

测试运行

sudo php5-fpm -t
sudo php5-fpm -m
sudo service php5-fpm reload

ubuntu安装最新的xhprof

安装xhprof

aptitude install python-software-properties
add-apt-repository ppa:brianmercer/php5-xhprof
aptitude update
aptitude install php5-xhprof graphviz

其中graphviz包用来生成图形

xdebug配置

使用以下配置时,默认不开启PROFILE,只有当GET,POST,COOKIE存在XDEBUG_PROFILE时才会生效

zend_extension=xdebug.so
xdebug.auto_trace=0
xdebug.trace_enable_trigger=1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.trace_output_dir = "/var/log/xdebug"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "/var/log/xdebug"
;xdebug.profiler_output_name = "cachegrind.out.%t.%p"

linux下jdk+ant安装

下载JDK安装jdk

可以将url换成其他版本,URL在http://www.oracle.com/technetwork/java/javaee/downloads/index.htm

mkdir -p /opt/java
cd /opt/java
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin"
chmod u+x jdk-6u45-linux-x64.bin
ln -s jdk-6u45-linux-x64 default

下载安装ant

wget http://mirrors.cnnic.cn/apache//ant/binaries/apache-ant-1.9.4-bin.tar.gz
tar zxf apache-ant-1.9.4-bin.tar.gz 
ln -s apache-ant-1.9.4 ant

修改profile

vim /etc/profile.d/sun-jdk.sh

export JAVA_HOME=/opt/java/default
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:.
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:.:$CLASSPATH

# ant
export ANT_HOME=/opt/java/ant
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:.:$ANT_HOME/bin

使用left join替代not exists查询

使用 NOT EXISTS

SELECT  table1.column1,  table1.column2
      FROM table1
          WHERE NOT 
              EXISTS (
                    SELECT table2.column1, table2.column2
                    FROM table2
                    WHERE table2.column1= table1.column1
                    AND table2.location_id= 6
                )
      GROUP BY Barcode

使用 LEFT JOIN

SELECT  table1.column1,  table1.column2
   FROM table1
   LEFT JOIN table2
   ON table2.column1= table1.column1
     AND table2.location_id= 6
   WHERE table2.column1 is null
   GROUP By Barcode