您的性格类型倾向为“ ENFJ ”(外向 直觉 情感 判断)

才储分析:您的性格类型倾向为“ ENFJ ”(外向 直觉 情感 判断)

温情,有同情心,反应敏捷,有责任感。非常关注别人的情绪、需要和动机。善于发现他人的潜能,并希望能帮助他们实现。能够成为个人或群体成长和进步的催化剂。忠诚,对赞美和批评都能做出积极地回应。友善好社交。在团体中能很好地帮助他人,并有鼓舞他人的领导能力。

ENFJ型的人热爱人类,他们认为人的感情是最重要的。而且他们很自然地关心别人,以热情的态度对待生命,感受与个人相关的所有事物。由于他们很理想化,按照自己的价值观生活,因此ENFJ型的人对于他们所尊重和敬 佩的人、事业和机构非常忠诚。他们精力充沛、满腔热情、富有责任感、勤勤勤恳恳、锲而不舍。 ENFJ型的人具有自我批评的自然倾向。然而,他们对他人的情感具有责任心,所以ENFJ型的人很少在公共场合批评人。他们 敏锐地意识到什么是(或不是)合适的行为。他们彬彬有礼、富有魅力、讨人喜欢、深谙社会。ENFJ型的人具有平和的性格与忍耐力,他们长于外交,擅长在自己的周围激发幽默感。他们是天然的领导者,受人欢迎而有魅 力。他们常常得利于自己口头表达的天份,愿意成为出色的传播工作者。 ENFJ型的人在自已对情况感受的基础上做决定,而不是基于事实本身。他们对显而易见的事物之外的可能性,以及这些可能性以怎样的方式影响他人 感兴趣。 ENFJ型的人天生具有条理性,他们喜欢一种有安排的世界,并且希望别人也是如此。即使其他人正在做决定,他们还是喜欢把问题解决了。 ENFJ型的人富有同情心和理解力,愿意培养和支持他人。他们能很好地 理解别人,有责任感和关心他人。由于他们是理想主义者,因此他们通常能看到别人身上的优点。

您适合的领域有:培训、咨询、教育、新闻传播、公共关系、文化艺术

您适合的职业有:(该类型存在的盲点和发展建议见完整分析报告

· 人力资源培训主任
· 销售经理
· 小企业经理
· 程序设计员
· 生态旅游业专家
· 广告客户经理
· 公关专业人士
· 协调人
· 交流总裁
· 作家/记者
· 非营利机构总裁
· 杂志编辑
· 电视制片人
· 市场专员
· 社会工作者
· 人力资源管理
· 职业指导顾问
· 心理咨询工作者    现在就去心理问题解答区实习下!
· 大学教师(人文学科类)
· 教育学、心理学研究人员
· 撰稿人
· 节目主持人(新闻、采访类)
· 公共关系专家
· 社会活动家
· 文艺工作者
· 平面设计师
· 画家
· 音乐家

世界上的风云大事,归根结底,都不重要。最重要的是个人的生活,这才是伟大变革的所在,整个未来、世界的整个历史,最终都是对个人潜在能量的宏大总结。

——- 卡尔.G.荣格

Posted in 未分类 | Leave a comment

百度 相册体验

http://baike.baidu.com/album/764737/23212.html

Posted in 未分类 | Leave a comment

CentOS5.4上将Python版本升级到2.6.5

1.  背景

CentOS5.4自带的Python版本是2.4.3,但是目前许多基于Python的应用软件要求的Python版本应要高于2.4。(如Robot Framework2.5要求Python版本至少是2.5)

2.  目标

将CentOS自带的Python由2.4.3版本升级到2.6.5版本。

3.  实施

(1)下载/安装python

下载Python2.6.5.tar.bz2(下载地址: http://www.python.org/ftp/python/2.6.5/Python-2.6.5.tar.bz2)

$tar jxvf  Python2.6.5.tar.bz2

$cd Python2.6.5

$./configure

$make && make install

自此,python2.6安装后路径默认是在/usr/local/lib/python2.6

查看Python版本:

$ /usr/local/bin/python2.6 -V

(2)建立软连接,使系统默认的python指向python2.6

正常情况下即使python2.6安装成功后,系统默认指向的python仍然是2.4.3版本,考虑到yum是基于python2.4.3才能正常工作,不敢轻易卸载。如何实现将系统默认的python指向到2.6版本呢?

mv /usr/bin/python  /usr/bin/python.bak

ln -s //usr/local/bin/python2.6 /usr/bin/python

检验python指向是否成功

python -V

(3) 解决系统python软链接指向python2.6版本后,yum不能正常工作

方法:

$vi /usr/bin/yum

将文本编辑显示的#/usr/bin/python修改为#/usr/bin/python2.4,保存修改即可

Posted in Linux, python | Leave a comment

Sniff Your iPhone’s Network Traffic

http://blog.jerodsanto.net/2009/06/sniff-your-iphones-network-traffic/

http://www.51testing.com/html/37/n-111337.html

Ever wanted (or needed) to see your iPhone’s network traffic? All you need is a wireless LAN and the cross-platform proxy application, Paros. There are other proxy server’s that can be used, but Paros was built for web application security assessments, so it provides an intimate hook into the HTTP request/response flow. Let’s get started!

1) Download and Install Paros

Grab the download from the Paros site. Your install process will differ depending on your O/S, but they’ve provided some install instructions here. Everybody will need the Java Runtime Environment 1.4 or above.

2) Configure Paros

Once installed, launch Paros and find the configuration options (on OS X they are under Tools -> Options). Paros is configured by default to listen on localhost only, but we are going to route our iPhone’s traffic through Paros, so we need to set it to listen on the IP address of the interface connected to the same LAN as the iPhone.

My LAN’s network is 1.1.1.0/16, so I’ll configure the Local Proxy address accordingly:

paros_config

That should be the only setting that we need to fuss with. Paros is all set and listening on port 8080, let’s configure the iPhone to route its traffic through our proxy!

3) Configure iPhone

On the iPhone, open the “Settings” app and navigate to the Wi-Fi page. Once there, edit the settings for the wireless network you are currently connected to (this needs to be the same network where your proxy is running). To do this, click the little blue arrow on the right side of the screen.

config_wifi

Now, scroll all the way to the bottom of the settings page and change the “HTTP Proxy” setting to manual. Enter the IP address and port number of your Paros Proxy.

config_proxy

All set! Now all web traffic to and from the iPhone is routed through Paros. Let’s go see what we can see.

4) Using Paros

The main section of Paros is the “Request/Response/Trap.” As the iPhone talks through Paros to Internet sites, it will display the iPhone’s request and the server’s response. The “trap” functionality allows you to stop either the request or the response and view/modify it before sending it along to the recipient. Trapping is very cool, and why Paros is used for security auditing, but for our purposes we just want to see what is going on, so I won’t explain it any further.

For now, let’s see what happens when we fire up my iPhone’s “App Store” app:

In the bottom section of the screen is the history viewer. There we can see that my iPhone made 4 requests to different servers ( 3 GETs and 1 POST):

history

Highlighting the first GET in the history list shows its details. The iPhone’s HTTP request header looked like this:

request

One noteworthy tidbit is that the iPhone is sending a custom header (X-Apple-Connection-Type) which tells the server that it is connected to WiFi. Next, let’s take a look at the server’s response:

response

Notice that in the response we see both the headers that the server returned AND the response data itself, in this case an xml plist file.

Sniffing traffic like this can help you understand how different iPhone apps work behind the scenes or it can help debug interaction for an app that you’re writing. Hope this helps you get started!

Posted in iphone | Leave a comment

跨iPhone和Android全新开发平台发布!

泡泡网iPhone频道7月14日 移动互联网市场的重要性目前被越来越多的人认识到了。在国外,Google收购AdMob,苹果发布iAd、GameCenter服务;国内,三大运营商和各大终端厂商相继发布自己的应用商店,民间的应用商店也如火如荼接踵而至……

为了争夺移动互联网这块正在迅速发展的巨大蛋糕,各大厂商、服务商是卯足了劲儿磨拳擦掌蓄劲儿拼搏。

