在linux操作系统中下安装rar解压缩

2

分类 : 技术文摘 | 发表时间 22-09-2008

winzip虽然最近也在努力更新,但已经实在太晚了。winrar已经占据了大片江山了。并且还有一个7z也很好用。那么在linux下如何安装rar解压缩程序呢?

第一:下载、安装

1、到网上下载rar for linux,下载地址
2、然后解压:# tar xvfz rarlinux-3.7.b1.tar.gz
3、安装
# make install
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cp rar unrar /usr/local/bin
cp rarfiles.lst /etc
cp default.sfx /usr/local/lib

第二:使用

1. rar e test.rar 解压RAR档
2. rar a 压缩后的文件名.rar?待压文件或目录
4、解压文件:
# rar x test.rar /
rar: /lib/tls/libc.so.6: version `GLIBC_2.4′ not found (required by rar)

5、需要GLIBC_2.4。如果没有GLIBC_2.4可以

# cp ./rar/rar_static /usr/local/bin/rar

若运行RAR提示如下:
rar: /lib/tls/libc.so.6: version `GLIBC_2.4′ not found (required by rar)

则用里面提供的 rar_static 版本即可。那是 static linking 版本,不会有 glibc 程式库版本不和的问题。

再次解压: 
# rar x test.rar /

RAR 3.71 Copyright (c) 1993-2007 Alexander Roshal 20 Sep 2007
Shareware version Type RAR -? for help

Extracting from test.rar
Extracting /test.txt OK 
 
解压成功。

若你要任何地方都可以跑 rar,请把 rar_static 复制到 /usr/local/bin 目录内成为 rar 这个档名即可。一般 PATH 变量都会包含 /usr/local/bin,所以任何目录下都可以执行 rar 命令。

关键引用:http://www.nutchchina.com/blog/index.php?op=ViewArticle&articleId=60&blogId=1

有些意外 微软发布为PHP提供的SQL Server 2005驱动

0

分类 : 业界动态 | 发表时间 28-08-2008

确实非常意外。以前asp与access针对个人小站,asp与sqlserver,开发中型企业门户,php与mysql,linux下的高端高性能高负载网站,特别流行的是大量的资讯网站与论坛,这种组合,似乎已经在意识中固化,同时也显得很自然,这样的搭配,大家都认为很正常。至于asp与mysql,php与sqlserver,这种组合,从来就没想过;随着php与mysql的日趋流行,php高效的地方也逐渐替代asp,微软就此适时发布了专为PHP所用的SQL Server 2005驱动(SQL Server 2005 Driver for PHP)1.0版。

这一驱动的目的是在PHP和SQL Server 2005之间提供更强大的交互功能:

SQL Server 2005 Driver for PHP是PHP 5的一个扩展,用来访问SQL Server
2005。这一扩展为所有的SQL Server 2005版本(包括速成版),提供了一个数据访问编程接口。SQL Server 2005
Driver for PHP API提供了对Windows认证、交易、参数绑定、流、元数据访问和错误处理的支持。(MSDN) 

该驱动现在可以从微软网站上下载。MSDN另外还提供了一个应用示例和详细文档

基于微软公共协议(Microsoft Public License,Ms-PL),微软还在CodePlex上发布了这个驱动的源代码。开发人员可以用这些源代码创建自己的应用,但是微软仅对MSND下载站点上的签约驱动版提供支持。

SQL Server 2005 Driver for PHP需要微软SQL Server 2005 ODBC驱动的支持,而该ODBC驱动只用于Windows平台。目前微软还没有计划要为其他操作系统平台提供类似的驱动。

查看英文原文:Microsoft SQL Server 2005 Driver for PHP Released

玩php的,试下php与sqlserver的搭配吧!

手动关闭gzip方法(phpwind、discuz和supesite)

2

分类 : 网络日志 | 发表时间 05-11-2007

前段时间,禁论坛禁得厉害;因此,很多主机商不得不安装了主机关键字过滤系统,这个星外的监控过滤系统,新版本加入了关闭gzip的选项(因为gzip模式是加密压缩传输,如果不关闭这个选项,就无法监控过滤关键字),由此就引起了一些php系统关闭gzip的方法讨论,很多朋友在询问一些系统的关闭方法,就此简单总结一些常用的;如果是直接登陆系统后台修改,就需要由主机商来提供合作,暂时关闭监控过滤系统或者关闭自己域名的监控,如果主机商无法提供合作(当然,这不一定是不愿意,而是有关安全操作等方面的问题),就需要先手动关闭,然后登陆后台再关闭。

phpwind论坛系统:

\data\bbscache\config.php
修改:
$db_obstart=’1′;

$db_obstart=’0′;

登录论坛后台,找到论坛核心设置–核心功能设置,禁止GZIP功能。

后台登录地址为:http://您的域名/admin.php

discuz论坛系统:

方法一:
使用ftp进入论坛
将  forumdata/cache/cache_settings.php 下载到本地,

修改里面的
‘gzipcompress’ => 1,

改成
‘gzipcompress’ => 0,

修改完成后保存。上传回去。你的论坛就可以访问了。

然后登录论坛后台,找到基本设置–服务器优化,禁止GZIP功能。

后台登录地址:http://您的域名/logging.php?action=login

方法二:

把附件里的程序上传到你的论坛根目录下。运行即可。

关闭gzip.rar

运行后页面空白,但gzip己经关闭了。再打开首页即可

方法三:

尝试使用tools工具 升级sql:

UPDATE `cdb_settings` SET `value` = ’0′ WHERE CONVERT( `variable` USING utf8 ) = ‘gzipcompress’ LIMIT 1 ;

tools工具下载
http://www.discuz.net/thread-761181-1-1.html

升级后 清除forumdata/cache和forumdata/templates下面的文件,然后重新访问

supesite网站系统:

登录FTP,修改data\system目录下的config.cache.php文件,找到’gzipcompress’ => 1,,改为:’gzipcompress’ => 0,,然后进入后台正式关闭

SupeSite/X-Space后台地址为:http://您的域名/?action-login

清除本地cookie

4、ShopEx 商城:

4.7.1版本解决办法:由于ShopEX设计上的缺陷,无法单独修改设置,需要下载经过修改index.php文件替换您的网站根目录下的index.php 点击这里下载

4.7.2版本解决办法:在根目录的include目录中找到mall_config.php文件(此文件在安装成功后都会有的),在?>前增加下面一段话就可以关闭系统的gzip功能
define(‘SYS_GZIP’, false);

ShopEx 商城后台地址为:http://您的域名/syssite/shopadmin/

5、SaBlog 博客:

登录FTP,下载cache/cache_settings.php这个文件,将第64行的
‘gzipcompress’ => ’1′,
修改为
‘gzipcompress’ => ’0′,
然后上传覆盖回去即可。

SaBlog 博客后台地址为:http://您的域名/?action-login

6、动网PHP版本论坛:

登录FTP,下载论坛根目录下的global.php,查找以下内容,
if (!$zliboutputenable AND function_exists(‘ob_gzhandler’)) {
$db_obstart = 1;
修改为
if (!$zliboutputenable AND function_exists(‘ob_gzhandler’)) {
$db_obstart = 0;
然后上传覆盖即可。

7、Ecshop:

ECSHOP 管理中心 – 商店设置 -基本设置-是否启用Gzip模式: 禁用

Linux下代理服务器安装调试一例

0

分类 : 技术文摘 | 发表时间 16-04-2006

作为一种免费的网络操作系统,Linux越来越受到广大网络爱好者的欢迎了,目前因特网(Internet)上运行的主机有相当一部分采用的就是 linux操作系统,而且中国已经把linux操作系统作为政府上网年的指定网络操作系统,种种迹象表明,linux操作系统正在逐渐走向成熟。今天,我给大家介绍一种能在Linux系统下使用的比较优秀的代理服务器软件的安装和调试方法。

  众所周知,当今因特网发展速度极其迅猛,IP地址资源非常紧张。而如果您想访问因特网,共享因特网的丰富资源,您的机器必须拥有一个标准的IP地址。在因特网上,IP地址是识别您的机器的唯一标志。目前,有两种方式可以让您的机器拥有标准的IP地址:一种是局域网通过专线接入因特网,您的机器可以拥有静态的IP地址。所谓静态IP地址,就是对使用者来说,是固定不变的IP地址,这个IP地址给您使用后,其他人就不能再用了。一种是通过电话线拨号或 ISDN拨号等方式接入因特网,您的机器可以在您拨号上网的在线期间从ISP的访问服务器的IP地址池中获得一个临时的标准IP地址,这个IP地址在您下线后就不归您使用了,而您下次拨号再上网,很可能分配给您的机器的是另外一个临时的IP地址了。这种临时分配的IP地址,称为动态IP地址。无论是静态地址还是动态地址,在您的机器访问因特网时,使用起来没有什么区别。

  现在因特网发展速度这么快,而IP地址资源又这么紧张,这不能不说是一个尖锐的矛盾。虽说Ipv6正在开发中,但远水不解近渴,好多的企业、公司内部的Intranet现在就想接入因特网这个浩瀚的资源海洋,但又苦于没有充足的IP地址资源,怎么办?还好,有代理服务这个好东西。代理服务是指由一台拥有标准IP地址的机器代替若干没有标准IP地址(以下称内部地址)的机器和因特网上的其他主机打交道,提供代理服务的这台机器称为代理服务器。拥有内部地址的机器想到因特网上查找资料时,先把这个请求发给拥有标准IP地址的代理服务器,由代理服务器把这个请求通过它的标准IP地址发到请求的目标地址。然后目标地址的服务器把返回的结果发回给代理服务器,代理服务器再原封不动的把资料发给最初那台拥有内部IP地址的机器。这样就完成了一次内部机器访问因特网的一个过程。若干拥有内部地址的机器就组成了内部网,代理服务器的作用就是勾通内部网和因特网,解决内部网访问因特网的问题。而且这种代理是不可逆的,因特网上的主机不能访问任何一台拥有内部地址的机器,这样又可以保障内部资料的安全性。

  能够完成这种代理功能的服务器软件有好多,我给大家推荐一种能在linux下使用的比较优秀的代理服务器软件Squid。之所以说它比较优秀,一方面是因为它可以在代理服务器上作一个很大的缓存,可以把好多常去的网站内容存储到缓存中,这样,内部网的机器再访问那些网站,就可以从缓存里调用了。这样一可以加快内部网浏览因特网的速度,二可以减少专线的数据流量。另一方面,Squid不仅仅支持HTTP协议,而且还支持FTP,GOPHER,SSL和 WAIS等协议。下面我将逐步介绍该服务器软件的下载、编译、安装和调试。
  一、 准备工作

  最好是为Squid建立专用的运行帐号和用户组。比如建立新帐号test1,把该帐号归为test组,把该帐号的根目录设为/usr/local/squid。以下操作均由这个专用帐号来完成。

  二、 下载:

  可以在http://squid.nlanr.net/Squid/ 处下载Squid代理服务器软件。文件名字是 squid-2.2.STABLE3-src.tar.gz。这是一个压缩以后的数据包。假设下载后我们把它放在 /usr/local/squid/src目录里。

  三、 解压缩数据包

  进入/usr/local/squid/src目录,键入如下命令:

  gzip –dc squid-2.2.STABLE3-src.tar.gz | tar –xvf –

  这个命令将该数据包解开,建立一个目录叫作squid-2.2.STABLE3,并且把所有的文件放在这个目录里面。

  四、 编译源程序

  首先运行配置脚本,以便生成适合您的机器的编译脚本。命令格式是:

  ./configure

  这种方式产生的编译脚本编译后默认安装路径是/usr/local/squid。

  如果想改变安装路径,需要用以下格式:

  ./configure –prefix=/some/other/directory

  这种方法编译后安装到/some/other/directory里面。

  生成编译脚本后,可以正式开始编译了。命令为:

  make

  五、 安装Squid代理服务器

  编译无误,安装显得更加简单了。命令为:

  make install

  安装完成后,会在您指定的安装路径里产生一个squid目录,squid目录下有三个目录:etc、bin、logs。其中etc里面是配置文件,bin里面是执行文件,logs里面是日志文件。

  六、 调试代理服务器

  安装结束后就是调试服务器,使其按照您的要求工作。Squid的配置文件只有一个,在etc目录里,名字是squid.conf,所有的配置选项都在这个文件里面。而且每个配置项目都有注释说明。我们就不一一介绍所有的配置项目了,只介绍几个常用的项目。

  首先,在squid文件里面找到下列配置项:

  cache_mem

  这里可以添上您准备给squid作为高速缓存使用的内存大小。注意,如果您的机器有N兆内存,那么,推荐您在这里添的数字是N/3。

  cache_dir /usr/local/squid/cache 100 16 256

  这里的第一个数字100是您准备给squid作为cache使用的硬盘空间大小,单位是兆。如果您想划100M空间当作cache,那么这里就写100。

  acl, http_access, icp_access

  用您的网络地址(比如:192.168.10.0)和子网掩码(比如:255.255.255.0)填写“allowed host”ACL访问控制列表。这是很重要的一项,它可以防止未经您授权的人窃取您的网络资源。

  acl manager proto cache_object

  acl localhost src 127.0.0.1/255.255.255.255

  acl all src 0.0.0.0/0.0.0.0

  acl allowed_hosts src 192.168.10.0/255.255.255.0

  http_access deny manager all

  http_access allow allowed_hosts

  http_access deny all

  icp_access allow allowed_hosts

  icp_access deny all

  cache_mgr

  这里填写cache管理员的Email地址,系统出错会自动提醒cache管理员。
 修改完配置文件,在正式运行squid代理服务器之前,先进行初始化。命令如下:

  % /usr/local/squid/bin/squid -z

  % /usr/local/squid/bin/squid

  检查cache.log文件确保所有部分运行正常。如果有出错信息,系统不能正常启动,一般情况是由于目录和文件的存取权限导致的,请仔细检查各目录和文件的权限设置。

  如果一切正常,那么就可以投入使用了。系统默认的服务端口是3128。

  七、 使用代理服务器

  在调试完成之后,就可以试试代理服务器了。将您的某台终端机设置成内部地址,将该终端的DNS服务器设置为代理服务器的DNS服务,在内部地址和标准地址之间作一个路由,这样,您应该在终端上可以ping通代理服务器的标准地址了。在您的浏览
器里设置代理服务器地址为squid代理服务器的地址,端口号为3128,试试浏览外面的网站,怎么样?成功了!!!

  代理服务器的安装调试结束了,您可以根据您的网络出口带宽,随时调整访问控制列表,决定代理多少台终端访问因特网。您还可以调整squid.conf的其他配置使其更能适应您的需要。

  最后说明一点,squid不仅可以用在Linux系统上,经过测试,它还可以用在以下系统上:AIX, Digital Unix, FreeBSD, HP-UX, Irix, NetBSD, Nextstep, SCO, Solaris等等。您还在等什么?赶快动手试试吧!

Backup your Linux System|备份你的 Linux 系统

0

分类 : 娱乐休闲 | 发表时间 10-03-2006

一、我们需要备份什么?

我的 Linux 系统是基于 Redhat 的Redhat Linux 9.0,同时配置了诸如 MySQL、PHP、Apache 等基础服务,同时又配有 Awstats、MRTG、MT 等应用服务程序,因此,我们需要备份的除了系统本身的重要文件以外,还需要备份数据库、log文件和统计数据文件等。当然另外一项必不可少的就是编译各项服务时的 ./configure 参数,这里就不赘述了。

二、制定备份文件列表。

这个步骤就是归纳一下需要备份的目录列表。以下我就依照我所安装的各项服务作了一个简单的list。 一些文件的地址是以我的服务器为标准(以”/”开头),一些则以相对目录来描述(以”./”开头)。

系统:


/etc /usr/local/etc
包含所有核心配置文件。这其中包括网络配置、系统名称、防火墙规则、用户、组,以及其他全局系统项。

/var
包含系统守护进程(服务)所使用的信息,包括 DNS 配置、DHCP 租期、邮件缓冲文件、HTTP 服务器文件、db2 实例配置,等等。

/home
包含所有用户的默认用户主目录。这包括他们的个人设置、已下载的文件和用户不希望失去的其他信息。

/root
是根(root)用户的主目录。

/opt
是安装许多非系统文件的地方。IBM 软件就安装在这里。OpenOffice、JDK 和其他软件在默认情况下也安装在这里。

系统中不需要备份的目录:


/proc
应该永远不要备份这个目录。它不是一个真实的文件系统,而是运行内核和环境的虚拟化视图。它包括诸如 /proc/kcore 这样的文件,这个文件是整个运行内存的虚拟视图。备份这些文件只是在浪费资源。

/dev
包含硬件设备的文件表示。如果计划还原到一个空白的系统,那就可以备份 /dev。然而,如果计划还原到一个已安装的 Linux 系统,那么备份 /dev 是没有必要的。

更多关于目录的解释,请查看 Filesystem Hierarchy Standard 和 Red Hat Linux Overview of File System Hierarchy Standard (FHS)

MySQL:


/usr/local/mysql
同时要注意版本的保留,在恢复的时候使用相同的版本(或者相同系列的版本)会减少更多不必要的麻烦,例如 “/usr
/local/mysql-standard-4.1.7-pc-linux-i686”。

/etc/my.cnf
MySQL 的配置文件。

Apache:


/usr/local/apache2/logs
Apache 的 log 文件。这里建议使用 cronolog 来 rotate Apache 的巨大 log。可以参考我的 cronolog 杂记

/usr/local/apache2/conf
Apache 的配置文件,例如: httpd.conf。还是建议在修改此文本的时候使用“#”号 comment 修改的内容,然后添加需要修改的内容。

PHP:


/usr/local/lib/php.ini
个人觉得这个就够了。如果你设定了 php 的 error log 文件,当然那个也是需要的。

Movable Type:


./MT-3.0D-full-en_ususr/ 和你的 weblog 目录
一般来说 blog 不会太大,不介意的话就整个备份一下。当然最重要的是 ./MT-3.0D-full-en_ususr/db/ 文件夹,里面有所有的数据(如果你没有用 MySQL 作为 MT 的数据存储格式的话)。

Awstats:

/etc/awstats/
Awstats 的配置文件。诸如:awstats.blog.conf

/var/lib/awstats/
Awstats 的分析留档文件。 诸如:awstats082004.blog.txt

MRTG:


MRTG 的输出文件夹。内有图片和诸如 12.34.56.78_12.34.56.78.log 的log文件。

三、使用 tar 和 crontab 等简单工具备份。

以下是使用 tar 的脚本,去掉了多余的说明部分。 您也可以点击这里下载并修改以适合自己的系统。在脚本中我尽量用更多的方法来进行备份。在实际应用中可以将步骤更加简化。更多关于 tar 的参数请看 man tar

#!/bin/sh

# Date format: 20040626
DATE=`date -d yesterday +%Y%m%d`

# MySQL version & directory
MYSQL_VERSION=”4.x.x”
MYSQL_DIR=”/usr/local/mysql/data”

# MT Blog directory
MTBLOG_DIR=”/path-to-mt/db/”

# Backup directory & Backup Filelist
BACKUP_DIR=”/path-to-backup/backupfile”
BACKUP_FILELIST=”/path-to-backup/filelist”

# Backup MySQL
printf “Backup MySQL data directory, please wait…\n”
tar -zpcvPf $BACKUP_DIR/mysql-standard-$MYSQL_VERSION-data-$DATE.tgz $MYSQL_DIR | grep “tar:”
printf “Done! The new backup file is: $BACKUP_DIR/mysql-standard-$MYSQL_VERSION-data-$DATE.tgz\n\n”

# Backup MT Blog
printf “Backuping the MT3.0 Weblog data directory, please wait…\n”
tar -zpcvPf $BACKUP_DIR/MT-db-$DATE.tgz $MTBLOG_DIR | grep “tar:”
printf “Done! The new backup file is: $BACKUP_DIR/MT-db-$DATE.tgz\n”

这里引用了『Linux 备份与恢复速成指南』中的一个小技巧,将文件列表写入一个文件进行操作。查看我的Filelist。

以下是一个文件列表的例子:

/etc
/var
/home
/usr/local
/opt (有时会是空目录)
以下解释引自『Linux 备份与恢复速成指南』:

请注意 tar -T(或 files-from)命令不能接受通配符。文件必须明确地列出。上面的例子展示了一种单独地引用文件的方法。您还可以执行脚本来搜索系统,然后建立一个列表。下面就是这样一个脚本的例子:

#!/bin/sh
cat MyFiles > TempList
find /usr/share -iname *.png >> TempList
find /tmp -iname *.iso >> TempList
tar -cpzMf /path-to-backup/backupfile -T TempList
上面的脚本首先将 MyFiles 中的所有现有文件列表复制到 TempList。然后它执行两个 find 命令来搜索文件系统中匹配某个模式的文件,并将它们附加到 TempList。第一次是搜索 /usr/share 目录树中以 .png 结尾的所有文件。第二次是搜索 /tmp 目录树中以 .iso 结尾的所有文件。在建立好列表之后,tar 然后在文件设备 /dev/st0 (第一个 SCSI 磁带设备)上创建 一个新的归档文件,该文件使用 gzip 格式来压缩,并保留所有文件权限。该归档文件将跨越多个卷。要归档的文件的名称将从 TempList 文件中提取。

四、适用于 log 和数据库的增量备份(incremental backup)。

对于庞大的 log 或者 数据库文件,每天进行完全备份似乎不是很能合理高效地实现备份工作。所以在较短的时间周期内,适用增量备份(incremental backup)会是一个不错的选择。

tar 并不是最好的增量备份工具

tar 并不是最好的增量备份的工具,但是它也可以实现增量备份。参照 『The tar backup program』中的脚本可以实现这个操作。

简单地介绍一下其原理:
首先,制作一个完全备份的时间点文件,例如 “full-date”。其中写入某次完全备份的时间点,例如 echo $NOW > full-date。
然后在自定的时间循环期内(例如一周),每次和完全备份时间点(full-date)对比后进行增量备份。
其中最关键的一个语句就是:

tar –newer $full-date -zcpf $BACKUPDIR/$BACKUPFILE-$NOW.tgz $DIRECTOIES
其结果就是,在一周中会产生 6 个独立文件,其内容是前一天内新增的内容。以下是一个例子:
[root@deep] /# ls -l /backups/

total 22217
-rw-r–r– 1 root root 10731288 Feb 7 11:24 deep-01Feb.tar << 每月月初一次完全备份
-rw-r–r– 1 root root 6879 Feb 7 11:24 deep-Fri.tar << 每天的增量备份
-rw-r–r– 1 root root 2831 Feb 7 11:24 deep-Mon.tar
-rw-r–r– 1 root root 7924 Feb 7 11:25 deep-Sat.tar
-rw-r–r– 1 root root 11923013 Feb 7 11:24 deep-Sun.tar << 每周一次完全备份
-rw-r–r– 1 root root 5643 Feb 7 11:25 deep-Thu.tar
-rw-r–r– 1 root root 3152 Feb 7 11:25 deep-Tue.tar
-rw-r–r-
- 1 root root 4567 Feb 7 11:25 deep-Wed.tar
drwxr-xr-x 2 root root 1024 Feb 7 11:20 last-full


tar 中几个开关的简介:


The c option specifies that an archive file is begin created.

The p option preserves permissions; file protection information will be remembered.

The N or newer option does an incremental backup and only stores files newer than DATE.

The f option states that the very next argument will be the name of the archive file or device being written.

The z option specifies that an gzip file will be created.

The u option can APPEND more files to a tarball file.
注意:-u 开关并不是增量备份,而是往原有的 tar 包里面添加新的文件。

fbackup is a better choice

在 HP 的论坛上,有关于增量备份的讨论--“Incremental “tar” Backup in HP-Ux”。但是因为我不是 HP 的系统,tar 已经可以满足现有的备份需求。

五、使用 ssh 实现安全网络远程备份。

[很抱歉,此段笔者没有试验环境,现在之能添加几篇关于 ssh 远程传送的文章。等到经过试验后,我会添加具体内容。]


33.8. Backing up and restoring over the network

轻松进行自主的、安全的、分布式网络备份

六、个人使用的 e-mail 简单备份。

由于 Yahoo!、Google、Hotmail 相继推出了 1-2G 的邮箱,因此可是试着使用带有文件附件的 E-mail 来传输小于各个邮箱的单封信件上限大小的文件。 具体需要用到一些诸如 uudecode 的命令,所以需要先安装一个 Sharutils 。 我在编译中遇到一些简单的错误,这里是我修改过的 Sharutils。

在命令行下发送带附件的邮件时,还是建议使用诸如 MUTT 的 MUA,请查看我的 MUTT 的安装失败经历,也许对新装的用户有所帮助。

安装完毕后,可以使用 Mutt 的命令行一行解决问题。首先先写一个邮件文本 mailcontent.txt。

# cat mailcontent.txt | mutt -s “mailtitle” -a attachfile1 mail@address

结合上面的 shell 脚本,如果你有企业级邮箱的话,不妨也试试这种方法。仅供参考。

PHP程序加速探索之压缩输出gzip

0

分类 : 技术文摘 | 发表时间 20-02-2006

利用Apache中的mod_gzip模块,我们可以利用gzip的压缩算法来对Apache服务器发布的网页内容进行压缩后再传输到客户端的浏览器。如果是纯文本的内容,效果非常明显,大约可以压缩到原来的30%-40%,使用户的浏览速度大大加快。

  Gzip需要客户端浏览器支持,目前大部份浏览器都支持gzip,如IE,Netscape,Mozilla等,所以这种方法值得一试。我们可以利用PHP中的预定义变量$_SERVER[‘HTTP_ACCEPT_ENCODING’]来判断客户端浏览器是否支持gzip。

  gzip1.php

if(ereg(‘gzip’,$_SERVER['HTTP_ACCEPT_ENCODING'])) {
 //浏览器支持
} else {
 //浏览器不支持,输出其它内容
}
?>

  接下来我们对上面这个PHP程序进行扩展,使用ob_start(ob_gzhandler)来将网页内容压缩,存入缓冲并发送给支持gzip的浏览器,浏览器会自动将压缩后的内容解压,显示。

  gzip2.php

define(‘MAX’,100);

if(ereg(‘gzip’,$_SERVER['HTTP_ACCEPT_ENCODING']))
{
 //浏览器支持gzip,将内容压缩并缓冲输出
 ob_start(“ob_gzhandler”);
 $output = ”;

 for($i=0;$i<=MAX;$i++)
 {
  $output .= “This is line $i “;
 }
 echo “浏览器支持gzip压缩输出”;
 echo $output;
}
else
{
 //浏览器不支持,直接输出
 for($i=0;$i<=MAX;$i++)
 {
  $output .= “This is line $i “;
 }

 echo “浏览器不支持gzip压缩输出 “;
 echo $output;
}
?>

  使用gzip压缩生成的网页的HTTP头信息与一般的网页相比中会多出这样的信息:

Content-Encoding: gzip
Content-Length: 270

  如果你想得到更详细的信息,请参看mod_gzip项目主页:

  http://sourceforge.net/projects/mod-gzip/

  类似地,我们也可以利用mod_deflate,压缩率比mod_gzip略低一些。调用zip函数需要耗用服务器内存,所以要慎用,视需求而定。

PHP 4.1.0 – php.ini 全文翻译

0

分类 : 技术文摘 | 发表时间 06-12-2005

;;;;;;;;;;;;;;;;;;;
; About this file ;
;
; 关于这个文件
;
;;;;;;;;;;;;;;;;;;;
;
; This is the recommended, PHP 4-style version of the php.ini-dist file. It
; sets some non standard settings, that make PHP more efficient, more secure,
; and encourage cleaner coding.
;
;
; 这个是推荐的,PHP 4 版本类型的 php.ini-dist 文件,他设置了一些非标准的设置,他们使得
; PHP更加有效,更加安全,鼓励整洁的编码。
;
;
; The price is that with these settings, PHP may be incompatible with some
; applications, and sometimes, more difficult to develop with. Using this
; file is warmly recommended for production sites. As all of the changes from
; the standard settings are thoroughly documented, you can go over each one,
; and decide whether you want to use it or not.
;
;
; 这样做的代价是,某些应用程序可能在这样的配置下不兼容,在某些情况下,开发会更加困难。
; 使用这个文件是我门对建设站点的热心建议。每个标准设置的改变都有彻底的说明稳当,你可以
; 处理没一个,决定是否使用他们。
;
;
; For general information about the php.ini file, please consult the php.ini-dist
; file, included in your PHP distribution.
;
;
; 关于 php.ini 的一般信息,请参考 php.ini-dist 文件,包括你的 PHP 的说明
;
;
; This file is different from the php.ini-dist file in the fact that it features
; different values for several directives, in order to improve performance, while
; possibly breaking compatibility with the standard out-of-the-box behavior of
; PHP 3. Please make sure you read what’s different, and modify your scripts
; accordingly, if you decide to use this file instead.
;
;
; 这个文件和 php.ini-dist 的区别在于它给予了一些指示不同的值,来提高性能,同时可能破坏了
; PHP 3 的标准的 out-of-the-box 特性。
;
;
; – register_globals = Off [Security, Performance]
; Global variables are no longer registered for input data (POST, GET, cookies,
; environment and other server variables). Instead of using $foo, you must use
; you can use $_REQUEST["foo"] (includes any variable that arrives through the
; request, namely, POST, GET and cookie variables), or use one of the specific
; $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending
; on where the input originates. Also, you can look at the
; import_request_variables() function.
; Note that register_globals is going to be depracated (i.e., turned off by
; default) in the next version of PHP, because it often leads to security bugs.
; Read http://php.net/manual/en/security.registerglobals.php for further
; information.
;
;
; 全局变量不再注册输入的数据(POST,GET,cookies,环境变量和其他的服务器变量)。作为代替的是使用
; $foo, 你必须使用 $_REQUEST["foo"] ( 包括所有的通过请求传来的变量,也就是说,POST,GET,和
; cookies 变量)或者根据输入的来源使用指定的 $_GET["foo"],$_POST["foo"],$_COOKIE["foo"]
; ,$_FILES["foo"] (访问他们).同时,你可以查看 import_request_variables()函数。
;
; 注意,这个参数可能在下个版本去掉(默认为off),因为他经常引起安全 bugs.到
; http://php.net/manual/en/security.registerglobals.php
; 查看详细内容
;
;
; – display_errors = Off [Security]
; With this directive set to off, errors that occur during the execution of
; scripts will no longer be displayed as a part of the script output, and thus,
; will no longer be exposed to remote users. With some errors, the error message
; content may expose information about your script, web server, or database
; server that may be exploitable for hacking. Production sites should have this
; directive set to off.
;
;
; 设置这个指示为Off,在脚本执行期间发生错误时,不再将错误作为输出的一部分显示,这样就不会暴露给
; 远端用户。对于某些错误,错误信息的内容可能暴露你的脚本,web服务器,数据库服务器的信息,可能被
; 黑客利用。最终产品占点需要设置这个指示为off.
;
;
; – log_errors = On [Security]
; This directive complements the above one. Any errors that occur during the
; execution of your script will be logged (typically, to your server’s error log,
; but can be configured in several ways). Along with setting display_errors to off,
; this setup gives you the ability to fully understand what may have gone wrong,
; without exposing any sensitive information to remote users.
;
;
; 这个指示补充上面的。所有的发生在脚本运行期间的错误都会纪录在日志中(代表性的,记录在服务器的错误
; 日志中,但是可以配置不同的方式)。随着 display_errors 设置为 off,这个设置给你全面了解到底什么
; 发生错误的能力,而不会向远端用户暴露任何信息。
;
;
; – output_buffering = 4096 [Performance]
; Set a 4KB output buffer. Enabling output buffering typically results in less
; writes, and sometimes less packets sent on the wire, which can often lead to
; better performance. The gain this directive actually yields greatly depends
; on which Web server you’re working with, and what kind of scripts you’re using.
;
;
; 设置 4KB 的输出缓冲区。打开输出缓冲可以减少写的次数,有时减少线路发送包的数量,这样能提高性能。
; 这个指示真正得到的益处很大程度的依赖于你的工作的 WEB 服务器,以及你使用的脚本。
;
;
; – register_argc_argv = Off [Performance]
; Disables registration of the somewhat redundant $argv and $argc global
; variables.
;
;
; 禁止注册某些多于的 $argv 和 $argc 全局变量
;
;
; – magic_quotes_gpc = Off [Performance]
; Input data is no longer escaped with slashes so that it can be sent into
; SQL databases without further manipulation. Instead, you should use the
; function addslashes() on each input element you wish to send to a database.
;
;
; 输入数据不再被斜线转义,以便于无需更多的处理就可以发送到SQL数据库里面。作为代替,你可
; 以对每个要发送到数据库的输入元素使用 addslashes()函数。
;
;
; – variables_order = “GPCS” [Performance]
; The environment variables are not hashed into the $HTTP_ENV_VARS[]. To access
; environment variables, you can use getenv() instead.
;
; 环境变量不再进入 $HTTP_ENV_VARS[],你需要用 getenv()来访问环境变量。
;
;
; – error_reporting = E_ALL [Code Cleanliness, Security(?)]
; By default, PHP surpresses errors of type E_NOTICE. These error messages
; are emitted for non-critical errors, but that could be a symptom of a bigger
; problem. Most notably, this will cause error messages about the use
; of uninitialized variables to be displayed.
;
;
; 默认的,PHP 给出 E_NOTICE 错误类型,这些错误信息不是核心错误,但是可能是个更大错误的隐患。
; 大多数提醒是那些没有初始化变量引起的错误信息。
;
;
; – allow_call_time_pass_reference = Off [Code cleanliness]
; It’s not possible to decide to force a variable to be passed by reference
; when calling a function. The PHP 4 style to do this is by making the
; function require the relevant argument by reference.
;
;
; 在调用函数时,不可能决定强制传递变量的引用。PHP 4 里通过函数请求相关参数的引用来实现
;
>;

;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;
;
; 语言配置
;
;
;;;;;;;;;;;;;;;;;;;;

; Enable the PHP scripting language engine under Apache.
;
;
; 允许在Apache下的PHP脚本语言引擎
;
;
engine = On

; Allow the tags are recognized.
;
;
; 允许 标记
;
;
short_open_tag = On

; Allow ASP-style tags.
;
;
; 允许 ASP 类型的 标记
;
;
asp_tags = Off

; The number of significant digits displayed in floating point numbers.
;
;
; 浮点数显示的有意义的数字(精度)
;
;
precision = 14

; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
;
;
; 强制遵从 2000 年(会在不遵从的浏览器上引起错误)
;
;
y2k_compliance = Off

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP’s output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size – you can use a maximum number of bytes instead of ‘On’, as
; a value for this directive (e.g., output_buffering=4096).
;
;
; 输出缓冲允许你在主体内容发送后发送头信息行(包括 cookies),作为代价,会稍微减慢一点PHP
; 输出层的速度。你可以在运行期间通过调用输出缓冲函数来打开输出缓冲。你也可以通过设置这个
; 指示来对虽有的文件打开输出缓冲。如果你想限制缓冲区大小为某个尺寸,你可以使用一个允许最大
; 的字节数值代替 “On”,作为这个指示的值。
;
;
output_buffering = 4096

; You can redirect all of the output of your scripts to a function. For
; example, if you set output_handler to “ob_gzhandler”, output will be
; transparently compressed for browsers that support gzip or deflate encoding.
; Setting an output handler automatically turns on output buffering.
;
;
; 你可以重新定向脚本所有输出到一个函数。例如,你可以设置 output_handler 为 “ob_gzhandler”,
; 输出将会被明显的被压缩到支持 gzip 或 deflate 编码的浏览器。设置一个输出管理会自动打开
; 输出缓冲
;
;
output_handler =

; Transparent output compression using the zlib library
; Valid values for this option are ‘off’, ‘on’, or a specific buffer size
; to be used for compression (default is 4KB)
;
;
; 使用 zlib 库进行输出压缩,可以指定 off/on 或者用于压缩的缓冲大小
;
;
zlib.output_compression = Off

; Implicit flush tells PHP to tell the output layer to flush itself
; automatically after every output block. This is equivalent to calling the
; PHP function flush() after each and every call to print() or echo() and each
; and every HTML block. Turning this option on has serious performance
; implications and is generally recommended for debugging purposes only.
;
;
; 隐含的通知PHP的输出层在每个输出块后自己自动刷新。等同于在每个 print() 或者 echo()
; 和每个HTML块后面都调用 flush()函数。打开这个配置会引起严重的隐含执行,一般推荐在用于
; 调试目的时使用。
;
;
implicit_flush = Off

; Whether to enable the ability to force arguments to be passed by reference
; at function call time. This method is deprecated and is likely to be
; unsupported in future versions of PHP/Zend. The encouraged method of
; specifying which arguments should be passed by reference is in the function
; declaration. You’re encouraged to try and turn this option Off and make
; sure your scripts work properly with it in order to ensure they will work
; with future versions of the language (you will receive a warning each time
; you use this feature, and the argument will be passed by value instead of by
; reference).
;
;
; 是否允许在函数调用期间有强制参数以引用的形式传递的能力。这个方法不赞成使用,在将来的
; PHP和Zend版本里面可能不支持。鼓励的方法是在函数声明时指定哪个参数通过引用传递。鼓励你
; 尝试关闭这个参数,确认你的脚本能够正常运行,以便在以后版能里面正确运行(你会在每次使用
; 这个特性时得到一个警告,并且参数以值来传递,代替引用)
;
;
allow_call_time_pass_reference = Off

;
; Safe Mode
;
;
; 安全模式
;
;
;
safe_mode = Off

; By default, Safe Mode does a UID compare check when
; opening files. If you want to relax this to a GID compare,
; then turn on safe_mode_gid.
;
;
; 安全模式默认的在打开文件时进行 UID 比较检查,如果你想放宽他为GID比较,打开这个参数
;
;
safe_mode_gid = Off

; When safe_mode is on, UID/GID checks are bypassed when
; including files from this directory and its subdirectories.
; (directory must also be in include_path or full path must
; be used when including)
;
;
; 在安全模式,当包含如下目录和子目录文件时,绕过 UID/GID检查(路径必须在 include_path下面
; 或者在包含时使用完整路径
;
;
safe_mode_include_dir =

; When safe_mode is on, only executables located in the safe_mode_exec_dir
; will be allowed to be executed via the exec family of functions.
;
;
; 在安全模式下,只有给出目录下可以通过 exec 族函数执行
;
;
safe_mode_exec_dir =

; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.
;
;
; 如果设置,则限制所有的文件操作都到下面给出的目录下。这个指示在每个目录,每个虚拟主机的web
; 服务器配置文件里给出更多的认识。
;
;
;open_basedir =

; Setting certain environment variables may be a potential security breach.
; This directive contains a comma-delimited list of prefixes. In Safe Mode,
; the user may only alter environment variables whose names begin with the
; prefixes supplied here. By default, users will only be able to set
; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR).
;
; Note: If this directive is empty, PHP will let the user modify ANY
; environment variable!
;
;
; 设置某些环境变量可能是隐藏的安全缺口。这个指示包含一个逗号分割的前缀指示。在安全模式下
; 用户只能修改下面提供的为前缀的变量名字。默认,用户只能设置以 PHP_ 前缀开头的环境变量(
; 例如 PHP_FOO=BAR).
;
; 注意:如果这个设置为空,则 PHP 可以让用户修改任何环境变量。
;
;
safe_mode_allowed_env_vars = PHP_

; This directive contains a comma-delimited list of environment variables that
; the end user won’t be able to change using putenv(). These variables will be
; protected even if safe_mode_allowed_env_vars is set to allow to change them.
;
;
; 这个指示包含用逗号分割的不允许最终用户通过 putenv()修改的环境变量的列表。这些变量即使
; 在 safe_mode_allowed_env_vars 设置允许改变他们的情况下也被保护。
;
;
safe_mode_protected_env_vars = LD_LIBRARY_PATH

; This
directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
;
;
; 这个指示用于在由于安全原因的情况下屏蔽某些函数。接受用逗号分割的函数名列表,这个指示不受
; Safe Mode 是否打开的影响。
;
;
disable_functions =

; Colors for Syntax Highlighting mode. Anything that’s acceptable in
; would work.
;
;
; 语法加亮模式的颜色,任何 正常工作的都可以接受
;
;
highlight.string = #CC0000
highlight.comment = #FF9900
highlight.keyword = #006600
highlight.bg = #FFFFFF
highlight.default = #0000CC
highlight.html = #000000

;
; Misc
;
; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header). It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
;
;
; 是否让服务器暴露 PHP(例如在 web 服务器头增加标记)。他不会有安全威胁,但是可以让你
; 检测一个服务器是否使用了 PHP.
;
;
expose_php = On

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;
;
; 资源限制
;
;

;;;;;;;;;;;;;;;;;;;

;
;
; 每个脚本最大执行的秒数
;
;
max_execution_time = 30 ; Maximum execution time of each script, in seconds

;
;
; 一个脚本最大消耗的内存
;
;
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;
;
; 错误处理和记录
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; error_reporting is a bit-field. Or each number up to get desired error
; reporting level
;
;
; 错误报告是一个位字段,每个数值代表错误报告的等级
;
;
; E_ALL – All errors and warnings
;
; 所有的错误和警告
;
; E_ERROR – fatal run-time errors
;
; 致命的运行期错误
;
; E_WARNING – run-time warnings (non-fatal errors)
;
; 运行期警告(非致命错误)
;
; E_PARSE – compile-time parse errors
;
; 编译期间解析错误
;
; E_NOTICE – run-time notices (these are warnings which often result
; from a bug in your code, but it’s possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it’s automatically initialized to an
; empty string)
;
; 运行期间注意,一般是由于代码的 bug 引起的警告,但是很可能是故意这样的。例如使用没有初始化
; 的变量,依赖于他自动初始化为空的字符串。
;
; E_CORE_ERROR – fatal errors that occur during PHP’s initial startup
;
; 发生在 PHP 的初始启动阶段的致命错误
;
; E_CORE_WARNING – warnings (non-fatal errors) that occur during PHP’s
; initial startup
;
; 发生在 PHP 的初始启动阶段的警告(非致命错误)
;
; E_COMPILE_ERROR – fatal compile-time errors
;
; 致命的编译期间错误
;
; E_COMPILE_WARNING – compile-time warnings (non-fatal errors)
;
; 编译期间的警告(非致命的错误)
;
; E_USER_ERROR – user-generated error message
;
; 用户引起的错误信息
;
; E_USER_WARNING – user-generated warning message
;
; 用户引起的警告信息
;
; E_USER_NOTICE – user-generated notice message
;
; 用户引起的提醒信息
;
;
; Examples:
;
; – Show all errors, except for notices
;
; 显示所有错误,除了提醒
;
;error_reporting = E_ALL & ~E_NOTICE
;
; – Show only errors
;
; 只显示错误
;
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
;
; – Show all errors except for notices
;
; 显示所有的错误(译者注:英文可能有错误)
;
error_reporting = E_ALL

; Print out errors (as a part of the output). For production web sites,
; you’re strongly encouraged to turn this feature off, and use error logging
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
;
;
; 输出错误(作为输出的一部分)。对于成品网站,强烈建议关闭这个特性,使用下面错误日志代替。
; 在成品网站打开这个特性可能对最终用户暴露安全信息。例如 WEB 服务器的文件路径,数据库计划
; 或其他信息。
;
;
display_errors = Off

; Even when display_errors is on, errors that occur during PHP’s startup
; sequence are not displayed. It’s strongly recommended to keep
; display_startup_errors off, except for when debugging.
;
;
; 即使 display_errors 参数设置位 on,发生在 PHP 的启动顺序期间的错误也不会显示。
; 强烈建议保持 display_startup_errors 为 off,除非在调试阶段。
;
;
display_startup_errors = Off

; Log errors into a log file (server-specific log, stderr, or error_log (below))
; As stated above, you’re strongly advised to use error logging in place of
; error displaying on production web sites.
;
;
; 把错误写到一个日志文件里面(服务器指定日志,标准错误,或者后面的错误日志)。
; 根据上面的一致性,强烈建议使用错误日志代替web站点的错误显示。
;
;
log_errors = On

; Store the last error/warning message in $php_errormsg (boolean).
;
;
; 保存最后的错误/警告信息在 $php_errormsg(boolean)里面。
;
;
track_errors = Off

; Disable the inclusion of HTML tags in error messages.
;
;
; 屏蔽掉错误信息里面内含的HTML标记
;
;
;html_errors = Off

; String to output before an error message.
;
;
; 错误信息前输出的字符串
;
;
;error_prepend_string = “”

; String to output after an error message.
;
;
; 错误信息后输出的字符串。
;
;
;error_append_string = “”

; Log errors to specified file.
;
;
; 错误写进指定的文件
;
;
;error_log = filename

; Log errors to syslog (Event Log on NT, not valid in Windows 95).
;error_log = syslog

; Warn if the + operator is used with strings.
;
;
; 在对字符串用 + 操作符时给出警告
;
;
warn_plus_overloading = Off

;;;;;;;;;;;;;;;;;
; Data Handling ;
;
;
; 数据处理
;
;
;;;;;;;;;;;;;;;;;
;
; Note – track_vars is ALWAYS enabled as of PHP 4.0.3
;
; 注意,在 PHP 4.0.3 里面, track_vars 总是打开的。
;

; The separator used in PHP generated URLs to separate arguments.
; Default is “&”.
;
;
; PHP在产生URLs时用于分割参数的分割符。默认是 “&”
;
;
;arg_separator.output = “&”

; List of separator(s) used by PHP to parse input URLs into variables.
; Default is “&”.
; NOTE: Every character in this directive is considered as separator!
;
;
; PHP用于把输入的 URLs 解析为变量的分割符列表,默认是 “&”;
; 注意:这个指示的每个字符都被认为是分割符
;
;
;arg_separator.input = “;&”

; This directive describes the or
der in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
; referred to as EGPCS or GPC). Registration is done from left to right, newer
; values override older values.
;
;
; 这个指示描述PHP注册 GET,POST,Cookes,环境变量和内部变量的顺序(分别对应于 G,P,C,E 和 S,
; 经常为 EGPCS 或者 GPC).注册从左到右,新的值覆盖旧的值。
;
;
variables_order = “GPCS”

