从版本 4.3.0 开始,PHP 提供了一种新类型的 SAPI(Server Application Programming Interface,服务端应用编程端口)支持,名为 CLI,意为 Command Line Interface,即命令行接口。顾名思义,该 SAPI 模块主要用作 PHP 的开发外壳应用。CLI SAPI 和其它 SAPI 模块相比有很多的不同之处,我们将在本章中详细阐述。值得一提的是,CLICGI 是不同的 SAPI,尽管它们之间有很多共同的行为。

CLI SAPI 最先是随 PHP 4.2.0 版本发布的,但仍旧只是一个实验性的版本,并需要在运行 ./configure 时加上 –enable-cli 参数。从 PHP 4.3.0 版本开始,CLI SAPI 成为了正式模块,–enable-cli 参数会被默认得设置为 on,也可以用参数 –disable-cli 来屏蔽。

从 PHP 4.3.0开始,CLI/CGI 二进制执行文件的文件名、位置和是否存在会根据 PHP 在系统上的安装而不同。在默认情况下,当运行 make 时,CGI 和 CLI 都会被编译并且分别放置在 PHP 源文件目录的 sapi/cgi/phpsapi/cli/php 下。可以注意到两个文件都被命名为了 php。在 make install 的过程中会发生什么取决于配置行。如果在配置的时候选择了一个 SAPI 模块,如 apxs,或者使用了 –disable-cgi 参数,则在 make install 的过程中,CLI 将被拷贝到 {PREFIX}/bin/php,除非 CGI 已经被放置在了那个位置。因此,例如,如果在配置行中有 –with–apxs,则在 make install 的过程中,CLI 将被拷贝到 {PREFIX}/bin/php。如果希望撤销 CGI 执行文件的安装,请在 make install 之后运行 make install-cli。或者,也可以在配置行中加上 –disable-cgi 参数。

Note: 由于 –enable-cli 和 –enable-cgi 同时默认有效,因此,不必再配置行中加上 –enable-cli 来使得 CLI 在 make install 过程中被拷贝到 {PREFIX}/bin/php

在 PHP 4.2.0 到 PHP 4.2.3 之间的 Windows 发行包中,CLI 的文件名为 php-cli.exe,相同文件夹下的 php.exe 为 CGI。从 PHP 4.3.0 版本开始,Windows 的发行包中 CLI 的执行文件为 php.exe,被放置在一个单独的名为 cli 的文件夹下,即 cli/php.exe。在 PHP 5 中,CLI 存在于主文件夹中,名为 php.exe,而 CGI 版本名为 php-cgi.exe

从 PHP 5 起,一个名为 php-win.exe 的新文件随包发布。它相当于 CLI 版本,但是 php-win 不输出任何内容,便不提供控制台(不会弹出“DOS 窗口”)。这种方式类似于 php-gtk。需要使用 –enable-cli-win32 选项来配置它。

Note: 如何得知自己使用的是哪个 SAPI?
在命令行下,运行 php -v 便能得知该 php 是 CGI 还是 CLI。请参考函数 php_sapi_name() 以及常量 PHP_SAPI

Note: 在 PHP 4.3.2 中加入了 Unix 的 man 页面。可以在命令行中键入 man php 来查看。

以下为 CLI SAPI 和其它 SAPI 模块相比的显著区别:

  • CGI SAPI 不同,其输出没有任何头信息。尽管 CGI SAPI 提供了取消 HTTP 头信息的方法,但在 CLI SAPI 中并不存在类似的方法以开启 HTTP 头信息的输出。CLI 默认以安静模式开始,但为了保证兼容性,-q 和 –no-header 参数为了向后兼容仍然保留,使得可以使用旧的 CGI 脚本。在运行时,不会把工作目录改为脚本的当前目录(可以使用 -C 和 –no-chdir 参数来兼容 CGI 模式)。出错时输出纯文本的错误信息(非 HTML 格式)。
  • CLI SAPI 强制覆盖了 php.ini 中的某些设置,因为这些设置在外壳环境下是没有意义的。