目前在中国,移动互联网运营模式成熟用户群充足,可是为了什么优秀的互联网应用依然稀缺移动互联网产业依然弱小呢?出现这种情况大多是开发平台未能将开发者的利益和运营商的利益完美地结合起来。

7月12日,广受国内移动开发者关注的微云平台(www.wiyun.com)正式上线,这是一个面向广大中小移动开发者的全新、强大的开发和商业服务云计算平台,它在为中文移动开发者提供免费的基础平台支持之外,更能给开发者带来较高的盈利。

跨iPhone和Android全新游戏平台发布!

微云平台的操作流程

微云团队在针对中国市场和手机用户做了大量分析,并历经一年多的潜心研发之后,微云平台同时推出了横跨Android和iPhone两大智能操作系统的重量级平台服务和产品:

WiGame:互动游戏社交平台

将单机游戏变成趣味社交互动游戏,提供排行榜、玩家PK、成就和游戏社交等互动服务,让用户在玩游戏时进行社交互动,增强用户体验和粘性,解决 单机游戏的持续性发展问题;并为开发者提供用户反馈、数据分析等全面支持;并即将推出虚拟商店,使移动开发者可以向用户提供虚拟物品和关卡售卖,获得丰厚 收入。

WiAd:创新移动广告平台

全新的手机广告表现形式、世界领先的精准匹配投放算法、多样化的效果营销计费方式,为广告主带来更多用户、提高知名度,满足品牌广告和效果营销等全面需求;帮助国内中小移动开发者增加获利渠道,与手机应用商店共同拓展新的营收模式。

微云平台的WiAd和WiGame,可以理解为AdMob + OpenFeint模式,也可以等同于苹果的iAd + GameCenter,但微云平台横跨Android和iPhone,也只面向中文开发者和中文用户提供服务,易用、自助的平台功能更符合中国用户和移动 开发者的习惯,且增加了强大的WiEngine手机游戏引擎,使其比目前的AdMob、iAd、GameCenter、OpenFeint、Plus+、 Scoreloop等平台的模式都更完整,为中国的移动开发者带来了全方位的服务支持。

易观国际高级分析师方丽指出,到2013年,中国的移动互联网用户将突破5亿,成为全球第一的移动互联网大国。

据悉,微云将斥资千万,协助中文Android和iPhone开发者打造并推广伟大的手机应用和游戏。■

Posted in 移动互联网 | Leave a comment

解决Apache2的PHP文件上传大小限制

PHP学习 2010-08-06 15:43:43 阅读5 评论0   字号:大中小 订阅

网上很多解决PHP上传文件大小限制的解决方法,主要是以下两种:

方法一:

修改php.ini配置文件

upload_max_filesize = 20M

post_max_size = 30M

memory_limit = 256M

当然,如果文件过大,会出现时间问题,必要的话,做如下修改:

max_execution_time = 300

max_input_time = 600

这样估计就不会出问题了。

方法二:

如果是apache 2 需要修改

/etc/httpd/conf.d/php.conf

LimitRequestBody 524288

将524288(=512×1024)改大。

【重要说明】

以上是网上最流行的解决方法。第二种方法我没有亲自测试。主要说一下第一种方法。

可能是Apache的版本不同,也许别人通过修改php.ini文件后就可以上传大文件了。

我的是AppServ,修改php.ini后,通过查看phpinfo.php,发现php.ini文件根本没有被加载。

后来把php.ini文件移到Apache2.2的根目录就可以了。此方法本人亲测,绝对可行!!

Posted in Linux, php | Leave a comment

Manipulating Images with PHP and GraphicsMagick

http://devzone.zend.com/article/10531

One of the things I like best about PHP is its support for a diverse array of tools and technologies. Take, for instance, image manipulation. Like most developers, I’ve known for a while that PHP comes with GD support for basic image generation and processing tasks, and I’ve even used it on occasion to dynamically create images from a base template. However, I recently needed to write some code involving cropping, resizing and otherwise torturing images and while researching the topic, I came across another PHP extension for image manipulation: the GraphicsMagick extension.

Based on the robust, multi-threaded GraphicsMagick library, aka the “Swiss Army knife of image processing”, PHP’s GraphicsMagick extension allows developers to add street cred to their image (sorry, I couldn’t resist!) with some fairly powerful API methods. This article discusses the extension in detail, introducing you to its key functions and showing you how to rotate, resample, transform, crop, carve, and otherwise mangle your images until they roll over and beg for mercy. So come on in, and bring your evil laughter with you!

Lights! Camera! Magic!

GraphicsMagick support in PHP comes through PECL’s ext/gmagick extension, which is maintained by Vito Chin and Mikko Koppanen, and provides an object-oriented API for image manipulation. Although this extension is currently in beta, it still allows you to do some fairly interesting things, including cropping, resizing and applying effects to images using PHP.

To get started with ext/gmagick, you’ll need to first make sure that you’re running PHP v5.1.3 or better, as the extension will not work on any earlier version. If you’ve got this, download the GraphicsMagick libraries (v1.2.6 or better) and compile them for your system. Assuming you’re on a *NIX system, here’s how:

shell> tar -xzvf GraphicsMagick-1.3.7.tar.gz
shell> cd GraphicsMagick-1.3.7
shell> ./configure --without-perl --enable-shared --disable-openmp
shell> make
shell> make install

Once this is done, you can proceed to install the GraphicsMagick extension using the pecl command, as shown below:

shell> pecl install gmagick-beta

In case you don’t have access to the pecl command, you can also manually download the source code archive (v1.0.1-beta at this time) and compile it into a loadable PHP module with phpize:

shell> cd gmagick-1.0.1b1
shell> phpize
shell> ./configure
shell> make
shell> make install

Regardless of which procedure you choose, you should end up with a loadable PHP module named gmagick.so in your PHP extension directory. You should now enable the extension in the php.ini configuration file, restart your Web server, and check that the extension is enabled with a quick call to phpinfo():

This article uses GraphicsMagick v1.3.7 and ext/gmagick v1.0.1-beta.

Picture This

Once you have all the pieces loaded, let’s take ext/gmagick out for a quick spin. Here’s a simple example, which reads a photo and displays various photo properties:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $file = 'gallery/IMG_0001.JPG';
  $image->readImage($file);
  echo '<img src="' . $file . '" width="200" height="150" /> <br/>';

  // get image height and width
  echo 'Image dimensions: ' . $image->getImageWidth() . ' x ' . $image->getImageHeight() . '<br/>';

  // get image format
  echo 'Image format: ' . $image->getImageFormat() . '<br/>';

  // get image depth
  echo 'Image depth: ' . $image->getImageDepth() . '<br/>';

  // get number of unique image colors
  echo 'Image colors: ' . $image->getImageColors() . '<br/>';

  // get image resolution
  $r = $image->getImageResolution();
  echo 'Image resolution: ' . $r['x'] . 'x' . $r['y'] . '<br/>';

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Your primary access point to GraphicsMagick in PHP is through the Gmagick object, which is initialized in the first line of the script above. This object exposes a number of methods for image manipulation, but the one you’re going to be on first-name terms with very soon is the readImage() method, which accepts a file path as argument and reads the corresponding image into memory. Detailed information on the image, such as its dimensions, resolution, color depth and format, can now be obtained via a range of conveniently-named get*() methods, as illustrated above.

Here’s what the output looks like:

Scaling Up

If you need to dynamically resize images so they fit into a particular template, the GraphicsMagick extension has you covered: simply call the resizeImage() method with the new height and width. You can then send the new image to the output device, or write it to a file.

Consider the next example, which demonstrates by resizing an image to 150% of its original dimensions:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // set height and width as 150% of original
  $height = $image->getImageHeight() * 1.5;
  $width = $image->getImageWidth() * 1.5;

  // resize image
  $image->resizeImage($width, $height, null, 1);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Here’s what the output looks like:

You can resample an image with the resampleImage() method, which accepts the dimensions of the new resolution, the image filter and the blur factor as arguments. Here’s an example of it in action:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // resample image
  $image->resampleImage(160, 120, null, 1);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

And here’s some example output:

If what you’re really trying to do is create a thumbnail gallery, there’s a simpler way: the extension has a thumbnailImage() method, which accepts height and width numbers and generates a thumbnail version of the original image corresponding those dimensions. Here’s an example, which iterates over a directory, locates all the JPEGs in it and builds a thumbnail gallery of 150×150 images:

<?php
try {
  // get all the JPEG files in a directory
  $fileList = glob('gallery/*.JPG');
  foreach ($fileList as $file) {
    // initialize object
    $image = new Gmagick();

    // for each file
    // generate thumbnail
    // write thumbnail to disk
    $image->readImage($file);
    $image->thumbnailImage(150, 150);
    $thumbFile = dirname($file) . '/' . basename($file, '.JPG') . '.thumb.jpg';
    $image->writeImage($thumbFile);

    // free resource handle
    $image->destroy();
  }

} catch (Exception $e) {
  die ($e->getMessage());
}
?>

: Here’s what the output looks like:

In the Frame

The GraphicsMagick extension also includes methods for rotating, flipping and cropping images. Here’s an example:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // rotate image
  $image->rotateImage('red', -45);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

The rotateImage() method needs two arguments: the number of degrees by which to rotate the original image (second) and the fill color to use for any resultant empty space (first). Here’s what the script above generates:

You can create a vertical or horizontal mirror image with the flipImage() and flopImage() methods, respectively. Here’s an example:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // flip image vertically
  $image->flipImage();

  // write new image file
  $image->writeImage('gallery/new_1.jpg');

  // revert
  $image->flipImage();

  // flip image horizontally
  $image->flopImage();

  // write new image file
  $image->writeImage('gallery/new_2.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

And here’s an example of the resulting output:

You can crop a portion of the image with the cropImage() method, which accepts four arguments: the width and height of the area to crop, in pixels, and the X and Y coordinates of the pixel at the top left corner of the crop area. Here’s an example:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // crop image
  $image->cropImage(122, 70, 76, 138);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

And here’s the resulting output:

Finally, you can magnify an image to twice its original size, or scale it down to half, with the magnifyImage() and minifyImage() methods, as below:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // magnify image 2x
  $image->magnifyImage();

  // write new image file
  $image->writeImage('gallery/new_1.jpg');

  // revert
  $image->minifyImage();

  // scale image to half
  $image->minifyImage();

  // write new image file
  $image->writeImage('gallery/new_2.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Take a look at what this produces:

Not My Type

Living up to its billing as the “Swiss Army knife of image processing”, the GraphicsMagick extension eats formats for breakfast. It can read and convert between most common image formats, including JPEG, GIF, PNG and TIFF, making it perfect for on-the-fly image conversion of uploaded photos or drawings. To convert an image, simply read it into memory with readImage(), use the setImageFormat() method to set the target format, and then write it back out with writeImage(). Simple, logical and oh so easy!

Here’s an example:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // switch to GIF format
  $image->setImageFormat('GIF');

  // write new image file
  $image->writeImage('gallery/new.gif');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Incidentally, you can get a list of all the formats supported by your build with the queryFormats() method.

Border Incursion

You can add a 2D border to your image with the borderImage() method, which accepts three arguments: the border color, the border width and the border height. Here’s an example of it in action, generating a blue border that’s 4 pixels wide and 15 pixels high:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // add border to image
  $image->borderImage('blue', 4, 15);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Here’s what the output looks like:

If you prefer 3D, the frameImage() method lets you apply a 3D border to your image. Here’s how it works:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // add 3D border to image
  $image->frameImage('silver', 20, 20, 5, 5);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

And here’s an example of what the output looks like:

You can blur or sharpen an image with the blurImage() and sharpenImage() methods, both of which accept a blur/sharpen radius value and a standard deviation. Here’s an example:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // blur image
  $image->blurImage(8, 3);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

And here’s the output:

Swirl Cycle

I’ve left the most impressive bits for last. The GraphicsMagick extension comes with a bunch of methods that allow you to apply special effects to your images. For example, the swirlImage() method adds a swirling effect to the center of your image:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // add swirl effect
  $image->swirlImage(180);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Here’s an example of the resulting output:

The charcoalImage() method lets you re-render an image in the style of a charcoal drawing:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // add charcoal drawing effect
  $image->charcoalImage(5, 0.2);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Here’s an example of the resulting output:

The oilPaintImage() method lets you render an image in the style of an oil painting:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // add oil paint effect
  $image->oilPaintImage(2.5);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Here’s an example of the resulting output:

The cycleColorMapImage() method lets you shift the colors of the image. As the manual suggests, if you do this a few times, it produces a psychedelic effect. Here’s an example:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // displace image colors
  $image->cycleColorMapImage(100);
  $image->cycleColorMapImage(100);
  $image->cycleColorMapImage(100);
  $image->cycleColorMapImage(100);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

And here’s an example of the resulting output:

The solarizeImage() method lets you apply a darkroom effect to your image:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // solarize image
  $image->solarizeImage(100);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

The shearImage() method lets you move part of the image to create a “parallelogram effect”:

<?php
try {
  // initialize object
  $image = new Gmagick();

  // read image file
  $image->readImage('gallery/original.jpg');

  // displace image colors
  $image->shearImage('white', 5, 70);

  // write new image file
  $image->writeImage('gallery/new.jpg');

  // free resource handle
  $image->destroy();
} catch (Exception $e) {
  die ($e->getMessage());
}
?>

Here’s the output:

As the examples above illustrate, you no longer need a Photoshop expert to hold your hand when it comes to working with images, because PHP’s GraphicsMagick extension offers a full-fledged alternative for dynamic image manipulation. This article has only scratched the tip of the iceberg – the PHP manual documents more than 130 methods for this extension. In other words, there’s no shortage of things to play with – so why not try it out and see what you think!

Posted in ImageHandle, Linux | Leave a comment

Web前端优化最佳实践

http://www.bopor.com/?p=1073

如果愿意看英文,直接看
Google的前端优化最佳实践 

Yahoo的前端优化最佳实践
------------------------------------------------------------

Web前端优化最佳实践之Content

1. 尽量减少 HTTP 请求 (Make Fewer HTTP Requests)

作为第一条,可能也是最重要的一条。根据 Yahoo! 研究团队的数据分析,有很大一部分用户访问会因为这一条而取得最大受益。有几种常见的方法能切实减少 HTTP 请求:

  • 1) 合并文件 ,比如把多个 CSS 文件合成一个;
  • 2) CSS Sprites 利用 CSS background 相关元素进行背景图绝对 定位;参见:CSS Sprites: Image Slicing’s Kiss of Death
  • 3) 图像地图
  • 4) 内联图象 使用 data: URL scheme 在实际的页面嵌入图像数据.

2. 减少 DNS 查找 (Reduce DNS Lookups)

必须明确的一点,DNS 查找的开销是很大的。另外,我倒是觉得这是 Yahoo! 所有站点的通病,Yahoo!主站点可能还不够明显,一些分站点,存在明显的类似问题。对于国内站点来说,如果过多的使用了站外的 Widget ,也很容易引起过多的 DNS 查找问题。

3. 避免重定向 (Avoid Redirects)

不是绝对的避免,尽量减少。另外,应该注意一些不必要的重定向。比如对 Web 站点子目录的后面添加个 / (Slash) ,就能有效避免一次重定向。http://www.dbanotes.net/arch 与 http://www.dbanotes.net/arch/ 二者之间是有差异的。如果是 Apache 服务器,通过配置 Alias 或mod_rewrite 或是 DirectorySlash 能够消除这个问题。

4. 使得 Ajax 可缓存 (Make Ajax Cacheable)

响应时间对 Ajax 来说至关重要,否则用户体验绝对好不到哪里去。提高响应时间的有效手段就是 Cache 。其它的一些优化规则对这一条也是有效的。

5. 延迟载入组件 (Post-load Components)