; Whether or not to register the EGPCS variables as global variables. You may
; want to turn this off if you don’t want to clutter your scripts’ global scope
; with user data. This makes most sense when coupled with track_vars – in which
; case you can access all of the GPC variables through the $HTTP_*_VARS[],
; variables.
;
;
; 是否注册 EGPCS 变量为全局变量。如果你不想和用户数据混淆脚本全局范围,你可能想关闭他。
; 结合 track_vars 可以更加理性。它可以让你通过 $HTTP_*_VARS[] 访问所有的GPC变量。
;
;
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
;
;
; 你可以尽力书写不需要 register_globals 打开时的脚本。如果代码没有非常好的考虑是
; 使用来源于全局变量的表单数据很容易引起安全问题。
;
;
register_globals = Off

; This directive tells PHP whether to declare the argv&argc variables (that
; would contain the GET information). If you don’t use these variables, you
; should turn it off for increased performance.
;
;
; 这个指示通知 PHP 是否声明 argv 和 argc 变量(他们可能包含 GET 信息)。
; 如果你不使用他们,你应该关闭他来提高性能。
;
;
register_argc_argv = Off

; Maximum size of POST data that PHP will accept.
;
;
; PHP接受的最大的 POST 数据尺寸
;
;
post_max_size = 8M