可以知道,php cli是从4.2.0实验性的引入,并且./configure的时候需要带参数–enable-cli。并且在服务器上我运行php -i >test.html,然后查看test.html,发现:

Configure Command ‘./configure’ ‘–host=i386-redhat-linux’ ‘–build=i386-redhat-linux’ ‘–target=i386-redhat-linux-gnu’ ‘–program-prefix=’ ‘–prefix=/usr’ ‘–exec-prefix=/usr’ ‘–bindir=/usr/bin’ ‘–sbindir=/usr/sbin’ ‘–sysconfdir=/etc’ ‘–datadir=/usr/share’ ‘–includedir=/usr/include’ ‘–libdir=/usr/lib’ ‘–libexecdir=/usr/libexec’ ‘–localstatedir=/var’ ‘–sharedstatedir=/usr/com’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘–cache-file=../config.cache’ ‘–with-config-file-path=/etc’ ‘–with-config-file-scan-dir=/etc/php.d’ ‘–enable-force-cgi-redirect’ ‘–disable-debug’ ‘–enable-pic’ ‘–disable-rpath’ ‘–enable-inline-optimization’ ‘–with-bz2′ ‘–with-db3′ ‘–with-curl’ ‘–with-dom=/usr’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–with-gd’ ‘–enable-gd-native-ttf’ ‘–with-ttf’ ‘–with-gdbm’ ‘–with-gettext’ ‘–with-ncurses’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg-dir=/usr’ ‘–with-openssl’ ‘–with-png’ ‘–with-pspell’ ‘–with-regex=system’ ‘–with-xml’ ‘–with-expat-dir=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–enable-bcmath’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-magic-quotes’ ‘–enable-safe-mode’ ‘–enable-sockets’ ‘–enable-sysvsem’ ‘–enable-sysvshm’ ‘–enable-discard-path’ ‘–enable-track-vars’ ‘–enable-trans-sid’ ‘–enable-yp’ ‘–enable-wddx’ ‘–without-oci8′ ‘–with-pear=/usr/share/pear’ ‘–with-imap=shared’ ‘–with-imap-ssl’ ‘–with-kerberos=/usr/kerberos’ ‘–with-ldap=shared’ ‘–with-mysql=shared,/usr’ ‘–with-pgsql=shared’ ‘–with-snmp=shared,/usr’ ‘–with-snmp=shared’ ‘–enable-ucd-snmp-hack’ ‘–with-unixODBC=shared’ ‘–enable-memory-limit’ ‘–enable-bcmath’ ‘–enable-shmop’ ‘–enable-versioning’ ‘–enable-calendar’ ‘–enable-dbx’ ‘–enable-dio’ ‘–enable-mcal’ ‘–enable-force-cgi-redirect’
Server API CGI

在cli下面的server api还是CGI,可以充分的肯定服务器上的php是没有cli模式的。所以我选择了自己编译一个php。

下载curl的最新源代码包:

wget http://curl.haxx.se/download/curl-7.20.1.tar.bz2
tar jxvf curl-7.20.1.tar.bz2
./configure –prefix=/home/tun/curl-7.20.1
make
make install

安装完了,看看版本:

-bash-2.05b$ /home/open/tun/curl-7.20.1/bin/curl –version
curl 7.20.1 (i686-pc-linux-gnu) libcurl/7.20.1 OpenSSL/0.9.7a zlib/1.1.4
Protocols: dict file ftp ftps http https imap imaps ldap pop3 pop3s rtsp smtp smtps telnet tftp
Features: Largefile NTLM SSL libz

下载php的最新源代码包:

wget http://cn2.php.net/distributions/php-5.3.2.tar.bz2

解压、配置、编译、安装:

-bash-2.05b$ pwd
/home/open/tun
-bash-2.05b$ tar jxvf php-5.3.2.tar.bz2
-bash-2.05b$ cd php-5.3.2
-bash-2.05b$ ./configure –prefix=./