6. 预载入组件 (Preload Components)

上面两条严格说来,都是属于异步 这个思想灵活运用的事儿。

7. 减少 DOM 元素数量 (Reduce the Number of DOM Elements)

8. 切分组件到多个域 (Split Components Across Domains)

主要的目的是提高页面组件并行下载能力。但不要跨太多域名,否则就和第二条有些冲突了。

9. 最小化 iframe 的数量 (Minimize the Number of iframes)

熟悉 SEO 的朋友知道 iframe 是 SEO 的大忌。针对前端优化来说 iframe 有其好处,也有其弊端,一分为二看问题吧。

10. 杜绝 http 404 错误 (No 404s)

对页面链接的充分测试加上对 Web 服务器 error 日志的不断跟踪能有效减少 404 错误,亦能提升用户体验。值得一提的是,CSS 与 Java Script 引起的 404 错误因为定位稍稍”难”一点而往往容易被忽略。

Web前端优化最佳实践之Server

1. 使用 CDN (Use a Content Delivery Network)

国内 CDN 的普及还不够。不过我们有独特的电信、网通之间的问题 ,如果针对这个作优化,基本上也算能收到 CDN 或类似的效果吧(假装如此)。【Tin 说国内 CDN 用的挺多,看看 CDN 厂商的市场就知道了,还没走入寻常百姓家】

2. 添加 Expires Cache-Control 信息头 (Add an Expires or a Cache-Control Header)

各个浏览器都有针对的方案, Apache 例子【注意:下面的说明例子还不够精细,具体的环境上还要加一些调整】:

Conf代码

  1. ExpiresActive On ExpiresByType image/gif “modification plus 1 weeks”
  2. Lighttpd 启用 mod_expire 模块 后:
  3. $HTTP["url"] =~ “\.(jpg|gif|png)$” { expire.url = ( “” => “access 1 years” ) }
  4. Nginx 例子参考:
  5. location ~* \.(jpg|gif|png)$ { if (-f $request_filename) { expires max; break; } }

3. 压缩内容 (Gzip Components)

对于绝大多数站点,这都是必要的一步,能有效减轻网络流量压力。或许有人担心对 CPU 压缩对于 CPU 的影响,放心大胆的整吧,没事儿。Nginx 例子:

gzip on; gzip_types text/plain text/html text/css ext/javascript;

另外参见:

IIS 如何启用 Gzip 压缩?

4. 设置 Etags (Configure ETags)

对于 Etag ,可能是多数网站维护者都会忽略的地方。在这一系列优化规则出现之前,可能互联网上绝大多数站点都对这个问题忽略了。当然,Etag 对多数站点性能的影响并不是很大。除非是面向 RSS 的网站。【看到有朋友批评说写的简略,并且说 IE 不支持 ETag。明确说一下:IE 支持 ETag,倒是使用 IIS 要注意相关 Etag Bug。】

补充:我的意思是”很多网站在不注意的情况下都是打开 Etag 的,而没有网站关心如何用,消耗资源而不知。并不是说 Etag 不好,合理利用 Etag ,绝对能取得很好的收益.

5. 尽早刷新 Buffer (Flush the Buffer Early)

对这一条,琢磨了半天,貌似还是异步 的思路。能更好的提升用户体验?

6. AJAX 请求使用 GET 方法 (Use GET for AJAX Requests)

XMLHttpRequest POST 要两步,而 GET 只需要一步。但要注意的是在 IE 上 GET 最大能处理的 URL 长度是 2K。

Web前端优化最佳实践之Cookie

1. 缩小 Cookie (Reduce Cookie Size)

Cookie 是个很有趣的话题。根据 RFC 2109 的描述,每个客户端最多保持 300 个 Cookie,针对每个域名最多 20 个 Cookie (实际上多数浏览器现在都比这个多,比如 Firefox 是 50 个) ,每个 Cookie 最多 4K,注意这里的 4K 根据不同的浏览器可能不是严格的 4096 。别扯远了,对于 Cookie 最重要的就是,尽量控制 Cookie 的大小,不要塞入一些无用的信息。

2. 针对 Web 组件使用域名无关性的 Cookie (Use Cookie-free Domains for Components)

这个话题在此前针对 Web 图片服务器 的讨论中曾经提及。这里说的 Web 组件(Component),多指静态文件,比如图片 CSS 等,Yahoo! 的静态文件都在 yimg.com 上,客户端请求静态文件的时候,减少了 Cookie 的反复传输对主域名 (yahoo.com) 的影响。

从这篇 When the Cookie Crumbles 能看出,MySpace 和 eBay 的 Cookie 都不小的,想必是对用户行为比较关心。eBay 前不久构造了 Personalization Platform ,就是从 Cookie 的限制中跳出来。

Web前端优化最佳实践第四部分面向CSS

1. CSS 放到代码页上端 (Put Stylesheets at the Top)

官方的解释我觉得多少有点语焉不详。这一条其实和用户访问期望 有关。CSS 放到最顶部,浏览器能够有针对性的对 HTML 页面从顶到下进行解析和渲染。没有人喜欢等待,而浏览器已经考虑到了这一点。

2. 避免 CSS 表达式 (Avoid CSS Expressions)

个人认为通过 CSS 表达式能做到的事情,通过其它手段也同样能做到而且风险更小一些。

3. 从页面中剥离 JavaScript CSS (Make JavaScript and CSS External)

剥离后,能够有针对性的对其进行单独的处理策略,比如压缩或者缓存策略。

4. 精简 JavaScript CSS (Minify JavaScript and CSS )

如果没有 JavaScript 与 CSS 可能更好。但,这是不可能的,SO,尽量小点吧。语法能简写的简写。

5. 使用 <link> 而不是@importChoose <link> over @import

在 IE 中 @import 指令等同于把 link 标记写在 HTML 的底部。而这与第一条相违背。

6. 避免使用Filter (Avoid Filters)

另请参见 Mozilla 开发者中心的文章:Writing Efficient CSS

Web前端优化最佳实践之JavaScript

1. 脚本放到 HTML 代码页底部 (Put Scripts at the Bottom)

当一个脚本在下载的时候,浏览器干不了其它的事儿(串行了)。所以,把它扔到最后面去处理。对于一些功能性的脚本,可能实现起来有些两难。不过对于 国内网站来说,有很多使用 Google Analytics 服务进行网站数据分析的。这这一点来说,绝对可行的建议,放到页面最底下。

2. Make JavaScript and CSS External

参见 CSS 篇 的描述

3. 精简 JavaScript CSS (Minify JavaScript and CSS )

参见 CSS 篇 的描述

4. 移除重复脚本 (Remove Duplicate Scripts)

对于一些历史遗留站点或是论坛类的网站来说,这倒是比较常见的。接手维护人前后变化过多,每个人都有自己的一套。这就会带来一些潜在的麻烦。

5. 减少 DOM 访问 (Minimize DOM Access)

有三条指导建议:

  • 缓存已经访问过的元素 (Cache references to accessed elements)
  • “离线”更新节点, 再将它们添加到树中 (Update nodes “offline” and then add them to the tree)
  • 避免使用 JavaScript 输出页面布局–应该是 CSS 的事儿 (Avoid fixing layout with JavaScript)

6. Develop Smart Event Handlers

除了英文解释外,这里也提醒一下注意关于 Java Script 内存泄漏 的问题。

Web前端优化最佳实践之图片篇

1. 优化图片 (Optimize Images)

使用 GIF 、JPG 还是 PNG 格式的图片? 尽可能的使用 PNG 格式的图片,更多的功能,更小的尺寸(与 GIF 相比)。

对于 PNG 图片,考虑用 Pngcrush 或类似的工具进行优化。常见的工具如下表:

  • pngcrush http://pmt.sourceforge.net/pngcrush/
  • pngrewrite http://www.pobox.com/~jason1/pngrewrite/
  • OptiPNG http://www.cs.toronto.edu/~cosmin/pngtech/optipng/ (refer: 教程 )
  • PNGOut http://advsys.net/ken/utils.htm

对 JPEG 图片的优化工具:

必需要强调的是,图片设计的同学啊,请考虑设计面向 Web 的图片 ,不要动不动就设计超过可接受尺寸之外大家伙,这应该是一种习惯,而不是什么高超的技能,只需要记住就成了。

2. 使用 CSS Sprites 技巧对图片优化 (Optimize CSS Sprites)

之前提到过,简单的说就是”利用 CSS background 相关元素进行背景图绝对定位”,把多次 HTTP 调用变为一次调用,更多参考:CSS Sprites: Image Slicing’s Kiss of Death

补充一下:对于这个技巧我曾经见到有人滥用的。把多个背景图片揉成一个,减少 HTTP 调用,这是一个很好的思路。但一定要记住这个大图片不能太”重”,我看到过 100 多K 的背景图。一个图片就把整个网站拖得很慢。比较好的例子可以参考雅虎关系的这个图 .

3. 不要在 HTML 中使用缩放图片 (Don’t Scale Images in HTML )

更多的时候,可能是因为偷懒而没有制作合适大小的图片,如果是批量处理图片的话,可能一条 ImageMagic 命令(convert )就能搞定 。必须提及的是,看到太多的对图片拉伸很难看的页面,救救这些页面!

4. 用更小的并且可缓存的 favicon.ico (Make favicon.ico Small and Cacheable)

更小,可缓存,这两条可能都不是问题。问题是,太多站点根本没有 favicon.ico 。有的时候,判断独立域名的 Blog 是否专业,基本看一下是否有 favicon.ico 就差不多了。

在 Velocity 2008 技术大会上,Yahoo! 的 Stoyan Stefanov 做的 Image Optimization: How Many of These 7 Mistakes Are You Making 也非常有参考价值。结合一起说一下。

Posted in AJAX | Leave a comment

InnoDB Plugin 1.0.6 for MySQL 5.1.41安装测试

1、安装
wget http://mirrors.ntua.gr/MySQL/Downloads/MySQL-5.1/mysql-5.1.41-linux-x86_64-glibc23.tar.gz
wget http://www.innodb.com/download/innodb_plugin/innodb_plugin-1.0.6-linux-x86_64-glibc23.tar.gz

# tar zxvf innodb_plugin-1.0.6-linux-x86_64-glibc23.tar.gz
# cp innodb_plugin-1.0.6-linux-x86_64-glibc23/ha_innodb.so /usr/local/mysql/lib/plugin/
# chown root:mysql /usr/local/mysql/lib/plugin/ha_innodb.so

# vi /etc/my.cnf
[mysqld]
ignore_builtin_innodb
plugin_load=innodb=ha_innodb.so;innodb_trx=ha_innodb.so;innodb_locks=ha_innodb.so;innodb_lock_waits=ha_innodb.so;innodb_cmp=ha_innodb.so;innodb_cmp_reset=ha_

innodb.so;innodb_cmpmem=ha_innodb.so;innodb_cmpmem_reset=ha_innodb.so

然后重启mysql即可。(注:重启前要先删除MYSQL自带的ibdata1,ib_logfile0,ib_logfile1)

此时的日志,如下:

InnoDB: The first specified data file /usr/local/mysql/data/ibdata1 did not exist:
InnoDB: a new database to be created!
090927 9:34:40 InnoDB: Setting file /usr/local/mysql/data/ibdata1 size to 200 MB
InnoDB: Database physically writes the file full: wait…
InnoDB: Progress in MB: 100 200
090927 9:34:43 InnoDB: Log file /usr/local/mysql/data/ib_logfile0 did not exist: new to be created
InnoDB: Setting log file /usr/local/mysql/data/ib_logfile0 size to 64 MB
InnoDB: Database physically writes the file full: wait…
090927 9:34:44 InnoDB: Log file /usr/local/mysql/data/ib_logfile1 did not exist: new to be created
InnoDB: Setting log file /usr/local/mysql/data/ib_logfile1 size to 64 MB
InnoDB: Database physically writes the file full: wait…
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
》》》》090927 9:34:45 InnoDB Plugin 1.0.4 started; log sequence number 0《《《《
090927 9:34:45 [Note] Event Scheduler: Loaded 0 events
090927 9:34:45 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ’5.1.37-log’ socket: ‘/tmp/mysql.sock’ port: 3306 MySQL Community Server (GPL)
2、测试方法
修改my.cnf将配置文件中max_connections调至2000。

mysqlslap -a –concurrency=50,100,500,1000 –number-of-queries 1000 –iterations=5 –engine=innodb –debug-info

3、测试结果

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.932 seconds
Minimum number of seconds to run all queries: 1.900 seconds
Maximum number of seconds to run all queries: 1.959 seconds
Number of clients running queries: 50
Average number of queries per client: 20

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.942 seconds
Minimum number of seconds to run all queries: 1.850 seconds
Maximum number of seconds to run all queries: 2.034 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.568 seconds
Minimum number of seconds to run all queries: 0.745 seconds
Maximum number of seconds to run all queries: 2.485 seconds
Number of clients running queries: 500
Average number of queries per client: 2

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.849 seconds
Minimum number of seconds to run all queries: 1.590 seconds
Maximum number of seconds to run all queries: 2.255 seconds
Number of clients running queries: 1000
Average number of queries per client: 1

——————————————————————————————————————

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.121 seconds
Minimum number of seconds to run all queries: 0.866 seconds
Maximum number of seconds to run all queries: 1.623 seconds
Number of clients running queries: 50
Average number of queries per client: 20

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.916 seconds
Minimum number of seconds to run all queries: 0.710 seconds
Maximum number of seconds to run all queries: 1.207 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.362 seconds
Minimum number of seconds to run all queries: 1.294 seconds
Maximum number of seconds to run all queries: 1.420 seconds
Number of clients running queries: 500
Average number of queries per client: 2

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.250 seconds
Minimum number of seconds to run all queries: 1.113 seconds
Maximum number of seconds to run all queries: 1.375 seconds
Number of clients running queries: 1000
Average number of queries per client: 1
User time 1.72, System time 2.67
Maximum resident set size 0, Integral resident set size 0
Non-physical pagefaults 80331, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 85040, Involuntary context switches 33867

不用说,已经看到差距了吧。

Posted in DB, Linux | Leave a comment

搭建前后端web生产环境

前言:谈到Linux下的web生产环境,大家就会想到apache这个开源服务器软件.apache可以整合 大多数应用,比如jsp,php,cgi,python等等,但是apache过于臃肿以及对静态文件响应过于缓慢让很多使用者感到头疼.而nginx作 为新崛起的服务器软件,在很多方面超出apache,定位也很明确:高性能的 HTTP 和反向代理服务器.因而,本篇主要讲的是nginx作为前端,apache作为后端的应用环境搭建过程.

为什么不使用nginx+php(fastcgi)作为生产环境?我提出我的看法.

  1. php(fastcgi)不够稳定,容易出现50x错误,在生成相对复杂的页面时没有优势,长时间占用也会使php-cgi进程变为僵尸进程.
  2. 安全性,多用户多站点权限问题.php(fastcgi)在应对多用户多站点往往捉襟见肘,不易于实施.
  3. 整合其他语言,apache表现得游刃有余.资源利用恰到好处.

为 什么采用nginx做前端,apache作为后端的方案?nginx在处理静态内容上较apache是几倍或几十倍的差异,因而放在前面过滤静态内容是最 为恰当的.同时nginx也是一个负载均衡器,低资源消耗,高性能转发是它的特点.经过nginx在前面的过滤,后端的apache需要处理的内容相对就 比较少了.只需负责处理动态内容就可以了.在性能与稳定性的权衡下,使用nginx+apache搭配会让它们在各自擅长的领域展现自身的价值.

本教程以CentOS 5.4 32bit为环境.其他Linux发行版本暂未测试.nginx,php,apache,mysql,pureftpd均为最新稳定版.

获取操作系统源更新.

yum update
yum -y install gcc gcc-c++ bison patch unzip mlocate flex wget automake autoconf gd cpp gettext readline-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel openldap openldap-devel openldap-clients openldap-servers nss_ldap expat-devel libtool libtool-ltdl-devel