; This directive is deprecated. Use variables_order instead.
;
;
; 这个指示不赞成使用,使用 variables_order 代替
;
;
gpc_order = “GPC”

; Magic quotes
;

; Magic quotes for incoming GET/POST/Cookie data.
;
;
; 转换进入的 GET/POST/Cookie 数据
;
;
magic_quotes_gpc = Off

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
;
;
; 转换运行期间产生的数据,例如来自于 SQL, exec()等等
;
;
magic_quotes_runtime = Off

; Use Sybase-style magic quotes (escape ‘ with ” instead of \’).
;
;
; 使用 Sybase 样式的转换(对于 ‘ 使用 ” 代替 \’)
;
;
magic_quotes_sybase = Off

; Automatically add files before or after any PHP document.
;
;
; 在PHP文档前后自动加入的文件名字。
;
;
auto_prepend_file =
auto_append_file =

; As of 4.0b4, PHP always outputs a character encoding by default in
; the Content-type: header. To disable sending of the charset, simply
; set it to be empty.
;
; PHP’s built-in default is text/html
;
;
; 在 4.0b4, PHP 总是在 Content-type:头里面发送默认的字符编码。要禁止发送字符设置
; 简单的把他设置为空就可以。
; PHP 内置的默认值是 text/html
;
;
default_mimetype = “text/html”
;default_charset = “iso-8859-1″

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;
;
; 路径和目录
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: “/path1:/path2″
;
;
; UNIX: 使用 /path1:path2 样式
;
;
;include_path = “.:/php/includes”
;
; Windows: “\path1;\path2″
;
; Window: 使用 \path1;\path2 样式
;
;include_path = “.;c:\php\includes”

; The root of the PHP pages, used only if nonempty.
;
;
; PHP 页面的根位置,仅在非空时使用
;
;
doc_root =

; The directory under which PHP opens the script using /~usernamem used only
; if nonempty.
;
;
; 使用 /~username 打开 PHP 脚本时的目录,非空时使用。
;
;
user_dir =

; Directory in which the loadable extensions (modules) reside.
;
;
; 本地可装载的扩展(模块)所在的目录
;
;
extension_dir = c:\php\extensions

; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
;
;
; 是否允许 dl()函数。dl()在多线程服务器上不能正确的工作,例如 IIS 或者 Zeus,此时自动屏蔽
;
;
enable_dl = On

;;;;;;;;;;;;;;;;
; File Uploads ;
;
;
; 文件上传
;
;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
;
;
; 是否允许文件上传
;
;
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;
;
; HTTP 上传时文件的临时目录(如果没有指定就使用系统默认的)
;
;
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
;
;
; 最大允许上传文件尺寸
;
;
upload_max_filesize = 2M

;;;;;;;;;;;;;;;;;;
; Fopen wrappers ;
;
;
; 文件打开封装
;
;
;;;;;;;;;;;;;;;;;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
;
;
; 是否允许把 URLs(象 http:// 或者 ftp://)以文件对待
;
;
allow_url_fopen = On

; Define the anonymous ftp password (your email address)
;
;
; 默认的 ftp 密码(你的邮箱地址)
;
;
;from=”john@doe.com”

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;
;
; 动态扩展
;
;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; … or under UNIX:
;
; extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here. Specify the location of the extension with the
; extension_dir directive above.
;
;
; 如果你想自动装载某些扩展,使用下面的语法
;
; extension = modulename.extension
;
; 例如在 Windows 下面
;
; extension=msql.dll
;
; 在 UNIX 下面
;
; extension = msql.so
;
; 注意,必须是模块的名字,不能有其他指示。扩展的位置在 extension_dir 那里指定
;
;

;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;
;
; Windows 扩展
; 注意,MySQL 和 ODBC 已经内置了,不需要 dll 了。
;
;
;extension=php_bz2.dll
;extension=php_ctype.dll
;extension=php_cpdf.dll
;extension=php_curl.dll
;extension=php_cybercash.dll
;extension=php_db.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_domxml.dll
;extension=php_dotnet.dll
;extension=php_exif.dll
;extension=php_fbsql.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd.dll
;extension=php_gettext.dll
;extension=php_hyperwave.dll
;extension=php_iconv.dll
;extension=php_ifx
.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_ingres.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_ming.dll
;extension=php_mssql.dll ; 这个是 Microsoft SQL Server
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_printer.dll
;extension=php_sablot.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_xslt.dll
;extension=php_yaz.dll
;extension=php_zlib.dll

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;
;
; 模块设置
;
;
;;;;;;;;;;;;;;;;;;;

[Syslog]
;
; 系统日志
;
; Whether or not to define the various syslog variables (e.g. $LOG_PID,
; $LOG_CRON, etc.). Turning it off is a good idea performance-wise. In
; runtime, you can define these variables by calling define_syslog_variables().
;
;
; 是否定以不同的系统日志变量(例如,$LOG_PID,$LOG_CRON,等等)。为性能考虑,关闭比较好
; 在运行期间,你可以通过调用 define_syslog_variables() 定以这些变量
;
;
define_syslog_variables = Off

[mail function]
;
; 邮件函数
;
; For Win32 only.
;
;
; Win32 可用
;
;
SMTP = localhost

; For Win32 only.
;
;
; Win32 可用
;
;
sendmail_from = me@localhost.com

; For Unix only. You may supply arguments as well (default: ‘sendmail -t -i’).
;
;
; Unix 可用,可以指定参数。(默认是 sendmail -t -i )
;
;
;sendmail_path =

[Logging]
;
; 日志
;
; These configuration directives are used by the example logging mechanism.
; See examples/README.logging for more explanation.
;
;
; 这些配置指示例子中的日志机制,查看 examples/README.logging 的详细说明
;
;
;logging.method = db
;logging.directory = /path/to/log/directory

[Java]
;
; Java 支持
;
;
; 指向 php_java.jar 的位置
;
;java.class.path = .\php_java.jar

;
; 指向 java 安装的目录
;
;java.home = c:\jdk

;
; 指向虚拟机的目录
;
;java.library = c:\jdk\jre\bin\hotspot\jvm.dll

;
; 指向 java 扩展所在的目录,比如 c:\php\extensions
;
;java.library.path = .\

[SQL]
;
; SQL 设置
;
sql.safe_mode = Off

[ODBC]
;
; ODBC 设置
;

;
; 默认的数据库,尚未实现
;
;odbc.default_db = Not yet implemented

;
; 默认的用户,尚未实现
;
;odbc.default_user = Not yet implemented

;
; 默认的密码,尚未实现
;
;odbc.default_pw = Not yet implemented

; Allow or prevent persistent links.
;
; 允许或者防止持久连接
;
odbc.allow_persistent = On

; Check that a connection is still valid before reuse.
;
; 在连接重新使用前检查是否依然合法
;
odbc.check_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大的持久连接数量,-1 代表不限制
;
odbc.max_persistent = -1

; Maximum number of links (persistent + non-persistent). -1 means no limit.
;
; 最大的连接数(持久 + 非持久),-1 代表不限制
;
odbc.max_links = -1

; Handling of LONG fields. Returns number of bytes to variables. 0 means
; passthru.
;
; 处理超长的字段,返回可用的字节数量,0 代表 放弃(passthru)
;
odbc.defaultlrl = 4096

; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char.
; See the documentation on odbc_binmode and odbc_longreadlen for an explanation
; of uodbc.defaultlrl and uodbc.defaultbinmode
;
; 处理二进制数据。0 代表放弃(passthru),1 返回原始的,2 转化为字符。
;
odbc.defaultbinmode = 1

[MySQL]
;
;
; MySQL 配置
;
;
; Allow or prevent persistent links.
;
; 是否允许持久连接
;
mysql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大的持久连接数量,-1 无限
;
mysql.max_persistent = -1

; Maximum number of links (persistent + non-persistent). -1 means no limit.
;
; 最大的连接数量(持久+非持久), -1 无限
;
mysql.max_links = -1

; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look at MYSQL_PORT.
;
; mysql_connect()默认的端口号。如果没有设置,则使用 $MYSQL_TCP_PORT 或者 在 /etc/services
; 里面的 mysql_tct 入口,或者运行期间给出的 MYSQL_PORT,Win32 只查看 MYSQL_PORT
;
mysql.default_port =

; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
;
; 默认的本地 MySQL 连接的 socket 名字,如果为空泽使用内置的
;
mysql.default_socket =

; Default host for mysql_connect() (doesn’t apply in safe mode).
;
; 默认的连接主机(在安全模式下不使用)
;
mysql.default_host =

; Default user for mysql_connect() (doesn’t apply in safe mode).
;
; 默认的用户名(在安全模式不使用)
;
mysql.default_user =

; Default password for mysql_connect() (doesn’t apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run ‘echo cfg_get_var(“mysql.default_password”)
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
;
; 默认的连接密码(在安全模式下不使用)
; 注意:在这里存储密码是一个非常不好的注意。任何可以访问 PHP 的用户可以通过
; echo cfg_get_var(“mysql.default_password”)来获得密码。当然,任何拥有这个文件读取
; 权限的用户同样可以得到密码。
;
mysql.default_password =

[mSQL]
; Allow or prevent persistent links.
;
; 是否允许持久连接
;
msql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大的持久连接数量,-1 无限
;
msql.max_persistent = -1

; Maximum number of links (persistent+non persistent). -1 means no limit.
;
; 最大的连接数量(持久+非持久), -1 无限
;
msql.max_links = -1

[PostgresSQL]
; Allow or prevent persistent links.
;
; 是否允许持久连接
;
pgsql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大的持久连接数量,-1 无限
;
pgsql.max_persistent = -1

; Maximum number of links (persistent+non persistent). -1 means no limit.
;
; 最大的连接数量(持久+非持久), -1 无限
;
pgsql.max_links = -1

[Sybase]
; Allow or prevent persistent links.
;
; 是否允许持久连接
;
sybase.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大的持久连接数量,-1 无限
;
sybase.max_persistent = -1

; Maximum number of
links (persistent + non-persistent). -1 means no limit.
;
; 最大的连接数量(持久+非持久), -1 无限
;
sybase.max_links = -1

;sybase.interface_file = “/usr/sybase/interfaces”

; Minimum error severity to display.
;
; 显示的最小错误
;
sybase.min_error_severity = 10

; Minimum message severity to display.
;
; 显示最小错误信息
;
sybase.min_message_severity = 10

; Compatability mode with old versions of PHP 3.0.
; If on, this will cause PHP to automatically assign types to results according
; to their Sybase type, instead of treating them all as strings. This
; compatability mode will probably not stay around forever, so try applying
; whatever necessary changes to your code, and turn it off.
;
; 兼容于旧的 PHP 3.0
; 如果为 on, 则PHP 根据他们的 Sybase 类型自动给结果赋予类型,而不是全部当成字符串。
; 这个兼容模式在将来不会保留,所以请修改你的代码,关闭这个参数
;
sybase.compatability_mode = Off

[Sybase-CT]
; Allow or prevent persistent links.
;
; 是否允许持久连接
;
sybct.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大的持久连接数量,-1 无限
;
sybct.max_persistent = -1

; Maximum number of links (persistent + non-persistent). -1 means no limit.
;
; 最大的连接数量(持久+非持久), -1 无限
;
sybct.max_links = -1

; Minimum server message severity to display.
;
; 最小的服务器严重信息显示
;
sybct.min_server_severity = 10

; Minimum client message severity to display.
;
; 最小的客户端严重信息显示
;
sybct.min_client_severity = 10

[bcmath]
;
;
;
; Number of decimal digits for all bcmath functions.
;
; bcmath 函数的十进制数字
;
bcmath.scale = 0

[browscap]
;
; 用于判断客户信息
;
;browscap = extra/browscap.ini

[Informix]
;
;
;
; Default host for ifx_connect() (doesn’t apply in safe mode).
;
; 默认的连接主机(安全模式下无效)
;
ifx.default_host =

; Default user for ifx_connect() (doesn’t apply in safe mode).
;
; 默认的连接用户(安全模式下无效)
;
ifx.default_user =

; Default password for ifx_connect() (doesn’t apply in safe mode).
;
; 默认的连接密码(安全模式下无效)
;
ifx.default_password =

; Allow or prevent persistent links.
;
; 是否允许持久连接
;
ifx.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大持久连接数量
;
ifx.max_persistent = -1

; Maximum number of links (persistent + non-persistent). -1 means no limit.
;
; 最大连接数量
;
ifx.max_links = -1

; If on, select statements return the contents of a text blob instead of its id.
;
; 如果为 on, 则选择语句返回 text blob 代替编号
;
ifx.textasvarchar = 0

; If on, select statements return the contents of a byte blob instead of its id.
;
; 如果为 on,则选择语句返回 byte blob 代替编号
;
ifx.byteasvarchar = 0

; Trailing blanks are stripped from fixed-length char columns. May help the
; life of Informix SE users.
ifx.charasvarchar = 0

; If on, the contents of text and byte blobs are dumped to a file instead of
; keeping them in memory.
ifx.blobinfile = 0

; NULL’s are returned as empty strings, unless this is set to 1. In that case,
; NULL’s are returned as string ‘NULL’.
ifx.nullformat = 0

[Session]
;
; Session 部分
;

; Handler used to store/retrieve data.
;
; 用于处理存储/取得数据
;
session.save_handler = files

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP’s session functions.
;
; 传递给 save_handleer 的参数,在 files 情况下,是数据存储的路径。
; 注意,Windows 用户需要修改这个变量来使用 PHP 的 session 功能
;
; 我给出的路径是我安装 PHP的路径,你可以改成任何你硬盘存在的路径
;
session.save_path = c:\php

; Whether to use cookies.
;
; 是否使用 cookies
;
session.use_cookies = 1

; Name of the session (used as cookie name).
;
; session 的名字(用于 cookes )
;
session.name = PHPSESSID

; Initialize session on request startup.
;
; 在请求开始时初始化 session
;
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
;
; cookie 的存活秒数,如果为 0 , 则是直到浏览器重新启动
;
session.cookie_lifetime = 0

; The path for which the cookie is valid.
;
; 正确的 cookie 路径
;
session.cookie_path = /

; The domain for which the cookie is valid.
;
; 存放数值的 cookie的主机(主键)
;
session.cookie_domain =

; Handler used to serialize data. php is the standard serializer of PHP.
;
; 序列化数据的句柄,标准句柄是 php
;
session.serialize_handler = php

; Percentual probability that the ‘garbage collection’ process is started
; on every session initialization.
;
; 打开每个session初始化时自动开始垃圾收集进程
;
session.gc_probability = 1

; After this number of seconds, stored data will be seen as ‘garbage’ and
; cleaned up by the garbage collection process.
;
; 当超过这个时间,存储的的数据会被认为是垃圾,被 gc 进程清除
;
session.gc_maxlifetime = 1440

; Check HTTP Referer to invalidate externally stored URLs containing ids.
;
; 检查包含 ids 的 HTTP 里无效的外部保存 URLs的内容
;
session.referer_check =

; How many bytes to read from the file.
;
; 从文件里读入的允许字节数
;
session.entropy_length = 0

; Specified here to create the session id.
;
; 指定在这里建立 session id
;
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public} to determine HTTP caching aspects.
;
; 确定 HTTP 缓存外貌 {nocache,private,public}
;
session.cache_limiter = nocache

; Document expires after n minutes.
;
; 超过 n 分钟文档到期
;
session.cache_expire = 180

; use transient sid support if enabled by compiling with –enable-trans-sid.
;
; 如果在编译时使用 –enable_trans-sid ,则使用短暂 sid 支持
;
session.use_trans_sid = 1

url_rewriter.tags = “a=href,area=href,frame=src,input=src,form=fakeentry”

[MSSQL]
;
; 这个就是 Microsoft Sql Server
;

; Allow or prevent persistent links.
;
; 是否允许持久连接
;
mssql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
;
; 最大持久连接数
;
mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent). -1 means no limit.
;
; 最大连接数
;
mssql.max_links = -1

