月度归档:2013年02月

Nginx ngx_http_index_module模块基本指令整理

原创文章,转载请指明出处并保留原文url地址

本文主要针对nginx的ngx_http_index_module 模块做简单介绍,本文具体包括如下指令:index

ngx_http_index_module模块处理以斜杠(“/”)开头的请求, 类似的请求也可以被ngx_http_autoindex_module和ngx_http_random_index_module模块所处理。

配置日子如下:

location / {

index index.$geo.html index.html;

}

Nginx原文:

The module ngx_http_index_module processes requests ending with the slash character (‘/’). Such requests can also be processed by ngx_http_autoindex_module and ngx_http_random_index_module modules.

Example Configuration

location / {

index index.$geo.html index.html;

}

1. index

syntax:index      file...;
default:index index.html;
context:http, server, location

定义被作为index页面(一般式默认页面,就是不输入任何页面地址时, 网站应该打开的页面)的文件。 这个文件名可能包括变量。 文件被按照次序(书写次序, 写在最后最后被检查)进行检查。在文件列表中最后一个内容可以是包括绝对路径的文件(其他的应该是相对路径的文件名称)

例如:

index index.$geo.html index.0.html /index.html;

应当指出的是,使用一个索引文件时,一个内部的重定向被产生,一个请求在多个不同的location中进行处理,例如下面的配置:

location = / {

index index.html;

}

location / {

...

}

请求(“/”)实际上是将在第二位置的location中被处理。(显然例子中有两个location配置, 用户请求过来后nginx会进行匹配, 越精确的匹配越先进行, 首先匹配的是=/的location, 然后在这个里面进行了 配置, 需要获取index.html, 之后这个文件要到哪里去找, 只好到下面的location中去配置的文件中去找。)

Nginx原文:

Defines files that will be used as an index. The file name can contain variables. Files are checked in the specified order. The last element of the list can be a file with an absolute path. Example:

index index.$geo.html index.0.html /index.html;

It should be noted that when using an index file, an internal redirect is made, and request can be processed in a different location. For example, with the following configuration:

location = / {

index index.html;

}

location / {

...

}

a request of “/” will actually be processed in the second location as “/index.html”.

PHP IDE

来源:http://www.laogui.com/28/PHPIDE

我这里整理的都是专门为PHP设计的IDE,editplus,Ultra Edit等常用文本工具我就不介绍了!其中一些介绍是从那些下载站里复制过来的!

Zend Studio

开发商:http://www.zend.com/store/products/zend-studio.php
目前公认的最强大的PHP开发工具,这种集成软件包包括了用于编辑,调试,配置PHP程序所需要的客户及服务器组件,软件包具有工业标准的PHP开发环境,代码完成引擎,功能齐全的调试器等

NuSphere PHPEd

http://www.nusphere.com/
PhpED 通过无与伦比的PHP调试和压缩能力,以及一个新的NuSOAP web服务向导成为了PHP领域的领军产品。更加强大的Project Manager使得发布站点和应用程序比以前更加容易。现在可以在线程级别对正在运行或者开发中的程序进行测试和调校。支持 CVS 版本控制,而且,对PostgreSQL和MySQL数据库的本地支持为PHP使用开源数据库提供了一个广泛的环境。但对中文支持不太好,汉字都当作单字节处理了。PHPED还有Linux版本。

PHP Coder

http://www.phpide.de/
PHPCoder 用于快速开发和调试PHP应用程序,它很容易扩展和定制,完全能够符合开发者的个性要求.1:结合了PHP编译器和参考文档,可以对编辑中的PHP脚本进行即时预览2:支持高亮显示HTML和PHP代码;3:自动完成功能,可以自动完成用户自定义代码片断;4:标准函数提示;5:有专门的工程项目管理器;6:对象浏览器搜寻编辑中文件的包含信息,自定义函数,并以树形显示.7:支持查找对称的语句标记符;8:支持高级搜索和替换;9:自带FTP功能;10:支持运行和断点调试11:......总之,PHPCoder是一个非常实用的,功能强大的编程环境,而且它是免费的!