如果系统默认安装了apache,请先卸载.执行:

yum remove httpd

下载最新稳定版的程序源码包,以下都是到官方网站或sourceforge下载的源码包.

cd /usr/local/src
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.45.tar.gz/from/http://mysql.he.net/
wget http://www.apache.org/dist/httpd/httpd-2.2.15.tar.gz
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2/download
wget http://www.php.net/get/php-5.2.13.tar.gz/from/this/mirror
wget http://www.lancs.ac.uk/~steveb/patches/php-mail-header-patch/php5-mail-header.patch
wget http://pecl.php.net/get/memcache-2.2.5.tgz
wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
wget http://download.suhosin.org/suhosin-0.9.29.tgz
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
wget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz
wget http://sourceforge.net/projects/pcre/files/pcre/8.01/pcre-8.01.tar.gz/download
wget http://nginx.org/download/nginx-0.7.65.tar.gz
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.28.tar.gz

一.安装Mysql.安装最新稳定版5.1.45版本,并没有采用最新开发版.

groupadd mysql -g 27
useradd mysql -u 27 -g 27 -c “MySQL Server” -d /var/lib/mysql -m
cd /usr/local/src
tar -zxf mysql-5.1.45.tar.gz
cd mysql-5.1.45
./configure –prefix=/usr/local/mysql –localstatedir=/var/lib/mysql –with-unix-socket-path=/var/lib/mysql/mysql.sock –with-mysqld-user=mysql –enable-assembler –enable-thread-safe-client –with-extra-charsets=all –with-big-tables –with-readline –with-ssl –with-embedded-server –enable-local-infile –with-plugins=partition,innodb_plugin,myisam,myisammrg
make && make install
cd ../

cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db –user=mysql
chown -R mysql.mysql /var/lib/mysql
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod u+x /etc/init.d/mysql
chkconfig –level 345 mysql on
echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
echo “/usr/local/lib” >>/etc/ld.so.conf
ldconfig
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
service mysql start
/usr/local/mysql/bin/mysqladmin -u root password root
service mysql restart
service mysql stop

二.编译安装apache(httpd).apache的执行用户为nobody.

cd /usr/local/src
tar -zxf httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure –prefix=/usr/local/apache –enable-headers –enable-mime-magic –enable-proxy –enable-rewrite –enable-ssl –enable-suexec  –disable-userdir –with-included-apr –with-mpm=prefork –with-ssl=/usr –with-suexec-caller=nobody –with-suexec-docroot=/ –with-suexec-gidmin=100 –with-suexec-logfile=/usr/local/apache/logs/suexec_log –with-suexec-uidmin=100 –with-suexec-userdir=public_html
make
make install
mkdir /usr/local/apache/domlogs
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

1.编辑/etc/init.d/httpd,在首行#!/bin/sh下添加:

# Startup script for the Apache Web Server
#
# chkconfig: – 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#              HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache/logs/httpd.pid
# config: /usr/local/apache/conf/httpd.conf

ulimit -n 1024
ulimit -n 4096
ulimit -n 8192
ulimit -n 16384
ulimit -n 32768

保存退出.

2.配置apache配置参数文件httpd.conf,位于/usr/local/apache/conf/目录

cd /usr/local/apache/conf/
mv httpd.conf httpd.conf.bak
mkdir vhosts
vi httpd.conf

输入以下内容:

PidFile logs/httpd.pid
LockFile logs/accept.lock
ServerRoot "/usr/local/apache"
Listen 0.0.0.0:81
User nobody
Group nobody
ServerAdmin admin@evlit.com
ServerName host.evlit.com

Timeout 300
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 5
UseCanonicalName Off
AccessFileName .htaccess
TraceEnable Off
ServerTokens ProductOnly
FileETag None
ServerSignature Off
HostnameLookups Off

# LoadModule perl_module modules/mod_perl.so

DocumentRoot "/usr/local/apache/htdocs"
<Directory "/">
 Options ExecCGI FollowSymLinks Includes IncludesNOEXEC -Indexes -MultiViews SymLinksIfOwnerMatch
 Order allow,deny
 Allow from all
 AllowOverride All
</Directory>

<Directory "/usr/local/apache/htdocs">
 Options Includes -Indexes FollowSymLinks
 AllowOverride None
 Order allow,deny
 Allow from all
</Directory>

DefaultType text/plain
RewriteEngine on
AddType text/html .shtml
AddHandler cgi-script .cgi .pl .plx .ppl .perl
AddHandler server-parsed .shtml
<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/perl .pl .plx .ppl .perl
    AddType application/x-img .img
    AddType application/x-httpd-php .php .php3 .php4 .php5 .php6
    AddType application/x-httpd-php-source .phps
    AddType application/cgi .cgi
    AddType text/x-sql .sql
    AddType text/x-log .log
    AddType text/x-config .cnf conf
    AddType text/x-registry .reg
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddType application/x-tar .tgz
    AddType application/rar .rar
    AddType application/x-compressed .rar
    AddType application/x-rar .rar
    AddType application/x-rar-compressed .rar
    AddType text/vnd.wap.wml .wml
    AddType image/vnd.wap.wbmp .wbmp
    AddType text/vnd.wap.wmlscript .wmls
    AddType application/vnd.wap.wmlc .wmlc
    AddType application/vnd.wap.wmlscriptc .wmlsc
</IfModule>

<IfModule dir_module>
 DirectoryIndex index.html index.htm index.shtml index.php index.perl index.pl index.cgi
</IfModule>

<Files ~ "^error_log$">
 Order allow,deny
 Deny from all

 Satisfy All
</Files>

<FilesMatch "^\.ht">
 Order allow,deny
 Deny from all
 Satisfy All
</FilesMatch>

ErrorLog "logs/error_log"
LogLevel warn

<IfModule log_config_module>
 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
 LogFormat "%h %l %u %t \"%r\" %>s %b" common

 <IfModule logio_module>
 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
 </IfModule>
 CustomLog "logs/access_log" common
</IfModule>

<IfModule alias_module>
 ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
</IfModule>

<Directory "/usr/local/apache/cgi-bin">
 AllowOverride None
 Options None
 Order allow,deny
 Allow from all
</Directory>

<IfModule mpm_prefork_module>
 StartServers          3
 MinSpareServers       3
 MaxSpareServers       5
 MaxClients          150
 MaxRequestsPerChild   1024
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "\.(html|htm|shtml)$">
Header set Cache-Control "max-age=3600, must-revalidate"
</FilesMatch>
</IfModule>

ReadmeName README.html
HeaderName HEADER.html

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

Include conf/extra/httpd-languages.conf

<Location /server-status>
 SetHandler server-status
 Order deny,allow
 Deny from all
 Allow from 127.0.0.1
</Location>
ExtendedStatus On

<Location /server-info>
 SetHandler server-info
 Order deny,allow
 Deny from all
 Allow from 127.0.0.1
</Location>

<IfModule ssl_module>
Listen 0.0.0.0:443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLCipherSuite ALL:!ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP
SSLPassPhraseDialog  builtin
SSLSessionCache         dbm:/usr/local/apache/logs/ssl_scache
SSLSessionCacheTimeout  300
SSLMutex  file:/usr/local/apache/logs/ssl_mutex
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

#Vhosts
NameVirtualHost 127.0.0.1:81
NameVirtualHost *

<VirtualHost 127.0.0.1:81 *>
 ServerName host.evlit.com
 DocumentRoot /var/www/html
 ServerAdmin admin@evlit.com
</VirtualHost>