配置加入 –prefix=./ 主要是因为我没有这台机子上面的root权限,没有办法让系统目录写文件。

结果configure包括,因为libxml版本过低,我本来打算只带cli,curl的阉割版php,所以打算将包括libxml在内的很多库都在参数中disable,将./configure改为:

./configure –prefix=./ –with-curl=/home/open/tun/curl-7.20.1 –disable-libxml –disable-dom –disable-simplexml –disable-xml –disable-xmlreader –disable-xmlwriter –without-pear –disable-cgi –disable-rpath –disable-ipv6 –disable-ctype –disable-fileinfo –disable-filter –disable-hash –disable-json –disable-mbregex –disable-mbregex-backtrack –disable-pdo –disable-phar –disable-session –disable-tokenizer
make
make install

这样php就安装好了,看看版本、扩展信息:

-bash-2.05b$ /home/open/tun/php-5.3.2/bin/php -v
PHP 5.3.2 (cli) (built: Apr 19 2010 22:36:50)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

-bash-2.05b$ /home/open/tun/php-5.3.2/bin/php -m
[PHP Modules]
Core
curl
date
ereg
iconv
pcre
posix
Reflection
SPL
SQLite
sqlite3
standard

[Zend Modules]

在来看看php.ini:

phpinfo()
PHP Version => 5.3.2

System => Linux ftpserver 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686
Build Date => Apr 20 2010 00:24:19
Configure Command =>  ‘./configure’  ‘–prefix=./’ ‘–with-curl=/home/open/tun/curl-7.20.1′ ‘–disable-libxml’ ‘–disable-dom’ ‘–disable-simplexml’ ‘–disable-xml’ ‘–disable-xmlreader’ ‘–disable-xmlwriter’ ‘–without-pear’ ‘–disable-cgi’ ‘–disable-rpath’ ‘–disable-ipv6′ ‘–disable-ctype’ ‘–disable-fileinfo’ ‘–disable-filter’ ‘–disable-hash’ ‘–disable-json’ ‘–disable-mbregex’ ‘–disable-mbregex-backtrack’ ‘–disable-pdo’ ‘–disable-phar’ ‘–disable-session’ ‘–disable-tokenizer’
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => .//lib
Loaded Configuration File => (none)
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20090626
PHP Extension => 20090626
Zend Extension => 220090626
Zend Extension Build => API220090626,NTS
PHP Extension Build => API20090626,NTS
Debug Build => no
Thread Safety => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => disabled
Registered PHP Streams => php, file, glob, data, http, ftp
Registered Stream Socket Transports => tcp, udp, unix, udg
Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

_______________________________________________________________________

Configuration

Core

PHP Version => 5.3.2