; Minimum error severity to display.
;
; 显示的最小错误严重
;
mssql.min_error_severity = 10

; Minimum message severity to display.
;

; 最小的显示的严重信息
;
mssql.min_message_severity = 10

; Compatability mode with old versions of PHP 3.0.
;
; 兼容老的 PHP 3.0
;
mssql.compatability_mode = Off

; Valid range 0 – 2147483647. Default = 4096.
;
; 允许值 , 默认值
;
;mssql.textlimit = 4096

; Valid range 0 – 2147483647. Default = 4096.
;
; 允许值, 默认值
;
;mssql.textsize = 4096

; Limits the number of records in each batch. 0 = all records in one batch.
;
; 每个批次最大的纪录数, 0 = 所有纪录1个批次
;
;mssql.batchsize = 0

[Assertion]
; Assert(expr); active by default.
;assert.active = On

; Issue a PHP warning for each failed assertion.
;assert.warning = On

; Don’t bail out by default.
;assert.bail = Off

; User-function to be called if an assertion fails.
;assert.callback = 0

; Eval the expression with current error_reporting(). Set to true if you want
; error_reporting(0) around the eval().
;assert.quiet_eval = 0

[Ingres II]
; Allow or prevent persistent links.
ingres.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
ingres.max_persistent = -1

; Maximum number of links, including persistents. -1 means no limit.
ingres.max_links = -1

; Default database (format: [node_id::]dbname[/srv_class]).
ingres.default_database =

; Default user.
ingres.default_user =

; Default password.
ingres.default_password =

[Verisign Payflow Pro]
; Default Payflow Pro server.
pfpro.defaulthost = “test-payflow.verisign.com”

; Default port to connect to.
pfpro.defaultport = 443

; Default timeout in seconds.
pfpro.defaulttimeout = 30

; Default proxy IP address (if required).
;pfpro.proxyaddress =

; Default proxy port.
;pfpro.proxyport =

; Default proxy logon.
;pfpro.proxylogon =

; Default proxy password.
;pfpro.proxypassword =

[Sockets]
; Use the system read() function instead of the php_read() wrapper.
;
; 使用系统的 read() 函数代替 php_read() 封装
;
sockets.use_system_read = On

[com]
;
; COM 设置
;
; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
;
; 指向包含 GUIDs,IIDs 或者 拥有 TypeLibs 文件的文件名的文件路径
;
;com.typelib_file =

; allow Distributed-COM calls
;
; 允许分布式 COM 调用
;
;com.allow_dcom = true

; autoregister constants of a components typlib on com_load()
;
; 在 com_load()时自动注册 typlib 组件的常量
;
;com.autoregister_typelib = true

; register constants casesensitive
;
; 注册常量区分大小写
;
;com.autoregister_casesensitive = false

; show warnings on duplicate constat registrations
;
; 重复注册常量则给出警告
;
;com.autoregister_verbose = true

[Printer]
;printer.default_printer = “”

[mbstring]
;mbstring.internal_encoding = EUC-JP
;mbstring.http_input = auto
;mbstring.http_output = SJIS
;mbstring.detect_order = auto
;mbstring.substitute_character = none;

[FrontBase]
;fbsql.allow_persistant = On
;fbsql.autocommit = On
;fbsql.default_database =
;fbsql.default_database_password =
;fbsql.default_host =
;fbsql.default_password =
;fbsql.default_user = “_SYSTEM”
;fbsql.generate_warnings = Off
;fbsql.max_connections = 128
;fbsql.max_links = 128
;fbsql.max_persistent = -1
;fbsql.max_results = 128
;fbsql.mbatchSize = 1000

; Local Variables:
; tab-width: 4
; End:

下载这个文件 php.ini

[PHP]

;;;;;;;;;;;;;;;;;;;
; About this file ;
;
; 关于这个文件
;
;;;;;;;;;;;;;;;;;;;
;
; This is the recommended, PHP 4-style version of the php.ini-dist file. It
; sets some non standard settings, that make PHP more efficient, more secure,
; and encourage cleaner coding.
;
;
; 这个是推荐的,PHP 4 版本类型的 php.ini-dist 文件,他设置了一些非标准的设置,他们使得
; PHP更加有效,更加安全,鼓励整洁的编码。
;
;
; The price is that with these settings, PHP may be incompatible with some
; applications, and sometimes, more difficult to develop with. Using this
; file is warmly recommended for production sites. As all of the changes from
; the standard settings are thoroughly documented, you can go over each one,
; and decide whether you want to use it or not.
;
;
; 这样做的代价是,某些应用程序可能在这样的配置下不兼容,在某些情况下,开发会更加困难。
; 使用这个文件是我门对建设站点的热心建议。每个标准设置的改变都有彻底的说明稳当,你可以
; 处理没一个,决定是否使用他们。
;
;
; For general information about the php.ini file, please consult the php.ini-dist
; file, included in your PHP distribution.
;
;
; 关于 php.ini 的一般信息,请参考 php.ini-dist 文件,包括你的 PHP 的说明
;
;
; This file is different from the php.ini-dist file in the fact that it features
; different values for several directives, in order to improve performance, while
; possibly breaking compatibility with the standard out-of-the-box behavior of
; PHP 3. Please make sure you read what’s different, and modify your scripts
; accordingly, if you decide to use this file instead.
;
;
; 这个文件和 php.ini-dist 的区别在于它给予了一些指示不同的值,来提高性能,同时可能破坏了
; PHP 3 的标准的 out-of-the-box 特性。
;
;
; – register_globals = Off [Security, Performance]
; Global variables are no longer registered for input data (POST, GET, cookies,
; environment and other server variables). Instead of using $foo, you must use
; you can use $_REQUEST["foo"] (includes any variable that arrives through the
; request, namely, POST, GET and cookie variables), or use one of the specific
; $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending
; on where the input originates. Also, you can look at the
; import_request_variables() function.
; Note that register_globals is going to be depracated (i.e., turned off by
; default) in the next version of PHP, because it often leads to security bugs.
; Read http://php.net/manual/en/security.registerglobals.php for further
; information.
;
;
; 全局变量不再注册输入的数据(POST,GET,cookies,环境变量和其他的服务器变量)。作为代替的是使用
; $foo, 你必须使用 $_REQUEST["foo"] ( 包括所有的通过请求传来的变量,也就是说,POST,GET,和
; cookies 变量)或者根据输入的来源使用指定的 $_GET["foo"],$_POST["foo"],$_COOKIE["foo"]
; ,$_FILES["foo"] (访问他们).同时,你可以查看 import_request_variables()函数。
;
; 注意,这个参数可能在下个版本去掉(默认为off),因为他经常引起安全 bugs.到
; http://php.net/manual/en/security.registerglobals.php
; 查看详细内容
;
;
; – display_errors = Off [Security]
; With this directive set to off, errors that occur during the execution of
; scripts will no longer be displayed as a part of the script output, and thus,
; will no longer be exposed to remote users. With some errors, the error message
; content may expose information about your script, web server, or database
; server that may be exploitable for hacking. Production sites should h
ave this
; directive set to off.
;
;
; 设置这个指示为Off,在脚本执行期间发生错误时,不再将错误作为输出的一部分显示,这样就不会暴露给
; 远端用户。对于某些错误,错误信息的内容可能暴露你的脚本,web服务器,数据库服务器的信息,可能被
; 黑客利用。最终产品占点需要设置这个指示为off.
;
;
; – log_errors = On [Security]
; This directive complements the above one. Any errors that occur during the
; execution of your script will be logged (typically, to your server’s error log,
; but can be configured in several ways). Along with setting display_errors to off,
; this setup gives you the ability to fully understand what may have gone wrong,
; without exposing any sensitive information to remote users.
;
;
; 这个指示补充上面的。所有的发生在脚本运行期间的错误都会纪录在日志中(代表性的,记录在服务器的错误
; 日志中,但是可以配置不同的方式)。随着 display_errors 设置为 off,这个设置给你全面了解到底什么
; 发生错误的能力,而不会向远端用户暴露任何信息。
;
;
; – output_buffering = 4096 [Performance]
; Set a 4KB output buffer. Enabling output buffering typically results in less
; writes, and sometimes less packets sent on the wire, which can often lead to
; better performance. The gain this directive actually yields greatly depends
; on which Web server you’re working with, and what kind of scripts you’re using.
;
;
; 设置 4KB 的输出缓冲区。打开输出缓冲可以减少写的次数,有时减少线路发送包的数量,这样能提高性能。
; 这个指示真正得到的益处很大程度的依赖于你的工作的 WEB 服务器,以及你使用的脚本。
;
;
; – register_argc_argv = Off [Performance]
; Disables registration of the somewhat redundant $argv and $argc global
; variables.
;
;
; 禁止注册某些多于的 $argv 和 $argc 全局变量
;
;
; – magic_quotes_gpc = Off [Performance]
; Input data is no longer escaped with slashes so that it can be sent into
; SQL databases without further manipulation. Instead, you should use the
; function addslashes() on each input element you wish to send to a database.
;
;
; 输入数据不再被斜线转义,以便于无需更多的处理就可以发送到SQL数据库里面。作为代替,你可
; 以对每个要发送到数据库的输入元素使用 addslashes()函数。
;
;
; – variables_order = “GPCS” [Performance]
; The environment variables are not hashed into the $HTTP_ENV_VARS[]. To access
; environment variables, you can use getenv() instead.
;
; 环境变量不再进入 $HTTP_ENV_VARS[],你需要用 getenv()来访问环境变量。
;
;
; – error_reporting = E_ALL [Code Cleanliness, Security(?)]
; By default, PHP surpresses errors of type E_NOTICE. These error messages
; are emitted for non-critical errors, but that could be a symptom of a bigger
; problem. Most notably, this will cause error messages about the use
; of uninitialized variables to be displayed.
;
;
; 默认的,PHP 给出 E_NOTICE 错误类型,这些错误信息不是核心错误,但是可能是个更大错误的隐患。
; 大多数提醒是那些没有初始化变量引起的错误信息。
;
;
; – allow_call_time_pass_reference = Off [Code cleanliness]
; It’s not possible to decide to force a variable to be passed by reference
; when calling a function. The PHP 4 style to do this is by making the
; function require the relevant argument by reference.
;
;
; 在调用函数时,不可能决定强制传递变量的引用。PHP 4 里通过函数请求相关参数的引用来实现
;
;

