RHEL/CentOS使用yum update更新时不升级内核的方法

分类:Unix/Linux评论:0条作者:JayKing日期:2011-12-26

RHEL/CentOS/Fedora使用yum update更新时,默认会升级内核。但有些服务器硬件(特别是组装的机器)在升级内核后,新的内核可能会认不出某些硬件,要重新安装驱动,很麻烦。所以在生产环境中不要轻易的升级内核,除非你确定升级内核后不会出现麻烦的问题。

如果不想升级内核而只更新其他软件包,有两种方法:

1、修改yum的配置文件 vim /etc/yum.conf,在[main]的最后添加exclude=kernel*

2、直接在yum的命令后面加上如下的参数:

yum --exclude=kernel* update

.lu域名的启用

分类:Development, Domain评论:2条作者:JayKing日期:2011-11-29

在hexonet管理页面中,执行下面的命令:

command = ModifyDomain
domain = yourdomain.lu
delstatus0 = INACTIVE

hexonet人员的回信,比较详细:

the LU registry performs nameserver-checks during the domain-registration. The status RESERVED means that the check failed during the registration. You will be able to activate your domain, by sending the command as described in 2.) to your system.

1. Information: Name Server settings

The .LU Registry requires, that for any .LU name server the IP address is sent along with the modification request, this is neccessary for the AddDomain, ModifyDomain and TransferDomain – commands .

If the parent domain id not manages through us the IP addresses have to be stated together with the name servers (seperated by a blank space).

Here an example:

1st name server host: ns1.example.lu 1.2.3.4
2nd name server host: ns2.example.lu 1.2.3.5

The registry provides a name server check on their website which is available here: http://www.dns.lu/en/EN-LUTestNoms.php

Example API:

command = ModifyDomain
domain=domain.lu
nameserver0=ns1.example.lu
nameserver1=ns2.example.lu
host0=ns1.example.lu 1.2.3.4
host1=ns2.example.lu 1.2.3.5

2. Status RESERVED

As well as after the add or the modify-domain command it could be that the domain has the status RESERVED This is caused by a server missconfiguration. The status can be removed by sending the following API command to the system:

command = ModifyDomain
domain = yourdomain.lu
delstatus0 = INACTIVE

WAMPServer 安装 Imagick

分类:PHP评论:0条作者:JayKing日期:2011-05-02

1. 下载 Download ImageMagick

#下载页面:

http://www.imagemagick.org/script/binary-releases.php#windows

#直接下载:

http://www.imagemagick.org/download/binaries/ImageMagick-6.6.9-Q16-windows-dll.exe

2. 安装 Install ImageMagick

C:\wamp\bin\ImageMagick-6.6.9-Q16

3. 测试 Testing the Installation
如果不加入环境变量的话,可以先下面方式测试:
Open the command prompt (Run->”CMD”->ENTER) and type in convert and press enter. You should see the help parameters of convert

cd C:\wamp\bin\ImageMagick-6.6.9-Q16 # 回车
C:\wamp\bin\ImageMagick-6.6.9-Q16>convert
Version: ImageMagick 6.6.9-7 2011-04-29 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

Usage: Magick [options ...] file [ [options ...] file …] [options ...] file

Image Settings:
-adjoin join images into a single multi-image file
-affine matrix affine transform matrix
-alpha option activate, deactivate, reset, or set the alpha channel
-antialias remove pixel-aliasing
-authenticate password
decipher image with this password
-attenuate value lessen (or intensify) when adding noise to an image
-background color background color
-bias value add bias when convolving an image
-black-point-compensation
use black point compensation
-blue-primary point chromaticity blue primary point
-bordercolor color border color
-caption string assign a caption to an image
…….
……
……

加入环境变量,方便以后使用(我的是WIndows7 系统):
我的电脑-》右键属性-》高级系统设置-》高级-》环境变量-》系统变量-》
-》找到Path, 点击编辑加入:

C:\wamp\bin\ImageMagick-6.6.9-Q16;

加入完成之后,可以直接在命令行(CMD)使用convert了。

4. 下载DLL Downloading the php_Imagick.dll

Again the version problem, well if you are using PHP 5.2.x this is where you will get your dll.

我使用的是 (php5.2.9-2):php_imagick_dyn-Q16.dll