Directive => Local Value => Master Value
allow_call_time_pass_reference => On => On
allow_url_fopen => On => On
allow_url_include => Off => Off
always_populate_raw_post_data => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
asp_tags => Off => Off
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => no value => no value
default_mimetype => text/html => text/html
define_syslog_variables => Off => Off
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => STDOUT => STDOUT
display_startup_errors => Off => Off
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => On => On
error_append_string => no value => no value
error_log => no value => no value
error_prepend_string => no value => no value
error_reporting => no value => no value
exit_on_timeout => Off => Off
expose_php => On => On
extension_dir => .//lib/php/extensions/no-debug-non-zts-20090626 => .//lib/php/extensions/no-debug-non-zts-20090626
file_uploads => On => On
highlight.bg => <font style=”color: #FFFFFF”>#FFFFFF</font> => <font style=”color: #FFFFFF”>#FFFFFF</font>
highlight.comment => <font style=”color: #FF8000″>#FF8000</font> => <font style=”color: #FF8000″>#FF8000</font>
highlight.default => <font style=”color: #0000BB”>#0000BB</font> => <font style=”color: #0000BB”>#0000BB</font>
highlight.html => <font style=”color: #000000″>#000000</font> => <font style=”color: #000000″>#000000</font>
highlight.keyword => <font style=”color: #007700″>#007700</font> => <font style=”color: #007700″>#007700</font>
highlight.string => <font style=”color: #DD0000″>#DD0000</font> => <font style=”color: #DD0000″>#DD0000</font>
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => .: => .:
log_errors => Off => Off
log_errors_max_len => 1024 => 1024
magic_quotes_gpc => On => On
magic_quotes_runtime => Off => Off
magic_quotes_sybase => Off => Off
mail.add_x_header => Off => Off
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
max_execution_time => 0 => 0
max_file_uploads => 20 => 20
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
memory_limit => 128M => 128M
open_basedir => no value => no value
output_buffering => 0 => 0
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 16K => 16K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
register_globals => Off => Off
register_long_arrays => On => On
report_memleaks => On => On
report_zend_debug => Off => Off
request_order => no value => no value
safe_mode => Off => Off
safe_mode_exec_dir => /usr/local/php/bin => /usr/local/php/bin
safe_mode_gid => Off => Off
safe_mode_include_dir => no value => no value
sendmail_from => no value => no value
sendmail_path => /usr/sbin/sendmail -t -i  => /usr/sbin/sendmail -t -i
serialize_precision => 100 => 100
short_open_tag => On => On
SMTP => localhost => localhost
smtp_port => 25 => 25
sql.safe_mode => Off => Off
track_errors => Off => Off
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
variables_order => EGPCS => EGPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
y2k_compliance => On => On
zend.enable_gc => On => On

curl

cURL support => enabled
cURL Information => 7.20.1
Age => 3
Features
AsynchDNS => No
Debug => No
GSS-Negotiate => No
IDN => No
IPv6 => No
Largefile => Yes
NTLM => Yes
SPNEGO => No
SSL => Yes
SSPI => No
krb4 => No
libz => Yes
CharConv => No
Protocols => dict, file, ftp, ftps, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, smtp, smtps, telnet, tftp
Host => i686-pc-linux-gnu
SSL Version => OpenSSL/0.9.7a
ZLib Version => 1.1.4

date

date/time support => enabled
“Olson” Timezone Database Version => 2010.3
Timezone Database => internal
Default timezone => Asia/Chongqing

Directive => Local Value => Master Value
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => no value => no value

ereg

Regex Library => Bundled library enabled

iconv

iconv support => enabled
iconv implementation => glibc
iconv library version => 2.3.2

Directive => Local Value => Master Value
iconv.input_encoding => ISO-8859-1 => ISO-8859-1
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
iconv.output_encoding => ISO-8859-1 => ISO-8859-1

pcre

PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 8.00 2009-10-19

Directive => Local Value => Master Value
pcre.backtrack_limit => 100000 => 100000
pcre.recursion_limit => 100000 => 100000

posix

Revision => $Revision: 293036 $

Reflection

Reflection => enabled
Version => $Revision: 293036 $

SPL

SPL support => enabled
Interfaces => Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException

SQLite

SQLite support => enabled
PECL Module version => 2.0-dev $Id: sqlite.c 293036 2010-01-03 09:23:27Z sebastian $
SQLite Library => 2.8.17
SQLite Encoding => iso8859

Directive => Local Value => Master Value
sqlite.assoc_case => 0 => 0

sqlite3

SQLite3 support => enabled
SQLite3 module version => 0.7-dev
SQLite Library => 3.6.22

Directive => Local Value => Master Value
sqlite3.extension_dir => no value => no value

standard

Dynamic Library Support => enabled
Path to sendmail => /usr/sbin/sendmail -t -i

Directive => Local Value => Master Value
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
auto_detect_line_endings => 0 => 0
default_socket_timeout => 60 => 60
safe_mode_allowed_env_vars => PHP_ => PHP_
safe_mode_protected_env_vars => LD_LIBRARY_PATH => LD_LIBRARY_PATH
url_rewriter.tags => a=href,area=href,frame=src,form=,fieldset= => a=href,area=href,frame=src,form=,fieldset=
user_agent => no value => no value