;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;
;
; 语言配置
;
;
;;;;;;;;;;;;;;;;;;;;

; Enable the PHP scripting language engine under Apache.
;
;
; 允许在Apache下的PHP脚本语言引擎
;
;
engine = On

; Allow the tags are recognized.
;
;
; 允许 标记
;
;
short_open_tag = On

; Allow ASP-style tags.
;
;
; 允许 ASP 类型的 标记
;
;
asp_tags = Off

; The number of significant digits displayed in floating point numbers.
;
;
; 浮点数显示的有意义的数字(精度)
;
;
precision = 14

; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
;
;
; 强制遵从 2000 年(会在不遵从的浏览器上引起错误)
;
;
y2k_compliance = Off

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP’s output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size – you can use a maximum number of bytes instead of ‘On’, as
; a value for this directive (e.g., output_buffering=4096).
;
;
; 输出缓冲允许你在主体内容发送后发送头信息行(包括 cookies),作为代价,会稍微减慢一点PHP
; 输出层的速度。你可以在运行期间通过调用输出缓冲函数来打开输出缓冲。你也可以通过设置这个
; 指示来对虽有的文件打开输出缓冲。如果你想限制缓冲区大小为某个尺寸,你可以使用一个允许最大
; 的字节数值代替 “On”,作为这个指示的值。
;
;
output_buffering = 4096

; You can redirect all of the output of your scripts to a function. For
; example, if you set output_handler to “ob_gzhandler”, output will be
; transparently compressed for browsers that support gzip or deflate encoding.
; Setting an output handler automatically turns on output buffering.
;
;
; 你可以重新定向脚本所有输出到一个函数。例如,你可以设置 output_handler 为 “ob_gzhandler”,
; 输出将会被明显的被压缩到支持 gzip 或 deflate 编码的浏览器。设置一个输出管理会自动打开
; 输出缓冲
;
;
output_handler =

; Transparent output compression using the zlib library
; Valid values for this option are ‘off’, ‘on’, or a specific buffer size
; to be used for compression (default is 4KB)
;
;
; 使用 zlib 库进行输出压缩,可以指定 off/on 或者用于压缩的缓冲大小
;
;
zlib.output_compression = Off

; Implicit flush tells PHP to tell the output layer to flush itself
; automatically after every output block. This is equivalent to calling the
; PHP function flush() after each and every call to print() or echo() and each
; and every HTML block. Turning this option on has serious performance
; implications and is generally recommended for debugging purposes only.
;
;
; 隐含的通知PHP的输出层在每个输出块后自己自动刷新。等同于在每个 print() 或者 echo()
; 和每个HTML块后面都调用 flush()函数。打开这个配置会引起严重的隐含执行,一般推荐在用于
; 调试目的时使用。
;
;
implicit_flush = Off

; Whether to enable the ability to force arguments to be passed by reference
; at function call time. This method is deprecated and is likely to be
; unsupported in future versions of PHP/Zend. The encouraged method of
; specifying which arguments should be passed by reference is in the function
; declaration. You’re encouraged to try and tu
rn this option Off and make
; sure your scripts work properly with it in order to ensure they will work
; with future versions of the language (you will receive a warning each time
; you use this feature, and the argument will be passed by value instead of by
; reference).
;
;
; 是否允许在函数调用期间有强制参数以引用的形式传递的能力。这个方法不赞成使用,在将来的
; PHP和Zend版本里面可能不支持。鼓励的方法是在函数声明时指定哪个参数通过引用传递。鼓励你
; 尝试关闭这个参数,确认你的脚本能够正常运行,以便在以后版能里面正确运行(你会在每次使用
; 这个特性时得到一个警告,并且参数以值来传递,代替引用)
;
;
allow_call_time_pass_reference = Off

;
; Safe Mode
;
;
; 安全模式
;
;
;
safe_mode = Off

; By default, Safe Mode does a UID compare check when
; opening files. If you want to relax this to a GID compare,
; then turn on safe_mode_gid.
;
;
; 安全模式默认的在打开文件时进行 UID 比较检查,如果你想放宽他为GID比较,打开这个参数
;
;
safe_mode_gid = Off

; When safe_mode is on, UID/GID checks are bypassed when
; including files from this directory and its subdirectories.
; (directory must also be in include_path or full path must
; be used when including)
;
;
; 在安全模式,当包含如下目录和子目录文件时,绕过 UID/GID检查(路径必须在 include_path下面
; 或者在包含时使用完整路径
;
;
safe_mode_include_dir =

; When safe_mode is on, only executables located in the safe_mode_exec_dir
; will be allowed to be executed via the exec family of functions.
;
;
; 在安全模式下,只有给出目录下可以通过 exec 族函数执行
;
;
safe_mode_exec_dir =

; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.
;
;
; 如果设置,则限制所有的文件操作都到下面给出的目录下。这个指示在每个目录,每个虚拟主机的web
; 服务器配置文件里给出更多的认识。
;
;
;open_basedir =

; Setting certain environment variables may be a potential security breach.
; This directive contains a comma-delimited list of prefixes. In Safe Mode,
; the user may only alter environment variables whose names begin with the
; prefixes supplied here. By default, users will only be able to set
; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR).
;
; Note: If this directive is empty, PHP will let the user modify ANY
; environment variable!
;
;
; 设置某些环境变量可能是隐藏的安全缺口。这个指示包含一个逗号分割的前缀指示。在安全模式下
; 用户只能修改下面提供的为前缀的变量名字。默认,用户只能设置以 PHP_ 前缀开头的环境变量(
; 例如 PHP_FOO=BAR).
;
; 注意:如果这个设置为空,则 PHP 可以让用户修改任何环境变量。
;
;
safe_mode_allowed_env_vars = PHP_

; This directive contains a comma-delimited list of environment variables that
; the end user won’t be able to change using putenv(). These variables will be
; protected even if safe_mode_allowed_env_vars is set to allow to change them.
;
;
; 这个指示包含用逗号分割的不允许最终用户通过 putenv()修改的环境变量的列表。这些变量即使
; 在 safe_mode_allowed_env_vars 设置允许改变他们的情况下也被保护。
;
;
safe_mode_protected_env_vars = LD_LIBRARY_PATH

; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
;
;
; 这个指示用于在由于安全原因的情况下屏蔽某些函数。接受用逗号分割的函数名列表,这个指示不受
; Safe Mode 是否打开的影响。
;
;
disable_functions =

; Colors for Syntax Highlighting mode. Anything that’s acceptable in
; would work.
;
;
; 语法加亮模式的颜色,任何 正常工作的都可以接受
;
;
highlight.string = #CC0000
highlight.comment = #FF9900
highlight.keyword = #006600
highlight.bg = #FFFFFF
highlight.default = #0000CC
highlight.html = #000000

;
; Misc
;
; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header). It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
;
;
; 是否让服务器暴露 PHP(例如在 web 服务器头增加标记)。他不会有安全威胁,但是可以让你
; 检测一个服务器是否使用了 PHP.
;
;
expose_php = On

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;
;
; 资源限制
;
;

;;;;;;;;;;;;;;;;;;;

;
;
; 每个脚本最大执行的秒数
;
;
max_execution_time = 30 ; Maximum execution time of each script, in seconds

;
;
; 一个脚本最大消耗的内存
;
;
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;
;
; 错误处理和记录
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; error_reporting is a bit-field. Or each number up to get desired error
; reporting level
;
;
; 错误报告是一个位字段,每个数值代表错误报告的等级
;
;
; E_ALL – All errors and warnings
;
; 所有的错误和警告
;
; E_ERROR – fatal run-time errors
;
; 致命的运行期错误
;
; E_WARNING – run-time warnings (non-fatal errors)
;
; 运行期警告(非致命错误)
;
; E_PARSE – compile-time parse errors
;
; 编译期间解析错误
;
; E_NOTICE – run-time notices (these are warnings which often result
; from a bug in your code, but it’s possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it’s automatically initialized to an
; empty string)
;
; 运行期间注意,一般是由于代码的 bug 引起的警告,但是很可能是故意这样的。例如使用没有初始化
; 的变量,依赖于他自动初始化为空的字符串。
;
; E_CORE_ERROR – fatal errors that occur during PHP’s initial startup
;
; 发生在 PHP 的初始启动阶段的致命错误
;
; E_CORE_WARNING – warnings (non-fatal errors) that occur during PHP’s
; initial startup
;
; 发生在 PHP 的初始启动阶段的警告(非致命错误)
;
; E_COMPILE_ERROR – fatal compile-time errors
;
; 致命的编译期间错误
;
; E_COMPILE_WARNING – compile-time warnings (non-fatal errors)
;
; 编译期间的警告(非致命的错误)
;
; E_USER_ERROR – user-generated error message
;
; 用户引起的错误信息
;
; E_USER_WARNING – user-generated warning message
;
; 用户引起的警告信息
;
; E_USER_NOTICE – user-generated notice message
;
; 用户引起的提醒信息
;
;
; Examples:
;
; – Show all errors, except for notices
;
; 显示所有错误,除了提醒
;
;error_reporting = E_ALL & ~E_NOTICE

;
; – Show only errors
;
; 只显示错误
;
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
;
; – Show all errors except for notices
;
; 显示所有的错误(译者注:英文可能有错误)
;
error_reporting = E_ALL

; Print out errors (as a part of the output). For production web sites,
; you’re strongly encouraged to turn this feature off, and use error logging
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
;
;
; 输出错误(作为输出的一部分)。对于成品网站,强烈建议关闭这个特性,使用下面错误日志代替。
; 在成品网站打开这个特性可能对最终用户暴露安全信息。例如 WEB 服务器的文件路径,数据库计划
; 或其他信息。
;
;
display_errors = Off

; Even when display_errors is on, errors that occur during PHP’s startup
; sequence are not displayed. It’s strongly recommended to keep
; display_startup_errors off, except for when debugging.
;
;
; 即使 display_errors 参数设置位 on,发生在 PHP 的启动顺序期间的错误也不会显示。
; 强烈建议保持 display_startup_errors 为 off,除非在调试阶段。
;
;
display_startup_errors = Off

; Log errors into a log file (server-specific log, stderr, or error_log (below))
; As stated above, you’re strongly advised to use error logging in place of
; error displaying on production web sites.
;
;
; 把错误写到一个日志文件里面(服务器指定日志,标准错误,或者后面的错误日志)。
; 根据上面的一致性,强烈建议使用错误日志代替web站点的错误显示。
;
;
log_errors = On

; Store the last error/warning message in $php_errormsg (boolean).
;
;
; 保存最后的错误/警告信息在 $php_errormsg(boolean)里面。
;
;
track_errors = Off

; Disable the inclusion of HTML tags in error messages.
;
;
; 屏蔽掉错误信息里面内含的HTML标记
;
;
;html_errors = Off

; String to output before an error message.
;
;
; 错误信息前输出的字符串
;
;
;error_prepend_string = “”

; String to output after an error message.
;
;
; 错误信息后输出的字符串。
;
;
;error_append_string = “”

; Log errors to specified file.
;
;
; 错误写进指定的文件
;
;
;error_log = filename

; Log errors to syslog (Event Log on NT, not valid in Windows 95).
;error_log = syslog

; Warn if the + operator is used with strings.
;
;
; 在对字符串用 + 操作符时给出警告
;
;
warn_plus_overloading = Off

;;;;;;;;;;;;;;;;;
; Data Handling ;
;
;
; 数据处理
;
;
;;;;;;;;;;;;;;;;;
;
; Note – track_vars is ALWAYS enabled as of PHP 4.0.3
;
; 注意,在 PHP 4.0.3 里面, track_vars 总是打开的。
;

; The separator used in PHP generated URLs to separate arguments.
; Default is “&”.
;
;
; PHP在产生URLs时用于分割参数的分割符。默认是 “&”
;
;
;arg_separator.output = “&”

; List of separator(s) used by PHP to parse input URLs into variables.
; Default is “&”.
; NOTE: Every character in this directive is considered as separator!
;
;
; PHP用于把输入的 URLs 解析为变量的分割符列表,默认是 “&”;
; 注意:这个指示的每个字符都被认为是分割符
;
;
;arg_separator.input = “;&”

; This directive describes the order in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
; referred to as EGPCS or GPC). Registration is done from left to right, newer
; values override older values.
;
;
; 这个指示描述PHP注册 GET,POST,Cookes,环境变量和内部变量的顺序(分别对应于 G,P,C,E 和 S,
; 经常为 EGPCS 或者 GPC).注册从左到右,新的值覆盖旧的值。
;
;
variables_order = “GPCS”

; Whether or not to register the EGPCS variables as global variables. You may
; want to turn this off if you don’t want to clutter your scripts’ global scope
; with user data. This makes most sense when coupled with track_vars – in which
; case you can access all of the GPC variables through the $HTTP_*_VARS[],
; variables.
;
;
; 是否注册 EGPCS 变量为全局变量。如果你不想和用户数据混淆脚本全局范围,你可能想关闭他。
; 结合 track_vars 可以更加理性。它可以让你通过 $HTTP_*_VARS[] 访问所有的GPC变量。
;
;
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
;
;
; 你可以尽力书写不需要 register_globals 打开时的脚本。如果代码没有非常好的考虑是
; 使用来源于全局变量的表单数据很容易引起安全问题。
;
;
register_globals = Off

; This directive tells PHP whether to declare the argv&argc variables (that
; would contain the GET information). If you don’t use these variables, you
; sh

Tomcat 配置集锦

0

分类 : 技术文摘 | 发表时间 21-11-2005

Tomcat 服务器server.xml的关键参数配置

说明:以下文字均以tomcat5.0.30为例进行。

1,配置tomcat服务器访问端口,只需配置Connector的port端口即可。Tomcat默认为8080,现修改port参数值为80。