dyn = dynamic, st = static, q16 = 16 bit, q8= 8 bit. This should match your downloaded version of course. If you downloaded q16 dynamic library, your file will be php_imagick_dyn-Q16.dll

If you are using PHP 5.3.xthis is your location to download.

 

5. Edit PHP.ini
下载的php_imagick_dyn-Q16.dll保存到

C:\wamp\bin\php\php5.2.9-2\ext\

然后编辑 PHP.ini
找到dll这里,加入下面的最后一行:

;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll
extension=php_imagick.dll

6. 重启Wamp
7. 通过查看phpinfo();
如果有imagick项应该成功了

8. 小测试

$im = new imagick( ‘a.jpg’ );
// resize by 200 width and keep the ratio
$im->thumbnailImage( 200, 0);
// write to disk
$im->writeImage( ‘a_thumbnail.jpg’ );

好了,完成了。
参考:

http://blog.hexu.org/archives/713.shtml

http://www.elxsy.com/2009/07/installing-imagemagick-on-windows-and-using-with-php-imagick/

Discuz!批量生成高质量用户头像

分类:PHP评论:0条作者:JayKing日期:2011-05-02

<?php
$dir = './img/';       // 源图片目录
$i = 1;         // 开始的导入用户uid
$size = 'big';        // 生成的图片大小 设置大小 (small,middle,big)

$files1 = scandir($dir);
foreach($files1 as $value) {
if($value!='.' && $value!='..' && $value!='Thumbs.db') {
   $newdir = get_avatar($i,$size);
   copyimage($dir.$value,$newdir,$size);
   $i++;
}
}
//echo $i;

function get_avatar($uid, $size = 'middle', $type = '') {
$size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
$uid = abs(intval($uid));
$uid = sprintf("%09d", $uid);
$dir1 = substr($uid, 0, 3);
$dir2 = substr($uid, 3, 2);
$dir3 = substr($uid, 5, 2);
$typeadd = $type == 'real' ? '_real' : '';
if(!is_dir($dir1)) {
   mkdir($dir1);
}
if(!is_dir($dir1.'/'.$dir2)) {
   mkdir($dir1.'/'.$dir2);
}
if(!is_dir($dir1.'/'.$dir2.'/'.$dir3)) {
   mkdir($dir1.'/'.$dir2.'/'.$dir3);
}
return $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2).$typeadd."_avatar_$size.jpg";
}

function copyimage($upfile,$newfile,$size = 'middle') {
if($size == 'middle'){$px = 160;}
if($size == 'small'){$px = 48;}
if($size == 'big'){$px = 200;}

$image_path=$upfile;
$image_info=getimagesize($image_path);
if($image_info[2]==2) {
   $image2=imagecreatefromjpeg($image_path);
}
$image2_x=imagesx($image2);
$image2_y=imagesy($image2);

if($image2_x > $px) {
   $x = $px;
   $y = intval($px*$image2_y/$image2_x);
} else {
   $y = $image2_y;
   $x = $image2_x;
}
$image1=imagecreatetruecolor($x,$y);
//imagecopyresized($image1,$image2,0,0,0,0,$x,$y,$image2_x,$image2_y);
imagecopyresampled($image1,$image2,0,0,0,0,$x,$y,$image2_x,$image2_y);
$Img = imagejpeg($image1,$newfile,90);
}
?>

iPhone WebApp Meta标记

分类:iOS评论:0条作者:JayKing日期:2011-04-13

<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>

width – viewport的宽度 height – viewport的高度
initial-scale – 初始的缩放比例
minimum-scale – 允许用户缩放到的最小比例
maximum-scale – 允许用户缩放到的最大比例
user-scalable – 用户是否可以手动缩放

css+div背景透明内容和图片不透明

分类:HTML/CSS评论:0条作者:JayKing日期:2011-03-26

<style type="text/css">
body {
     background-color: #0066FF;
}
#div1
{
     position:absolute;
/*---这里定义层不随表格透明而透明
这样就可以使表格透明的时候表格里的
内容和图片不跟着透明了---*/
}
table
{
background-color:#FFFFFF;
filter:alpha(opacity=50,Style=0);
   /*---定义透明度,和淡化的风格
   opacity为透明度,值越大透明度越小
   style是透明淡化的风格
   0 普通透明
   1 从左到右渐变淡化
   2 圆形像两边淡化
   3 星状渐变淡化
   默认不设置style参数为0
   这个效果同样可以用再图片上
   ---*/
width:300;
height:300;
   /*---这里一定要定义宽度和高度---*/
}
</style>
<body>
<table bgcolor="#0000FF" style="display:" id="tab1">
   <tr>
     <td><div id="div1">
       <p>DIV层里的内容</p>
       <p><img src="" width="174" height="59" /></p>
     </div></td>
   </tr>