Ankord PHP Expert Editor

http://www.ankord.com/phpxedit.html
PHP Expert Editor是一个容易使用的 PHP 开发工具,它的功能照顾到初级者及专业开发人员。 PHP Expert Editor 内建 http server 用作测试及除错(你也可以使用其他 http server), PHP 语法检查, FTP 功能, 程式码样板等功能。

DzSoft PHP Editor

http://www.dzsoft.com/dzphp.htm
专为 PHP 所设计的网页程序编辑软件 - DzSoft PHP Editor,具有 PHP 编辑、侦错、浏览、原始码检视、档案浏览、可自订的原始码样本..等功能,无须架设网站主机就可以测试 PHP 指令码,是一套功能强大的 PHP 编程软件。
DzSoft PHP Editor和Ankord PHP Expert Editor非常相识,几乎找不到他们的主要区别,关于这两个软件之间的具体内幕我也不太清楚!

Dev-PHP IDE

非常好用的php编辑器,支持php-gtk,內建許多快速html表单,非常的好用,本身含繁体语言包,另附暗地论坛的中文语言包
http://devphp.sourceforge.net/

Master PHP

http://www.gsoftwares.com/
一款支持PHP, PHP3, PHTML, CSS, JS, HTML, HTM and SQL的编辑器,它允许用户编辑多种一次编辑多种文件,允许插入,运行和最优化程序的脚本,用户可以通过工具栏定制按钮和窗体,可以导出html和rtf格式,支持18种语言

Komodo

http://www.activestate.com/Products/Komodo/
Komodo支持在Windows与Linux上,Perl、Python及JavaScript等的程序语言开发,以及多种程序语言语法不同颜色标注。这款功能强大的IDE竟然不支持中文,连中文文件名的文件都打不开!

Maguma Studio

http://www.maguma.com/
Maguma Studio包含了编辑和调试 PHP 程序所有必须的工具。无论您是经验丰富的开发者、或是初学者它都适合您。带有十分完整的断点、分步等调试功能。支持以树形方式显示文件中的函数和类成员。

PhpLens

http://phplens.com
PhpLens是一款专为PHP开发人员准备的快速数据库开发程序。通过使用PhpLens,可以快速的设计、发布和维护数据库驱动的网络产品。它允许你以HTML表格的形式对数据库进行浏览、编辑、创建、删除和查找。不用写任何代码,它就允许你完成上述操作。
先介绍到这里,以后再慢慢整理,虽然上面的软件都很强大,但我最习惯用的还是editplus。一则我水平不够,这些软件的很多功能用不上,二则英文太差,想用他们还需要熟悉一段时间,更多的PHP IDE可以参考这篇文章http://www.linuxdocs.org/HOWTOs/PHP-HOWTO-9.html

Nginx ngx_http_image_filter_module模块基本指令整理

原创文章,转载请指明出处并保留原文url地址

本文主要针对nginx的ngx_http_image_filter_module 模块做简单介绍,本文具体包括如下指image_filter,image_filter_buffer,image_filter_jpeg_quality,image_filter_sharpen,image_filter_transparency

ngx_http_image_filter_module模块是一个用于在JPEG, GIF, 和PNG 图片格式之间进行转换的过滤模块(nginx的一个术语)。

这个模块不是nginx内建模块,需要通过--with-http_image_filter_module指令进行进行开启相关功能。

这个模块使用libgd库, 推荐采用最新版本的库。

配置示例如下:

location /img/ {

proxy_pass   http://backend;

image_filter resize 150 100;

image_filter rotate 90;

error_page   415 = /empty;

}

location = /empty {

empty_gif;

}

Nginx原文:

The ngx_http_image_filter_module module (0.7.54+) is a filter that transforms images in JPEG, GIF, and PNG formats.

This module is not built by default, it should be enabled with the --with-http_image_filter_module configuration parameter.

This module utilizes the libgd library. It is recommended to use the latest available version of the library; it is version 2.0.35 as of this writing.

Example Configuration

location /img/ {

proxy_pass   http://backend;

image_filter resize 150 100;

image_filter rotate 90;

error_page   415 = /empty;

}

location = /empty {

empty_gif;

}

1. image_filter

syntax:image_filter  off;
image_filter  test;
image_filter  size;
image_filter  rotate 90 | 180 | 270;
image_filter  resize width height;
image_filter  crop width height;
default:image_filter off;
context:location

设置图像变换的类型

Off: 关闭一个访问类的图片变换处理功能(一般是一个nginx配置的location)

Test:确认在返回给用户的相应图片是JPEG, GIF, or PNG 格式的, 否则报415 错误(不支持的媒体文件类型)

Size: 采用json格式输出信息,例如:

{ "img" : { "width": 100, "height": 100, "type": "gif" } }

如果发生错误则输出如下

{}

rotate 90|180|270

逆时针旋转图像到设定的度数,这个值可以包括变量(配置时是个变量, 到执行具体这个条指令是, 变量需要实例化成具体的值),指令可以单独使用,也可以同resize 和crop 变换结合使用

调整高度和宽度(resize width height)

保持比例(原意是按照比例, 但是根据推测,这里的图片缩小等一定会保持原始图片的显示比例, 然后根据设定的宽度或者高度进行相关的缩放, 否则一定带来图片的比例失真,用户体验会比较差)的缩减图像到指定的尺寸。通常为了缩减等, 可以仅仅使用一个维度的设置(例如仅仅指定,宽度或者高度), 被省略的维度可以用“-”符号替代,在这种情况下, 若是发生错误,则给用户反馈一个415的错误代码(不支持的媒体类型)。这个指令的值可以是一个变量。当使用时伴随一个rotate参数,则缩放完成后进行旋转操作。

裁剪图像到指定的宽高(crop width height)

按照比例将图片调整到合适大小(最后一个维度达到设定值后停止变换, 然后裁剪掉超出的部分。 同上面指令区别是,上面是第一维度达到设定值后,停止变换, 然后将其他地方用背景或者设定的留白填充(我自己推测的, 没去测试))。通常为了缩减等操作, 可以仅仅使用一个维度的设置(例如仅仅指定,宽度或者高度), 被省略的维度可以用“-”符号替代,在这种情况下, 若是发生错误,则给用户反馈一个415的错误代码(不支持的媒体类型)。这个指令的值可以是一个变量。当使用时伴随一个rotate参数,则缩放完成后进行旋转操作。

Nginx原文:

Sets the type of transformation to perform on images:

off

turns off module processing in a surrounding location.

test

ensures that responses are images in either JPEG, GIF, or PNG format. Otherwise, the error 415 (Unsupported Media Type) is returned.

size

outputs information about images in a JSON format, e.g.:

{ "img" : { "width": 100, "height": 100, "type": "gif" } }

In case of an error, the following is output:

{}

rotate 90|180|270

rotates images counter-clockwise by the specified number of degrees. Value of the parameter can contain variables. Can be used either alone, or along with the resize and crop transformations.

resize width height

proportionally reduces an image to the specified sizes. To reduce by only one dimension, another dimension can be specified as “-”. In case of an error, the server will return code 415 (Unsupported Media Type). Values of parameters can contain variables. When used along with the rotate parameter, the rotation happens after reduction.

crop width height

proportionally reduces an image to the size of the largest side and crops extraneous edges by another side. To reduce by only one dimension, another dimension can be specified as “-”. In case of an error, the server will return code 415 (Unsupported Media Type). Values of parameters can contain variables. When used along with the rotate parameter, the rotation happens before reduction.