<!– Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 –>

<Connector port=”80″

maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″

enableLookups=”false” redirectPort=”8443″ acceptCount=”100″

debug=”0″ connectionTimeout=”20000″

disableUploadTimeout=”true” URIEncoding=”GBK”/>

2,配置tomcat支持URL中文参数,只需添加Connector的URIEncoding参数即可,默认情况下该参数未被配置。要支持URL参数支持中文,加上URIEncoding=”GBK”就行了(见1中附代码最后一行)。

3,配置新的webApp:找到host尾标记</Host>,插入新的context即可。
如:
(1)<Context path=”" docBase=”ROOT” debug=”0″/>
若要支持数据库(以SQL Server为例),则为:
(2)<Context path=”/xkb” docBase=”F:\XKB6\webApp” debug=”5″ reloadable=”true” crossContext=”true”>

<Logger className=”org.apache.catalina.logger.FileLogger” prefix=”localhost_DBTest_log.” suffix=”.txt” timestamp=”true”/>

<Resource name=”jdbc/SqlServerDB” auth=”Container” type=”javax.sql.DataSource”/>

<ResourceParams name=”jdbc/SqlServerDB”>

<parameter>

<name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

</parameter>

<!– Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to 0 for no limit.–>

<parameter>

<name>maxActive</name>

<value>50</value>

</parameter>

<!– Maximum number of idle dB connections to retain in pool. Set to 0 for no limit.–>

<parameter>

<name>maxIdle</name>

<value>20</value>

</parameter>

<!– Maximum time to wait for a dB connection to become available in ms, in this example 0.5 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. –>

<parameter>

<name>maxWait</name>

<value>500</value>

</parameter>

<!– msSQL dB username and password for dB connections –>

<parameter>

<name>username</name>

<value>sa</value>

</parameter>

<parameter>

<name>password</name>

<value>wangnewton</value>

</parameter>

<!– Class name for SQLServer2000 JDBC driver –>

<parameter>

<name>driverClassName</name>

<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>

</parameter>

<!– The JDBC connection url for connecting to your MS SQL Server dB.The autoReconnect=true argument to the url makes sure that the mm.Sql Server JDBC Driver will automatically reconnect if mysqld closed the connection. mysqld by default closes idle connections after 8 hours.–>

<parameter>

<name>url</name>

<value>jdbc:microsoft:sqlserver://localhost:1433;databaseName=XKBCourse</value>

<!–must use & not use & –>

</parameter>

</ResourceParams>

</Context>

tomcat5.5.x 配置记录。

1.下载:
http://www.eu.apache.org/dist/jakarta/tomcat-5/
http://www.apache.org/dist/jakarta/tomcat-5/v5.5.x/bin/jakarta-tomcat-5.5.x-admin.zip
http://www.apache.org/dist/jakarta/tomcat-5/v5.5.x/bin/jakarta-tomcat-5.5.x-compat.zip
http://www.apache.org/dist/jakarta/tomcat-5/v5.5.x/bin/jakarta-tomcat-5.5.x.zip
http://www.apache.org/dist/jakarta/tomcat-5/v5.5.x/bin/jakarta-tomcat-5.5.x-deployer.zip
把jakarta-tomcat-5.5.x.zip
和jakarta-tomcat-5.5.x-compat.zip
和jakarta-tomcat-5.5.x-admin.zip
(Tomcat 默认是没有内置admin模块了
Tomcat’s administration web application is no longer installed by default. Download and install the “admin” package to use it. )
都解压到同一个目录下面。比如:D:\jakarta-tomcat-5.5.x\
(如果使用jdk1.4,才需要compat.zip用jdk1.5就可以免了这个。)

2.修改jakarta-tomcat-5.5.x\conf\tomcat-users.xml.
添加管理员账号lizongbo,密码为lizongbopass.
新xml如下:
<?xml version=’1.0′ encoding=’utf-8′?>
<tomcat-users>
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<role rolename=”manager”/>
<role rolename=”admin”/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”role1″ password=”tomcat” roles=”role1″/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”lizongbo” password=”lizongbopass” roles=”admin,manager”/>
</tomcat-users>

3.修改jakarta-tomcat-5.5.x\conf\server.xml来解决编码问题。
(给Connector 添加URIEncoding参数,参考http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx)
(可以设置成GB18030)
<Connector port=”8080″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” redirectPort=”8443″ acceptCount=”200″
connectionTimeout=”20000″ disableUploadTimeout=”true” URIEncoding=”GBK”
compression=”on” compressionMinSize=”2048″
noCompressionUserAgents=”gozilla, traviata”
compressableMimeType=”text/html,text/xml”/>

<Connector port=”8009″
enableLookups=”false” redirectPort=”8443″ protocol=”AJP/1.3″ URIEncoding=”GBK”/>

4.启用支持gzip压缩.
(http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&i=81169)
添加下列属性
compression=”on”
compressionMinSize=”2048″
noCompressionUserAgents=”gozilla, traviata”
compressableMimeType=”text/html,text/xml”

5.设置虚拟主机。
在jakarta-tomcat-5.5.x\下建立文件夹vhost\www.mydomain.com。
然后修改jakarta-tomcat-5.5.x\conf\server.xml

<Engine defaultHost=”localhost” name=”Catalina”>
<Host appBase=”vhost/www.mydomain.com” name=”www.mydomain.com”>
</Host>
<Host appBase=”webapps” name=”localhost”>
</Host>
<Realm className=”org.apache.catalina.realm.UserDatabaseRealm”/>
</Engine>

6.添加数据库驱动,更新mail.jar和actiovation.jar
复制mysql-connector-java-3.0.16-ga-bin.jar,pg74.215.jdbc3.jar到 jakarta-tomcat-5.5.x\common\lib\
还有javamail 1.3.2的mail.jar,jaf-1_0_2的 activation.jar
msSQl 2000 JDBC sp3,msbase.jar,msutil,jar,mssqlserver.jar

7.配置SSL
参考 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/ssl-howto.html
D:\j2sdk1.4.2_06\bin>%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
输入keystore密码: lizongbossl
您的名字与姓氏是什么?
[tomcat5.5.x]: tomcat5.5.x
您的组织单位名称是什么?
[jakarta]: jakarta
您的组织名称是什么?
[apache]: apache
您所在的城市或区域名称是什么?
[hzcity]: hzcity<
br/>您所在的州或省份名称是什么?
[gdp]: gdp
该单位的两字母国家代码是什么
[CN]: CN
CN=tomcat5.5.x, OU=jakarta, O=apache, L=hzcity, ST=gdp, C=CN 正确吗?
[否]: y

输入<tomcat>的主密码
(如果和 keystore 密码相同,按回车):

(必须密码一致,因此直接回车)
然后再把userhome(例如:C:\Documents and Settings\lizongbo\)下的.keystore复制到
tomcat的conf\目录下。
(例如:D:\jakarta-tomcat-5.5.x\conf\.keystore )
配置jakarta-tomcat-5.5.x\conf\server.xml
加上
<Connector port=”8443″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” disableUploadTimeout=”true”
acceptCount=”100″ scheme=”https” secure=”true”
clientAuth=”false” sslProtocol=”TLS”
keystoreFile=”conf/.keystore”
keystorePass=”lizongbossl”> <!–与先前设置的密码一致–>
</Connector>
8.禁止文件目录列表,
修改jakarta-tomcat-5.5.x\conf\web.xml,把listing设置为false

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

9.指定了自己的javaEncoding
(参考 http://gceclub.sun.com.cn/staticcontent/html/sunone/app7/app7-dg-webapp/ch6/ch6-4.html )

<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>javaEncoding</param-name>
<param-value>GB18030</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
10.添加rar,iso等的mime-type映射
避免在浏览器里直接打开。
<mime-mapping>
<extension>mht</extension>
<mime-type>text/x-mht</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rar</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>iso</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ape</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rmvb</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>
10.1对html静态页面设置编码
<!– 修改下面两行以支持静态超文本的自动编码
–>
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html;charset=gb2312</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html;charset=gb2312</mime-type>
</mime-mapping>
</web-app>

11.添加welcome-file-list,并调整顺序。
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

Tomcat中文编码问题解决方案(简)

liyonghai 04/08/30

编码问题的根源可参考http://www-900.ibm.com/developerWorks/cn/java/java_chinese/index.shtml

Tomcat 4.x解决方法:
获取中文:request.setCharacterEncoding(“gb2312″);
输出中文:<%@ page contentType=”text/html;charset=gb2312″ %>,必要时需要转码

Tomcat 5.x解决方法:
获取中文:
提交表单时
1)post:request.setCharacterEncoding(“gb2312″);
2)get:修改server.xml,在Connector中加入URIEncoding=”gb2312″
如: <Connector port=”80″ maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” redirectPort=”8443″ acceptCount=”100″
debug=”0″ connectionTimeout=”20000″
disableUploadTimeout=”true” URIEncoding=”gb2312″ />
或者使用useBodyEncodingForURI,使tomcat 5.x兼容tomcat 4.x
输出中文:<%@ page contentType=”text/html;charset=gb2312″ %>,必要时需要转码

附:Tomcat 5.x与Tomcat 4.x在解析提交表单时发生了变化,Tomcat 4.x无论是post还是get,都使用
相同的编码,而Tomcat 5.x 却把get方法单独了出来.具体可查看tomcat的source code.

get方式的处理比较好,对于post方式建议用配置过滤器的方式来解决,因为这样,配置一个地方整个系统都不用操心了。

简单说明:
web.xml
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>SetCharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
/************************/

SetCharacterEncodingFilter.java
——————————————–
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;

/**
* Example filter that sets the character encoding to be used in parsing the
* incoming request
*/
public class SetCharacterEncodingFilter implements Filter {

/**
* Take this filter out of service.
*/
public void destroy() {
}
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)throws IOException, ServletException {

request.setCharacterEncoding(“GBK”);

// 传递控制到下一个过滤器
chain.doFilter(request, response);
}

public void init(FilterConfig filterConfig) throws ServletException {
}
}
////也可以把编码做为参数传递进去。

12.如果你的webapp需要只能够进行https方式访问,那么在webapp的web.xml里加上:
<security-constraint>
<web-resource-collection>
<web-resource-name>must https</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
参考:http://jakarta.apache.org/tomcat/faq/security.html#https
http://marc.theaimsgroup.com/?l=tomcat-user&m=1049515597226
19&w=2


13.修改远程关闭服务器的命令。
server.xml默认有下面一行:
<Server port=”8005″ shutdown=”SHUTDOWN”>
这样允许任何人只要telnet到服务器的8005端口,输入”SHUTDOWN”,然后回车,服务器立即就被关掉了。
从安全的角度上考虑,我们需要把这个shutdown指令改成一个别人不容易猜测的字符串。
例如修改如下:
<Server port=”8006″ shutdown=”lizongbo”>,这样就只有在telnet到8005,并且输入”lizongbo”才能够关闭Tomcat.
注意:这个修改不影响shutdown.bat的执行。运行shutdown.bat一样可以关闭服务器。
参考:http://jakarta.apache.org/tomcat/faq/security.html#8005

以下皆可以参考:http://www.cnjsp.org/document/user/tuman/valve.html

14.配置http访问日志。Tomcat自带的能够记录的http访问日志已经很详细了
取消下面这段的注释:

<Valve className=”org.apache.catalina.valves.AccessLogValve”
directory=”logs” prefix=”localhost_access_log.” suffix=”.txt”
pattern=”common” resolveHosts=”false”/>

然后修改为:
<Valve className=”org.apache.catalina.valves.FastCommonAccessLogValve”
directory=”logs” prefix=”localhost_access_log.” suffix=”.txt”
pattern=”combined” resolveHosts=”false” fileDateFormat=”yyyy-MM-dd.HH”/>

pattern=”combined” 记录的日志内容更详细,fileDateFormat=”yyyy-MM-dd.HH”,会让日志文件按小时进行滚卷,
比默认的按天滚卷要好些,尤其是访问量大的网站,可以考虑写成fileDateFormat=”yyyy-MM-dd.HH.mm”,就会是每分钟一个日志文件了。
而且可以分别按Engine, Host, or Context,来记录自己的日志
详情参考:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/valve.html
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/logger.html
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/host.html#Access%20Logs
而且还可以配合awstats来进行日志统计分析: http://www.chedong.com/tech/awstats.html http://blog.csdn.net/lizongbo/archive/2005/02/18/291929.aspx

15.限制ip,限制主机访问等。
如果想禁止指定的ip或者主机名来拒绝某些机器访问,或者指定某些机器来访问。
也支持分别按Engine, Host, or Context,进行以下配置:
<Context path=”/examples” …> …
<Valve className=”org.apache.catalina.valves.RemoteHostValve”
allow=”*.mycompany.com,www.yourcompany.com”/>
<Valve className=”org.apache.catalina.valves.RemoteAddrValve”
deny=”192.168.1.*”/>
</Context>
参考:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html

16.发布webapp到网站根目录
1。直接复制到ROOT目录下。
2.因为无法创建无名字的xml文件,并且在xml文件里指定path也是无效的(tomcat靠文件名字来判断的),
因此必须在server.xml里写下面一段:
<Context docBase=”${catalina.home}/vhost/www.lizongbo.com” path=”/”
privileged=”true” antiResourceLocking=”false” antiJARLocking=”false”>
<Manager className=”org.apache.catalina.session.StandardManager” algorithm=”SHA-512″ sessionIdLength=”40″>
<Valve className=”org.apache.catalina.valves.FastCommonAccessLogValve”
directory=”logs” prefix=”localhost_mytest_access_log.” suffix=”.txt”
pattern=”combined” resolveHosts=”true” fileDateFormat=”yyyy-MM-dd.HH”/>

</Context>
而且必须把ROOT目录删除掉,否则Tomcat还是优先部署ROOT目录为”/”。

17.在重新启动Tomcat的webapp的时候,禁止把session写入文件。
修改conf/web.xml
取消注释:
<!—->
<Manager pathname=”" />

18.增强SessiionID的生成算法和长度。

<Manager className=”org.apache.catalina.session.StandardManager” algorithm=”SHA-512″ sessionIdLength=”40″>
</Manager>

(Tomcat默认算法是MD5,默认长度是16位。)

tomcat+jsp经典配置

Tomcat下JSP、Servlet和JavaBean环境的配置