</table>
</body>

CMake和Configure项目的安装与反安装

分类:Unix/Linux评论:0条作者:JayKing日期:2011-03-09

Configure:
项目安装:
比如用源码包安装gaim 的

./configure --prefix=/opt/gaim
make
make install

如果安装mlterm

./configure --prefix=/opt/mlterm
make
make install

把源码包安装的软件,都指定安装在 /opt目录中 继续阅读…

为Centos5添加网易163、搜狐的yum源

分类:Unix/Linux评论:0条作者:JayKing日期:2011-03-08

先关闭fastestmirror

“vi /etc/yum/pluginconf.d/fastestmirror.conf”     and set “enable=0″

cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS-Base-163.repo
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
yum makecache
yum update

无缝升级nginx手动

分类:Unix/Linux评论:0条作者:JayKing日期:2011-03-08

// 下载软件
# wget http://docs.linuxtone.org/soft/lemp/packages/nginx-0.8.53.tar.gz -P /usr/local/src
# cd /usr/local/src
# tar zxvf nginx-0.8.53.tar.gz
# cd nginx-0.8.53
# ./configure --user=daemon --group=daemon --prefix=/usr/local/nginx/ --with-http_stub_status_module \
--with-http_ssl_module --with-http_sub_module --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_gzip_static_module --with-http_realip_module

// 先make不要make install
# make -j8

// 备份一下nginx
# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

// 在把新objs下的nginx cp到sbin下
# cp objs/nginx /usr/local/nginx/sbin/nginx

// 测试一下
# /usr/local/nginx/sbin/nginx -t 

// 升级
# make upgrade

// 查看是否升级成功
# /usr/local/nginx/sbin/nginx -V

// 升级完成

无缝升级nginx脚本

分类:Unix/Linux评论:0条作者:JayKing日期:2011-03-08

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != "0" ]; then
     echo "Error: You must be root to run this script!"
     exit 1
fi
clear
nv=`/usr/local/nginx/sbin/nginx -v 2>&1`
old_nginx_version=`echo $nv | cut -c22-`
#echo $old_nginx_version
if [ "$1" != "--help" ]; then
#set nginx version
         nginx_version=""
         echo "Current Nginx Version:$old_nginx_version"
         echo "Please input nginx version you want:"
         echo "You can get version number from [url=http://nginx.org/en/download.html]http://nginx.org/en/download.html[/url]"
         read -p "(example: 0.9.5 ):" nginx_version
         if [ "$nginx_version" = "" ]; then
                 echo "Error: You must input nginx version!!"
                 exit 1
         fi
         echo "==========================="
         echo "You want to upgrade nginx version to $nginx_version"
         echo "==========================="
         get_char()
         {
         SAVEDSTTY=`stty -g`
         stty -echo
         stty cbreak
         dd if=/dev/tty bs=1 count=1 2> /dev/null
         stty -raw
         stty echo
         stty $SAVEDSTTY
         }
         echo ""
         echo "Press any key to start...or Press Ctrl+c to cancel"
         char=`get_char`
echo "============================check files=================================="
if [ -s nginx-$nginx_version.tar.gz ]; then
   echo "nginx-$nginx_version.tar.gz [found]"
   else
   echo "Error: nginx-$nginx_version.tar.gz not found!!!download now......"
   wget -c [url=http://nginx.org/download/nginx-]http://nginx.org/download/nginx-[/url]$nginx_version.tar.gz
fi
echo "============================check files=================================="

tar zxvf nginx-$nginx_version.tar.gz
cd nginx-$nginx_version/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
make
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp objs/nginx /usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -t
make upgrade
echo "Upgrade completed!"
echo "Program will display Nginx Version......"
/usr/local/nginx/sbin/nginx -v
cd ../
fi

保存以上代码为update.sh,到linux下面执行就能升级nginx了。