Additional Modules

Module Name

Environment

Variable => Value
REMOTEHOST => 10.1.11.19
HOSTNAME => ftpserver
SHELL => /bin/bash
TERM => ansi
HISTSIZE => 1000
USER => open
LS_COLORS => no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
MAIL => /var/spool/mail/open
PATH => /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
INPUTRC => /etc/inputrc
PWD => /home/open/tun
LANG => en_US.UTF-8
SSH_ASKPASS => /usr/libexec/openssh/gnome-ssh-askpass
SHLVL => 1
HOME => /home/open
LOGNAME => open
LESSOPEN => |/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES => 1
_ => /home/open/tun/php-5.3.2/bin/php
OLDPWD => /home/open/tun/curl-7.20.1/bin

PHP Variables

Variable => Value
_SERVER["REMOTEHOST"] => 10.1.11.19
_SERVER["HOSTNAME"] => ftpserver
_SERVER["SHELL"] => /bin/bash
_SERVER["TERM"] => ansi
_SERVER["HISTSIZE"] => 1000
_SERVER["USER"] => open
_SERVER["LS_COLORS"] => no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
_SERVER["MAIL"] => /var/spool/mail/open
_SERVER["PATH"] => /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
_SERVER["INPUTRC"] => /etc/inputrc
_SERVER["PWD"] => /home/open/tun
_SERVER["LANG"] => en_US.UTF-8
_SERVER["SSH_ASKPASS"] => /usr/libexec/openssh/gnome-ssh-askpass
_SERVER["SHLVL"] => 1
_SERVER["HOME"] => /home/open
_SERVER["LOGNAME"] => open
_SERVER["LESSOPEN"] => |/usr/bin/lesspipe.sh %s
_SERVER["G_BROKEN_FILENAMES"] => 1
_SERVER["_"] => /home/open/tun/php-5.3.2/bin/php
_SERVER["OLDPWD"] => /home/open/tun/curl-7.20.1/bin
_SERVER["PHP_SELF"] =>
_SERVER["SCRIPT_NAME"] =>
_SERVER["SCRIPT_FILENAME"] =>
_SERVER["PATH_TRANSLATED"] =>
_SERVER["DOCUMENT_ROOT"] =>
_SERVER["REQUEST_TIME"] => 1271773084
_SERVER["argv"] => Array
(
)

_SERVER["argc"] => 0
_ENV["REMOTEHOST"] => 10.1.11.19
_ENV["HOSTNAME"] => ftpserver
_ENV["SHELL"] => /bin/bash
_ENV["TERM"] => ansi
_ENV["HISTSIZE"] => 1000
_ENV["USER"] => open
_ENV["LS_COLORS"] => no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
_ENV["MAIL"] => /var/spool/mail/open
_ENV["PATH"] => /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
_ENV["INPUTRC"] => /etc/inputrc
_ENV["PWD"] => /home/open/tun
_ENV["LANG"] => en_US.UTF-8
_ENV["SSH_ASKPASS"] => /usr/libexec/openssh/gnome-ssh-askpass
_ENV["SHLVL"] => 1
_ENV["HOME"] => /home/open
_ENV["LOGNAME"] => open
_ENV["LESSOPEN"] => |/usr/bin/lesspipe.sh %s
_ENV["G_BROKEN_FILENAMES"] => 1
_ENV["_"] => /home/open/tun/php-5.3.2/bin/php
_ENV["OLDPWD"] => /home/open/tun/curl-7.20.1/bin

PHP License
This program is free software; you can redistribute it and/or modify
it under the terms of the PHP License as published by the PHP Group
and included in the distribution in the file:  LICENSE

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact license@php.net.

然后再找一个包含$argc,$argv的脚本来测试一下,都是可以的。

看看php权限,普通用户权限:

-bash-2.05b$ ls -la /home/open/tun/php-5.3.2/bin/php
-rwxr-xr-x    1 open     open     11440897 Apr 20 01:10 /home/open/tun/php-5.3.2/bin/php