经常看到jsp的初学者问tomcat下如何配置jsp、servlet和bean的问题,于是总结了一下如何tomcat下配置jsp、servlet和ben,希望对那些初学者有所帮助。
一、开发环境配置
第一步:下载j2sdk和tomcat:到sun官方站点(http://java.sun.com/j2se/1.4.2/download.html)下载j2sdk,注意下载版本为Windows Offline Installation的SDK,同时最好下载J2SE 1.4.2 Documentation,然后到tomcat官方站点(http://www.apache.org/dist/jakarta/tomcat-4/)下载tomcat(下载最新4.1.x版本的tomcat);
第二步:安装和配置你的j2sdk和tomcat:执行j2sdk和tomcat的安装程序,然后按默认设置进行安装即可。
1.安装j2sdk以后,需要配置一下环境变量,在我的电脑->属性->高级->环境变量->系统变量中添加以下环境变量(假定你的j2sdk安装在c:\j2sdk1.4.2):
JAVA_HOME=c:\j2sdk1.4.2
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;(.;一定不能少,因为它代表当前路径)
path=%JAVA_HOME%\bin
接着可以写一个简单的java程序来测试J2SDK是否已安装成功:
public class Test{
public static void main(String args[]){
System.out.println(“This is a test program.”);
}
}
将上面的这段程序保存为文件名为Test.java的文件。
然后打开命令提示符窗口,cd到你的Test.java所在目录,然后键入下面的命令
javac Test.java
java Test
此时如果看到打印出来This is a test program.的话说明安装成功了,如果没有打印出这句话,你需要仔细检查一下你的配置情况。
2.安装Tomcat后,在我的电脑->属性->高级->环境变量->系统变量中添加以下环境变量(假定你的tomcat安装在c:\tomcat):
CATALINA_HOME=c:\tomcat
CATALINA_BASE=c:\tomcat
然后修改环境变量中的classpath,把tomat安装目录下的common\lib下的(可以根据实际追加)servlet.jar追加到classpath中去,修改后的classpath如下:
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\common\lib\servlet.jar;
接着可以启动tomcat,在IE中访问http://localhost:8080/,如果看到tomcat的欢迎页面的话说明安装成功了。
第三步:建立自己的jsp app目录
1.到Tomcat的安装目录的webapps目录,可以看到ROOT,examples, tomcat-docs之类Tomcat自带的的目录;
2.在webapps目录下新建一个目录,起名叫myapp;
3.myapp下新建一个目录WEB-INF,注意,目录名称是区分大小写的;
4.WEB-INF下新建一个文件web.xml,内容如下:
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
“http://java.sun.com/dtd/web-app_2_3.dtd”>
<web-app>
<display-name>My Web Application</display-name>
<description>
A application for test.
</description>
</web-app>
5.在myapp下新建一个测试的jsp页面,文件名为index.jsp,文件内容如下:
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
6.重启Tomcat
7.打开浏览器,输入http://localhost:8080/myapp/index.jsp 看到当前时间的话说明就成功了。
第四步:建立自己的Servlet:
1.用你最熟悉的编辑器(

HP-UNIX SAMBA 的安装及配置

0

分类 : 技术文摘 | 发表时间 18-11-2005

由于公司许多同事感觉在对UNIX进行文件存取时非常不方便,又羡慕LINUX的SAMBA .于是查了查SAMBA站点,发现可以在HP-UNIX上安装SAMBA,结果成功了,小弟愿与大家共享。


安装步骤:

1、到SAMBA站点下载HP-UNIX的SAMBA 二进制文件。

http://us1.samba.org/samba/ftp/Binary_Packages/hp/samba2.2.5/samba_2.2.5_HPUX_withwinbind.depot.gz


2、解压文件

tar -xzvf samba_2.2.5_HPUX_withwinbind.depot.gz
或者直接用gzip 命令解开。


3、安装

文件解压后可以得到文件samba_2.2.5_HPUX_withwinbind.depot,
然后用swinstall -s /yourdirectory/samba_2.2.5_HPUX_withwinbind.depot 安装该软件,
如果您感觉在字符控制台模式下不太方便,可以通过设置export DISPLAY=yourhost:0.0 然后在你的机器上启动 X-WIN32作模拟X终端,进行安装。


4、配置

打开/usr/local/samba/lib/smb.con (该文件依具体安装目录的不同而不同)文件,修改文件中的安全项:

# security_level.txt for details.
security = server
# Use password server option only with security = server or domain
password server = your server ip


然后添加


[tmp]
path = /tmp #当前共享的目录
hosts allow = 211.88.9.160 #允许访问该共享的主机


存盘退出。

5、检测

请使用 testparm 命令监测 smb.conf语法是否正确,如果一切ok.则可以启动samba服务。

6、启动samba服务

Start smbd & nmbd by /sbin/init.d/samba start



如果您在ie里面敲 \\your samba server 可以访问你刚建的共享tmp了,如果你不能创建新的文件夹,请确认您对当前目录是否有足够的权限。

phpMyAdmin (安装及配置)

0

分类 : 技术文摘 | 发表时间 12-11-2005

前言
  phpMyAdmin可以管理整个MySQL服务器(需要超级用户),也可以管理单个数据库。为了实现后一种,你
将需要合理设置MySQL用户,他只能对允许的数据库进行读/写。那要等到你看过MySQL手册中相关的部分。

快速安装

将phpMyAdmin软件包解到一个目录下。
打开config.inc.php3,根据你的环境,修改$cfgServers[1]['host'],$cfgServers[1]['user']和
$cfgServers[1]['password']的值。可以看一下下面的配置部分所列出的所有可配置的变量,根据情
况对其它参数进行修改。
建议在安装完phpMyAdmin之后,对其目录进行保护(除非在一个企业内部网上)。例如,可以使用HTTP-AUTH(用一个.htaccess文件)。
在浏览器中打开文件:安装主机域名/安装目录/index.php3。phpMyAdmin应该显示一个欢迎屏和你的数
据库。
phpMyAdmin支持多语言。如果要改成中文版本,则修改config.inc.php3中的require(“english.inc.php3″);为require(“chinese_gb.inc.php3″)。这样界面就是中文的了。好棒噢!
保存config.inc.php3。
安装注意
请确认保护了phpMyAdmin目录。缺省是没有任何保护的!它不应该被随便一个人特别是搜索引擎读到。
尽管我在每一页中都加了一个”nofollow”指令,也可能有的搜索引擎不考虑仍然继续访问页面的链接。
想象一下AltaVista访问了一个名叫”Drop Dtabase”的链接会怎么样吧。你可以
在http://www.apacheweek.com/features/userauth对Apache的认证方法有一个全面了解。另一个教程
在http://deepthought.texsci.edu/protected_dirs.html
PHP3应该被配置为magic_quotes=on。
配置
  所有可配置数据都放在config.inc.php3中。

$cfgServers 数组
  从1.4.2版本开始,phpMyAdmin支持对多个MySQL-server的管理。所以,增加了$cfgServers数组来存放
不同服务器的登录信息。$cfgServers[1]['host']包含了第一个服务器的主机名,$cfgServers[2]['host']
为第二个服务器的主机等,等等。如果你只有一个服务器要管理,可以简单地不去理会其它$cfgServers入
口的主机名。

$cfgServers[n]['port'] 字符串
  第n个MySQL服务器的端口号。缺省值为3300(保留空值)。

$cfgServers[n]['host'] 字符串
  第n个MySQL服务器的主机名。例如,localhost。

$cfgServers[n]['adv_auth'] 布尔值
  对这个服务器应该使用基本或是高级认证方式。基本认证方式($adv_auth = false)是普通的老的作法:
用户名和口令被存在config.inc.php3中。高级认证方式($adv_auth = true)从1.3.0版开始引入,允许你通
过HTTP-Auth来作为合法的MySQL的用户进行登录。在config.inc中你只需要提供一个标准用户,他能够连接
到MySQL上并且可以读出mysql库的user/db表(看$cfgServers[n]['stduser'])。

推荐使用高级方式管理的场合:

当phpMyAdmin运行在多用户环境下,人们拥有shell处理权限时,你不想知道MySQL的用户名/口令。
当你想让用户存取他们自已的数据库,并且不想他们干扰其他人。
  高级认证方式是安全的,因为标准用户只需要对mysql库的只读权限。MySQL口令不能被容易的破解,所
以对于一个普通用户没有机会看到其它用户的明文口令。

$cfgServers[n]['user'] 字符串
$cfgServers[n]['password'] 字符串
  当使用基本认证方式时,phpMyAdmin将使用用户名/口令对同这个MySQL服务器连接。当使用高级认证方
式时则不需要。

$cfgServers[n]['stduser'] 字符串
$cfgServers[n]['stdpass'] 字符串
  当使用高级认证方式时,用户名/口令对被用于校验真正的用户名/口令对。这个用户必须能够连接MySQL,
而且可以读取mysql库的user表。当使用基本认证方式时则不需要。

$cfgServers[n]['only_db'] 字符串
  如果设置了一个数据库名,只有这个数据库将显示给用户。

$cfgServers[n]['verbose'] 字符串
  只有在多服务器入口时使用phpMyAdmin才有用。如果设置了,这个字符串将被显示出来,用来代替在主页面中的下接菜单中的主机名。例如,如果你想在系统只显示某些数据库,这个可能就有用了。


$cfgManualBase 字符串
  如果设为一个URL(它指向MySQL文档),就会创建相应的帮助链接。


$cfgPersistentConnections 布尔值
  是否使用持续连接(mysql_connect或mysql_pconnect)。

$cfgConfirm 布尔值
  当你将要丢失数据时是否应该显示一个警告信息(“你真的确定要…”)。

$cfgMaxRows 整数
  当浏览一个结果集时显示的记录数。如果结果集包含了更多的数据,将显示前页/后页的链接。

$cfgMaxInputsize 整数
  当向一个表增加一条新的记录时,编辑字段的大小。

$cfgBorder 整数
  表格边界的大小。

$cfgThBgcolor 字符串 [HTML 颜色]
  用在表头的颜色。

$cfgBgcolorOne 字符串 [HTML 颜色]
  表格行第一行的颜色。

$cfgBgcolorTwo 字符串 [HTML 颜色]
  表格行第二行的颜色。

$cfgOrder 字符串 ["DESC"|"ASC"]
  定义了当你点击字段名时,字段是以升序(“ASC”)显示还是以降序(“DESC”)显示。

$cfgShowBlob 布尔值
  定义了当浏览一个表的内容时,是否显示BLOB字段。

$cfgShowSQL 布尔值
  定义了是否显示phpMyAdmin所生成的sql查询语句。

$cfgColumnTypes 数组
  MySQL列的所有可能的类型。大多数情况下你不需要编辑它。

$cfgFunctions 数组
  MySQL支持函数的列表。大多数情况下你不需要编辑它。

$cfgAttributeTypes 数组
  字段可能的属性。大多数情况下你不需要编辑它。

FAQ – 常见问题
我不能向表中插入新记录 — MySQL返回一个SQL错误。

  仔细检查SQL错误。我发现很多的程序员使用了错误的字段类型。普通的错误包括:

使用VARCHAR没有指定大小
使用TEXT或BLOB指定了大小
  另外,查看一下MySQL手册中的语法章节以确认你的语法是正确的。

phpMyAdmin不能连接MySQL。出了什么错?

   或者是PHP安装的问题或者是你的用户名/口令错了。试着编一个小的用了mysql_connect的脚本,看一
下是否它能工作。如果不能,那就可能是还没有在PHP中将MySQL的编译进去。

我不能编辑表的内容,尽管README中说这是phpMyAdmin的一个特色。


  phpMyAdmin只允许编辑拥有主键或唯一键值的表的内容。

当使用高级认证管理时,phpMyAdmin总是给出”处理禁止(Access denied)”。

发生可能有几种原因:

$stduser/$stdpassword不正确。试着关掉$adv_auth,然后使用这个用户名及口令来连接MySQL。
在登录对话框中指定的用户名/口令是错的。试着用上面同样的方法看一下是否可以工作。
你已经给phpMyAdmin安装目录建立了安全机制,例如,.htaccess文件。这个可能干扰phpMyAdmin的认
证管理,那么把它删除。
我想对phpMyAdmin的开发提供帮助。我应该如何进行?

下面的方法对于新的开发者来说是首选的:

取出在匿名CVS上的当前的CVS:
cvs -d :pserver:anon@www.htmlwizard.net:/usr/local/cvsroot login
[Password: phpMyAdmin]
cvs -d :pserver:anon@www.htmlwizard.net:/usr/local/cvsroot checkout phpMyAdmin
[这样将创建一个名为phpMyAdmin
的新的子目录]
加入你的东西
将修改的文件发给我(tar格式或gzip格式) 对CVS树的写权限只授权给有经验的已经对phpMyAdmin作出
了贡献的开发者。

另外看一下DEVELOPERS文件。
有什么好的方法可以让phpMyAdmin更安全对付恶意的攻击?

  这要看你的系统了。如果你正在运行一个无法被其它人使用的服务器,使用web服务器的目录保护绑定
就已经足够了(例如,对于Apache你可以使用.htaccess文件)。如果其它的人可以通过telnet存取你的服务
器,将MySQL口令以明文形式保存在你的config.inc.php3 文件中就不是一个好方法了。在这种情况下你应
该使用phpMyAdmin的高级认证方式功能。

如何才能向我的表中插入一个null值呢?

  输入”null”(没有引号)作为字段的的值。这个对于时间戳或自动增加字段特别有用。

我是一个ISP供应商。我可以安装一个主控的phpMyAdmin拷贝吗?或需要为每一个客户都安装一个?

   从2.0.3版本开始,你可以安装一个主控的phpMyAdmin拷贝为你的所有的用户。这个特性的开发是由
NetCologne GmbH倡议的。这样就要求合理地设置MySQL用户,并且设置phpMyAdmin的高级认证方式。当认证
一个用户时,phpMyAdmin执行这些步骤:

从mysql.user表中选出所有用户名/口令与申请用户相匹配的记录。如果没有记录被返回,认证失败。
否则,phpMyAdmin继续第2步。
如果用户的global Select_Priv是”N”(也就是用户不允许存取所有的数据库),phpMyAdmin搜索mysql.db
表,查找对于这个用户的Select_Priv=”Y”的记录。如果没有记录被找到,认证失败。否则,phpMyAdmin
显示所有允许用户查看的数据库。
如果用户的global Select_Priv是”Y”,系统中所有的数据库都显示出来。

  这就意味着你需要向mysql库中如下增加用户:

INSERT INTO user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv) VALUES (‘localhost’, ‘foo’, PASSWORD(‘bar’), ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’)
INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, Index_priv, Alter_priv) VALUES (‘localhost’, ‘foo_db’, ‘foo’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ”, ”, ”, ”)

  那样,对于用户foo,只有”foo_db”库将被显示出来。

phpMyAdmin主页:http://www.htmlwizard.net/phpMyAdmin/

无觅相关文章插件,快速提升流量