Include conf/vhosts/*

上述虚拟主机配置中出现的127.0.0.1请改为你本机公网IP.

三.编译安装php(mod_php)

1.编译安装相关支持库

cd /usr/local/src
tar -zxf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure
make
make install

cd /usr/local/src
tar -jxf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make
make install

cd /usr/local/src
tar -jxf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9/
./configure
make
make install

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

cd /usr/local/src
tar -zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install

2.编译php,这里我们为php打入补丁.有助于防止邮件发送被滥用(多用户)以及在邮件中提供有价值的信息.补丁介绍信息请点击:http://www.lancs.ac.uk/~steveb/patches/php-mail-header-patch/

cd /usr/local/src
tar -zxf php-5.2.13.tar.gz
patch -d php-5.2.13 -p1 < php5-mail-header.patch
cd php-5.2.13
./configure –prefix=/usr/local –with-config-file-path=/etc –with-apxs2=/usr/local/apache/bin/apxs –enable-bcmath –enable-calendar –enable-exif –enable-ftp –enable-gd-native-ttf –enable-libxml –enable-magic-quotes –enable-mbstring –enable-pdo=shared –enable-soap –enable-sockets –enable-zip –with-bz2 –with-curl –with-curlwrappers –with-freetype-dir –with-gd –with-gettext –with-jpeg-dir –with-kerberos –with-libexpat-dir=/usr –with-libxml-dir=/usr –with-mcrypt=/usr –with-mhash=/usr –with-mysql=/usr –with-mysql-sock=/var/lib/mysql/mysql.sock –with-mysqli=/usr/bin/mysql_config –with-openssl=/usr –with-openssl-dir=/usr –with-pdo-mysql=shared –with-pdo-sqlite=shared –with-png-dir=/usr –with-sqlite=shared –with-ttf –with-xmlrpc –with-zlib -with-zlib-dir=/usr
make ZEND_EXTRA_LIBS=’-liconv’
make install
cp php.ini-dist /etc/php.ini

3.安装php扩展模块

cd /usr/local/src
tar -zxf memcache-2.2.5.tgz
cd memcache-2.2.5/
phpize
./configure –with-php-config=/usr/local/bin/php-config –with-zlib-dir –enable-memcache
make
make install

cd /usr/local/src
tar -jxf eaccelerator-0.9.6.tar.bz2
cd eaccelerator-0.9.6/
phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/bin/php-config
make
make install
mkdir -p /tmp/eaccelerator
chmod 777 /tmp/eaccelerator
echo “mkdir -p /tmp/eaccelerator” >> /etc/rc.local
echo “chmod 777 /tmp/eaccelerator” >> /etc/rc.local

cd /usr/local/src
tar -zxf ImageMagick.tar.gz
cd ImageMagick-*
./configure
make
make install

cd /usr/local/src
tar -zxf imagick-2.3.0.tgz
cd imagick-2.3.0/

phpize

./configure –with-php-config=/usr/local/php/bin/php-config  –with-imagick=/usr/local/ImageMagick/

make
make install

cd /usr/local/src
tar -zxf suhosin-0.9.29.tgz
cd suhosin-0.9.29
phpize
./configure
make
make install

cd /usr/local/src
tar -zxf ioncube_loaders_lin_x86.tar.gz
cd ioncube
mkdir /usr/local/ioncube
mv ioncube_loader_lin_5.2.so /usr/local/ioncube/

cd /usr/local/src
tar -zxf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
mkdir -p /usr/local/Zend/lib/Optimizer-3.3.9/php-5.2.x
cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/Zend/lib/Optimizer-3.3.9/php-5.2.x/ZendOptimizer.so

3.1.修改php.ini.

查找/etc/php.ini中的extension_dir = “./”.将其修改为extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-20060613/”
查找;include_path = “.:/php/includes”,删除前面的分号,并修改为include_path = “.:/usr/lib/php:/usr/local/lib/php”
跳到最后一行,然后添加以下内容:

extension = “memcache.so”
extension = “pdo.so”
extension = “pdo_mysql.so”
extension = “pdo_sqlite.so”
extension = “sqlite.so”
extension = “eaccelerator.so”
eaccelerator.shm_size = 32
eaccelerator.cache_dir = “/tmp/eaccelerator”
eaccelerator.enable = 1
eaccelerator.optimizer = 0
eaccelerator.debug = 0
eaccelerator.name_space = “”
eaccelerator.check_mtime = 1
eaccelerator.filter = “”
eaccelerator.shm_max = 0
eaccelerator.shm_ttl = 3600
eaccelerator.shm_prune_period = 3600
eaccelerator.shm_only = 0
eaccelerator.compress = 0
eaccelerator.compress_level = 9
eaccelerator.keys = shm
eaccelerator.sessions = shm
eaccelerator.content = shm

zend_extension = “/usr/local/ioncube/ioncube_loader_lin_5.2.so”
zend_extension = “/usr/local/Zend/lib/Optimizer-3.3.9/php-5.2.x/ZendOptimizer.so”

4,安装Memcached(可选)

cd /usr/local/src
tar -xzf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure
make
make install
echo “/usr/local/lib/” > /etc/ld.so.conf.d/libevent.conf
ldconfig -v

cd /usr/local/src
tar -xzf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure
make
make install

基本使用方法:

启动:/usr/local/bin/memcached -d -m 64 -p 11211 -u nobody -l localhost
关闭:killall -9 memcached

四.安装nginx

1.安装pcre库

cd /usr/local/src
tar -zxf pcre-8.01.tar.gz
cd pcre-8.01
./configure
make
make install

2.安装nginx

cd /usr/local/src
tar -zxf nginx-0.7.65.tar.gz
cd nginx-0.7.65
./configure –user=nobody –group=nobody –prefix=/usr/local/nginx –pid-path=/usr/local/nginx/logs/nginx.pid –error-log-path=/usr/local/nginx/logs/error.log –http-log-path=/usr/local/nginx/logs/access.log –http-client-body-temp-path=/tmp/nginx_client –http-proxy-temp-path=/tmp/nginx_proxy –http-fastcgi-temp-path=/tmp/nginx_fastcgi –with-http_stub_status_module
make
make install

2.1.添加init控制脚本

#! /bin/sh
ulimit -n 65535
# Description: Startup script for nginx
# chkconfig: 2345 55 25

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
 $DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}

do_stop() {
 kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}

waitforexit() {
 count=${2:-30}
 while [ 0$count -gt 0 ]
 do
   PIDS=`ps -C$NAME --no-heading e | grep $DAEMON` || break
   PIDS=`echo "$PIDS" | awk '{print $1}' | tr '\n' ' '`
   echo Remaining processes: $PIDS
   do_stop
   sleep 2
   count=`expr $count - 1`
 done
 if [ 0$count -eq 0 ];
 then
   echo Remaining processes: $PIDS
   return 1
 fi
 return 0
}

do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}

case "$1" in
 start)
 echo -n "Starting $DESC: $NAME"
 do_start
 echo "."
 /etc/init.d/httpd start
 ;;
 stop)
 echo -n "Stopping $DESC: $NAME"
 do_stop
 echo "."
 /etc/init.d/httpd stop
 ;;
 reload)
 echo -n "Reloading $DESC configuration..."
 do_reload
 echo "."
 /etc/init.d/httpd restart
 ;;
 restart)
 echo -n "Restarting $DESC: $NAME"
 waitforexit "nginx" 20
 do_start
 echo "."
 /etc/init.d/httpd restart
 ;;
 *)
 echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
 exit 3
 ;;
esac

exit 0

保存退出,给该文件赋予执行权限并设置开机启动

chmod 755 /etc/init.d/nginx
chkconfig –level 345 nginx on

2.2.修改nginx配置文件,位于:/usr/local/nginx/conf/目录

cd /usr/local/nginx/conf/
mv nginx.conf nginx.conf.bak
mkdir vhosts
vi nginx.conf

输入以下内容:

worker_processes  2;
worker_rlimit_nofile  40960;
events {
worker_connections  40960;
use epoll;
}
error_log  /usr/local/nginx/logs/error.log info;
http {
include    mime.types;
default_type  application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_min_length  1100;
gzip_comp_level  3;
gzip_buffers  4 32k;
gzip_types    text/plain text/xml text/css application/x-javascript application/xml application/xml+rss text/javascript application/atom+xml;
ignore_invalid_headers on;
connection_pool_size  256;
request_pool_size  32k;
server_name_in_redirect off;
server_names_hash_max_size 2048;
server_names_hash_bucket_size 256;
output_buffers   4 64k;
postpone_output  1460;
#open_file_cache max=1000 inactive=30s;
#open_file_cache_valid    60s;
#open_file_cache_min_uses 2;
#open_file_cache_errors   off;
client_max_body_size    100m;
client_body_buffer_size 256k;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
client_header_timeout  3m;
client_body_timeout 3m;
send_timeout     3m;
include "/usr/local/nginx/conf/vhosts/*.conf";
}

保存退出.

五.为apache安装rpaf模块,该模块用于apache做后端时获取访客真实的IP.

1.使用apxs安装模块.这里要使用此前apache编译安装后的apxs

cd /usr/local/src/
tar -zxf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

2.编辑/usr/local/apache/conf/httpd.conf,添加模块参数,查找LoadModule php5_module modules/libphp5.so,在下方添加:

LoadModule rpaf_module modules/mod_rpaf-2.0.so
#Mod_rpaf settings
RPAFenable On
RPAFproxy_ips 127.0.0.1 [your_ips]
RPAFsethostname On
RPAFheader X-Forwarded-For

上面出现的[your_ips]请修改为你本机所监听web服务的ip.多个IP用空格空开.

六.安装ftp服务器:pure-ftpd

1.编译安装

cd /usr/local/src/
tar -zxf pure-ftpd-1.0.28.tar.gz
cd pure-ftpd-1.0.28
./configure –prefix=/usr/local/pureftpd –with-language=simplified-chinese –with-everything
make
make install
chmod 755 configuration-file/pure-config.pl
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
mkdir /usr/local/pureftpd/etc/
cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
ln -s /usr/local/pureftpd/bin/pure-pw /usr/local/bin/

2.配置pure-ftpd,这里采用PureDB的验证方式.

vi /usr/local/pureftpd/etc/pure-ftpd.conf

查找 PureDB /etc/pureftpd.pdb 取消前面的#号并设置成PureDB/usr/local/pureftpd/etc/pureftpd.pdb
查找 PassivePortRange 取消前面的#号
其他参数根据需要进行修改

3.添加自启动.这里不创建init脚本.直接放在/etc/rc.local启动即可

echo “/usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf –daemonize” >> /etc/rc.local

至此.所有安装工作结束.

如何使用这套系统

一,做好必要的安全工作

设置用户家目录/home/user,相关配置参数文件,以及访问日志等目录的权限.

chmod 711 /home
chmod 711 /usr/local/pureftpd/etc
chmod 711 /usr/local/apache/conf/vhosts
chmod 711 /usr/local/nginx/conf/vhosts
chmod 711 /usr/local/apache/domlogs
chmod 711 /usr/local/apache/logs

二,如何创建用户

创建用户分两个步骤.第一步创建系统用户.该命令直接创建用户家目录.第二步创建ftp用户.创建该用户依赖系统用户的创建.步骤如下(以创建用户名为admin为例):

useradd admin -m -s /sbin/nologin
pure-pw useradd admin -u admin -g admin -d /home/admin -m[第一次执行不可用]
pure-pw mkdb[仅限第一次执行]

注意.通过上述方法安装的ftp服务器在第一次创建用户的时候不可以在pure-pw useradd …后直接添加参数-m更新ftp用户数据库.需要分两步执行.以后可以直接在创建用户时在后面添加参数-m,执行之后会提示让你输入密码.需要重复输入两次.

三.如何绑定域名

由于采用前后端操作.因此需要修改两个服务器软件的虚拟主机参数.实例如下(以admin.com为例,用户目录承接上文的/home/admin):

1.创建nginx虚拟主机参数

cd /usr/local/nginx/conf/vhosts
touch admin.com.conf
vi admin.com.conf
输入以下内容:

server {
 error_log /usr/local/nginx/logs/admin.com-error_log warn;
 listen 127.0.0.1:80;
 server_name admin.com www.admin.com;
 access_log off;
 location ~* \.(gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg \
|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|rar \
|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
 access_log /usr/local/apache/domlogs/admin.com combined;
 root /home/admin/public_html;
 expires 7d;
 try_files $uri @backend;
 }
 error_page 400 401 402 403 404 405 406 407 408 409 500 501 502 503 504 @backend;
 location @backend {
 internal;
 proxy_connect_timeout 30s;
 proxy_send_timeout   300;
 proxy_read_timeout   300;
 proxy_buffer_size    64k;
 proxy_buffers     16 32k;
 proxy_busy_buffers_size 64k;
 proxy_temp_path      /dev/shm/proxy_temp;
 proxy_redirect http://admin.com:81 http://admin.com;
 proxy_redirect http://www.admin.com:81 http://www.admin.com;
 proxy_pass http://127.0.0.1:81;
 proxy_set_header   Host   $host;
 proxy_set_header   X-Real-IP  $remote_addr;
 proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
 }
 location ~* \.(ftpquota|htaccess|asp|aspx|jsp|asa|mdb)$ {
 deny  all;
 }
 location / {
 proxy_connect_timeout 30s;
 proxy_send_timeout   300;
 proxy_read_timeout   300;
 proxy_buffer_size    64k;
 proxy_buffers     16 32k;
 proxy_busy_buffers_size 64k;
 proxy_temp_path      /dev/shm/proxy_temp;
 proxy_redirect http://admin.com:81 http://admin.com;
 proxy_redirect http://www.admin.com:81 http://www.admin.com;
 proxy_pass http://127.0.0.1:81/;
 proxy_set_header   Host   $host;
 proxy_set_header   X-Real-IP  $remote_addr;
 proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
 }
}

保存退出,注意将上述出现的127.0.0.1替换本机监听web服务的IP

2.创建apache虚拟主机配置文件

cd /usr/local/apache/conf/vhosts
touch admin.com.conf
vi admin.com.conf
输入以下内容:

<VirtualHost 127.0.0.1:81>
 ServerName admin.com
 ServerAlias www.admin.com
 DocumentRoot /home/admin/public_html
 ServerAdmin admin@evlit.com
 UseCanonicalName Off
 CustomLog /usr/local/apache/domlogs/admin.com combined
 php_admin_value open_basedir "/home/admin:/usr/lib/php:/usr/local/lib/php:/tmp"
 <IfModule !mod_disable_suexec.c>
 SuexecUserGroup admin admin
 </IfModule>
 ScriptAlias /cgi-bin/ /home/admin/public_html/cgi-bin/
</VirtualHost>

保存退出,注意将上述出现的127.0.0.1替换本机监听web服务的IP,用户名admin改为虚拟主机用户的名称.

四.如何管理MySQL数据库

1.下载最新版PhpMyAdmin源码包

mkdir -p /var/www/html
chmod -R 711 /var/www
cd /var/www/html
wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.3.3/phpMyAdmin-3.3.3-all-languages.zip/download
unzip phpMyAdmin-3.3.3-all-languages.zip
mv phpMyAdmin-3.3.3-all-languages phpmyadmin

2.增加apache配置,编辑httpd.conf,转到最后一行

cd /usr/local/apache/conf
vi httpd.conf /* shift+g转到最后一行 */
#Managed Tools
<VirtualHost 127.0.0.1:81 *>
ServerName localhost
ServerAlias pma.*
DocumentRoot /var/www/html/phpmyadmin
ServerAdmin admin@localhost
UseCanonicalName Off
</VirtualHost>

同样,修改上述出现的127.0.0.1为你提供web服务的IP.重启apache后.我们打开绑定到服务器IP的pma.yourdomain.com即可访问到phpmyadmin.第一次使用.需要进行配置.具体配置请善用Google.

其他没有照顾到的地方自行添加即可.如perl,sendmail等.

为方便管理员添加用户及绑定域名.我编写了一个脚本.

wget http://icodex.org/vhosts
chmod 755 vhosts
./vhosts

转载:

http://icodex.org/2010/03/nginx-apache-guide/

Posted in Linux | Leave a comment
  •  

    January 2012
    M T W T F S S
    « Dec    
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031