2. image_filter_buffer

syntax:image_filter_buffer    size;
default:image_filter_buffer   1M;
context:http, server, location

设置用于读取图像缓冲区的最大大小。当一个大小超过设定值,服务器将返回错误415(不支持的媒体类型)。

Nginx原文:

Sets the maximum size of the buffer used for reading images. When a size is exceeded the server will return error 415 (Unsupported Media Type).

3. image_filter_jpeg_quality

syntax:image_filter_jpeg_quality  quality;
default:image_filter_jpeg_quality 75;
context:http, server, location

设置转换jpeg图片的期望图片质量值(质量高,设置值大, 显示效果好, 但是图片尺寸大, 不利于传输)。可以接受的设置值是1到100之间。最大的可以推荐值是95.这个值可以包括一个变量

Nginx原文:

Sets the desired quality of the transformed JPEG images. Acceptable values are in the 1..100 range. Lesser values usually imply both lower image quality and less data to transfer. The maximum recommended value is 95. Value of the parameter can contain variables.

4. image_filter_sharpen

syntax:image_filter_sharpen   percent;
default:image_filter_sharpen 0;
context:http, server, location

增加图片的锐化程度(图像相邻显示像素之间的跳跃变换程度增加, 连续程度降低, 某种程度上可以减少图像模糊感觉, 增加一定的清晰度, 但是会增加图片的颗粒化程度),锐化比例程度可以超过100%, 但是0值是被禁止的。这个在可以包括变量

Nginx原文:

Increases sharpness of the final image. The sharpness percentage can exceed 100. The value of 0 disables sharpening. Value of the parameter can contain variables.

5. image_filter_transparency

syntax:image_filter_transparency   on|off;
default:image_filter_transparency on;
context:http, server

设定当进行png(具有特定调色板的png图片)或者gif图片处理时, 是否保留透明部分。透明度的损失可以允许获取更好的图像显示效果。Alpha通道的透明性质在png图片中是被保留的。

Nginx原文:

Defines whether transparency should be preserved when transforming PNG images with colors specified by a palette, or in GIF images. The loss of transparency allows to obtain images of a better quality. The alpha channel transparency in PNG is always preserved.

Nginx ngx_http_headers_module模块基本指令整理

原创文章,转载请指明出处并保留原文url地址

本文主要针对nginx的ngx_http_headers_module 模块做简单介绍,本文具体包括如下指令:add_header, expires

该ngx_http_headers_module模块允许发出“Expires”和“Cache-Control”控制头域,并可以添加其他头部与到相应头中。

配置示例:

expires    24h;

expires    modified +24h;

expires    @24h;

expires    0;

expires    -1;

expires    epoch;

add_header Cache-Control private;

;

Nginx原文:

The ngx_http_headers_module module allows to emit the “Expires” and “Cache-Control” header fields, and to add arbitrary fields to a response header.

Example Configuration

expires    24h;

expires    modified +24h;

expires    @24h;

expires    0;

expires    -1;

expires    epoch;

add_header Cache-Control private;

;

1. add_header

syntax:add_header  name  value;
default:
context:http, server, location, if in location

向相应代码为200, 201, 204, 206, 301, 302, 303, 304, or 307的相应(response)中添加指定的相应头。头的值可以为一个变量。

Nginx原文:

Adds the specified field to a response header provided that the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307. A value can contain variables.

2. expires

syntax:expires   [modified] time;
expires   epoch | max | off;
default:expires off;
context:http, server, location, if in location

向相应代码为200, 201, 204, 206, 301, 302, 303, 304, or 307的相应中开启或者关闭添加或者改变“Expires” 和“Cache-Control”头部域的功能(若是开启,这添加或者改变相应头部域)。 参数值(时间)可以为正也可以为负

“Expires” 的时间作为当前指令指定的时间与当前时间(系统时间)的和。如果modified 参数被指定, 时间计算做文件修改时间与指令的指定时间的和

此外,有可能使用“@”前缀指定一个时间每天,例如:expires @15h30m;

epoch 参数对于绝对时间“Thu, 01 Jan 1970 00:00:01 GMT”, (当指定这个参数后,相应域中 “Cache-Control”值依赖于指令中指定的特定时间)

时间参数是负数时, “Cache-Control: no-cache”.

时间常数是整数或者0时: “Cache-Control: max-age=t”, t是指令中指定的时间参数,单位是秒

“Expires”的最大值是 “Thu, 31 Dec 2037 23:55:55 GMT”, “Cache-Control”最大值是10年

Off参数禁止向相应头中添加或者改变相应头中“Expires” 和“Cache-Control”参数。

Nginx原文:

Enables or disables adding or modifying the “Expires” and “Cache-Control” response header fields provided that the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307. A parameter can be a positive or negative time.

A time in the “Expires” field is computed as a sum of the current time and time specified in the directive. If the modified parameter is used (0.7.0, 0.6.32) then time is computed as a sum of the file’s modification time and time specified in the directive.

In addition, it is possible to specify a time of the day using the “@” prefix (0.7.9, 0.6.34):

expires @15h30m;

The epoch parameter corresponds to the absolute time “Thu, 01 Jan 1970 00:00:01 GMT”. The contents of the “Cache-Control” field depends on the sign of the specified time:

time is negative — “Cache-Control: no-cache”.

time is positive or zero — “Cache-Control: max-age=t”, where t is a time specified in the directive, in seconds.

The max parameter sets “Expires” to the value “Thu, 31 Dec 2037 23:55:55 GMT”, and “Cache-Control” to 10 years.

The off parameter disables adding or modifying the “Expires” and “Cache-Control” response header fields.

Nginx ngx_http_gzip_static_module模块基本指令整理

原创文章,转载请指明出处并保留原文url地址

本文主要针对nginx的ngx_http_gzip_static_module模块做简单介绍,本文具体包括如下指令:gzip_static

这个ngx_http_gzip_static_module模块允许发送具有".gz"扩展名的预编译文件给客户端。

这个模块不是默认的内建模块, 需要采用--with-http_gzip_static_module配置指令进行配置来开启相关功能。

配置例子如下:

Example Configuration

gzip_static  on;

gzip_proxied expired no-cache no-store private auth;

Nginx原文:

The ngx_http_gzip_static_module module allows to send precompressed files with the “.gz” filename extension instead of regular files.

This module is not built by default, it should be enabled with the --with-http_gzip_static_module configuration parameter.

Example Configuration

gzip_static  on;

gzip_proxied expired no-cache no-store private auth;

1. gzip_static

syntax:gzip_static         on | off | always;
default:gzip_static off;
context:http, server, location

“on”和“off”打开或者关闭预编译文件存在的检查的功能, 下面的指令也将被参考:

gzip_http_version, gzip_proxied, gzip_disable和gzip_vary。

当配置取值为“always”时,gzip文件形式在这种情况下都适用,不用检查是否客户端支持压缩功能。这个选项适合在磁盘上没有解压缩文件或者使用ngx_http_gunzip_module模块情况。

文件可以采用gzip命令进行压缩或者采用其他兼容命令进行。建议修改压缩文件的时间日期同原始文件的时间日期相同

Nginx原文:

Enables (“on”) or disables (“off”) checking the existence of precompressed files. The following directives are also taken into account: gzip_http_version, gzip_proxied, gzip_disable, and gzip_vary.

With the “always” value (1.3.6), gzipped file is used in all cases, without checking if the client supports it. It is useful if there are no uncompressed files on the disk anyway or the ngx_http_gunzip_module is used.

The files can be compressed using the gzip command, or any other compatible. It is recommended that the modification date and time of original and compressed files be the same.