微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在debian wheezy上安装带有readline支持的php5

PHP5-cli没有关于debian wheezy的readline支持.这意味着交互式PHP shell(运行为$PHP -a)没有提示符(PHP>),而只是说启用了交互模式,然后将光标留在空白行.我可以执行PHP,但它很尴尬,例如<? echo'hi'; ?&GT enterctrld并且它将执行一个PHP命令,但这并不像得到readline支持提示那么好. I found some instructions通过dotdeb存储库安装带有readline支持PHP5-cli但是我得到了一半并且它给出了一个错误

下载GPG密钥

$cd /tmp
$wget http://www.dotdeb.org/dotdeb.gpg
--2013-10-13 00:12:27--  http://www.dotdeb.org/dotdeb.gpg
Resolving www.dotdeb.org (www.dotdeb.org)... 88.190.17.153
Connecting to www.dotdeb.org (www.dotdeb.org)|88.190.17.153|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5299 (5.2K) [application/octet-stream]
Saving to: `dotdeb.gpg'

100%[=====================================================================================>] 5,299       --.-K/s   in 0.005s  

2013-10-13 00:12:28 (946 KB/s) - `dotdeb.gpg' saved [5299/5299]

安装GPG密钥

$cat dotdeb.gpg | sudo apt-key add -
OK
$sudo apt-get update
Ign cdrom://[Debian GNU/Linux 7.0.0 _Wheezy_ - Official Snapshot amd64 LIVE/INSTALL Binary 20130505-10:47] wheezy Release.gpg
Ign cdrom://[Debian GNU/Linux 7.0.0 _Wheezy_ - Official Snapshot amd64 LIVE/INSTALL Binary 20130505-10:47] wheezy Release
Ign cdrom://[Debian GNU/Linux 7.0.0 _Wheezy_ - Official Snapshot amd64 LIVE/INSTALL Binary 20130505-10:47] wheezy/main amd64 Packages/DiffIndex
Ign cdrom://[Debian GNU/Linux 7.0.0 _Wheezy_ - Official Snapshot amd64 LIVE/INSTALL Binary 20130505-10:47] wheezy/main Translation-en_AU
Ign cdrom://[Debian GNU/Linux 7.0.0 _Wheezy_ - Official Snapshot amd64 LIVE/INSTALL Binary 20130505-10:47] wheezy/main Translation-en
Hit http://ftp.au.debian.org wheezy Release.gpg                                                              
Hit http://ftp.au.debian.org wheezy-updates Release.gpg                                                      
Hit http://ftp.au.debian.org wheezy Release                                                                  
Hit http://ftp.au.debian.org wheezy-updates Release                                                                           
Hit http://ftp.au.debian.org wheezy/main Sources                                                                              
Hit http://ftp.au.debian.org wheezy/main amd64 Packages                                                                       
Hit http://ftp.au.debian.org wheezy/main Translation-en                                                      
Hit http://ftp.au.debian.org wheezy-updates/main Sources                       
Hit http://ftp.au.debian.org wheezy-updates/main amd64 Packages/DiffIndex
Hit http://ftp.au.debian.org wheezy-updates/main Translation-en/DiffIndex
Hit http://packages.dotdeb.org wheezy Release.gpg
Hit http://security.debian.org wheezy/updates Release.gpg
Hit http://packages.dotdeb.org wheezy Release
Hit http://security.debian.org wheezy/updates Release
Hit http://packages.dotdeb.org wheezy/all Sources
Hit http://packages.dotdeb.org wheezy/all amd64 Packages
Hit http://security.debian.org wheezy/updates/main Sources
Hit http://security.debian.org wheezy/updates/main amd64 Packages
Hit http://security.debian.org wheezy/updates/main Translation-en
Ign http://packages.dotdeb.org wheezy/all Translation-en_AU
Ign http://packages.dotdeb.org wheezy/all Translation-en
Reading package lists... Done

disT升级

$sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

以交互模式测试PHP

$PHP -a
Interactive mode enabled

<?PHP echo 'hi'; ?>
hi$# this is not what i want!

尝试编译readline支持

$sudo aptitude install PHP5-dev libedit-dev
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

$cd ~/
$sudo apt-get source PHP5-cli
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'PHP5' as source package instead of 'PHP5-cli'
NOTICE: 'PHP5' packaging is maintained in the 'Git' version control system at:
git://git.debian.org/pkg-PHP/PHP.git
Need to get 11.8 MB of source archives.
Get:1 http://packages.dotdeb.org/ wheezy/all PHP5 5.4.20-1~dotdeb.1 (dsc) [3,425 B]
Get:2 http://packages.dotdeb.org/ wheezy/all PHP5 5.4.20-1~dotdeb.1 (tar) [11.7 MB]
Get:3 http://packages.dotdeb.org/ wheezy/all PHP5 5.4.20-1~dotdeb.1 (diff) [121 kB]                                           
Fetched 11.8 MB in 31s (374 kB/s)                                                                                             
dpkg-source: warning: extracting unsigned source package (PHP5_5.4.20-1~dotdeb.1.dsc)
dpkg-source: info: extracting PHP5 in PHP5-5.4.20
dpkg-source: info: unpacking PHP5_5.4.20.orig.tar.bz2
dpkg-source: info: unpacking PHP5_5.4.20-1~dotdeb.1.debian.tar.gz
dpkg-source: info: applying 001-libtool_fixes.patch
dpkg-source: info: applying 006-debian_quirks.patch
dpkg-source: info: applying libtool2.2.patch
dpkg-source: info: applying 019-z_off_t_as_long.patch
dpkg-source: info: applying 033-we_WANT_libtool.patch
dpkg-source: info: applying 052-PHPinfo_no_configure.patch
dpkg-source: info: applying 053-extension_api.patch
dpkg-source: info: applying 054-PHPinfo_dotdeb.patch
dpkg-source: info: applying 057-no_apache_installed.patch
dpkg-source: info: applying 100-recode_is_shared.patch
dpkg-source: info: applying 113-PHP.ini_securitynotes.patch
dpkg-source: info: applying sybase-alias.patch
dpkg-source: info: applying qdbm-is-usr_include_qdbm.patch
dpkg-source: info: applying session_save_path.patch
dpkg-source: info: applying PHP-fpm-man-section-and-cleanup.patch
dpkg-source: info: applying fpm-config.patch
dpkg-source: info: applying PHP-fpm-sysconfdir.patch
dpkg-source: info: applying temporary-path-fixes-for-multiarch.patch
dpkg-source: info: applying PHP-5.3.9-MysqLnd.patch
dpkg-source: info: applying PHP-fpm-listen-on-unix-socket.patch

$cd PHP5-5.4.20/ext/readline
$pwd
/home/peter/PHP5-5.4.20/ext/readline
$ls
config.m4  CREDITS  PHP_readline.h  readline.c  readline_cli.c  readline_cli.h  README.libedit  tests

运行PHPize

$sudo PHPize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

$pwd
/home/peter/PHP5-5.4.20/ext/readline

$ls
acinclude.m4    build         config.m4   configure.in  ltmain.sh        mkinstalldirs   readline_cli.c  run-tests.PHP
aclocal.m4      config.guess  config.sub  CREDITS       Makefile.global  PHP_readline.h  readline_cli.h  tests
autom4te.cache  config.h.in   configure   install-sh    missing          readline.c      README.libedit

配置

$sudo ./configure 
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unkNown-linux-gnu
checking host system type... x86_64-unkNown-linux-gnu
checking target system type... x86_64-unkNown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/PHP5 -I/usr/include/PHP5/main -I/usr/include/PHP5/TSRM -I/usr/include/PHP5/Zend -I/usr/include/PHP5/ext -I/usr/include/PHP5/ext/date/lib
checking for PHP extension directory... /usr/lib/PHP5/20100525
checking for PHP installed headers prefix... /usr/include/PHP5
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for libedit readline replacement... yes, shared
checking for tgetent in -lncurses... no
checking for tgetent in -ltermcap... yes
checking for readline in -ledit... yes
checking for rl_callback_read_char in -ledit... yes
checking for rl_on_new_line in -ledit... no
checking for rl_completion_matches... no
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unkNown-linux-gnu file names to x86_64-unkNown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unkNown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) nawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands

使

$sudo make
/bin/bash /home/peter/PHP5-5.4.20/ext/readline/libtool --mode=compile cc  -I. -I/home/peter/PHP5-5.4.20/ext/readline -DPHP_ATOM_INC -I/home/peter/PHP5-5.4.20/ext/readline/include -I/home/peter/PHP5-5.4.20/ext/readline/main -I/home/peter/PHP5-5.4.20/ext/readline -I/usr/include/PHP5 -I/usr/include/PHP5/main -I/usr/include/PHP5/TSRM -I/usr/include/PHP5/Zend -I/usr/include/PHP5/ext -I/usr/include/PHP5/ext/date/lib  -DHAVE_CONfig_H  -g -O2   -c /home/peter/PHP5-5.4.20/ext/readline/readline.c -o readline.lo 
libtool: compile:  cc -I. -I/home/peter/PHP5-5.4.20/ext/readline -DPHP_ATOM_INC -I/home/peter/PHP5-5.4.20/ext/readline/include -I/home/peter/PHP5-5.4.20/ext/readline/main -I/home/peter/PHP5-5.4.20/ext/readline -I/usr/include/PHP5 -I/usr/include/PHP5/main -I/usr/include/PHP5/TSRM -I/usr/include/PHP5/Zend -I/usr/include/PHP5/ext -I/usr/include/PHP5/ext/date/lib -DHAVE_CONfig_H -g -O2 -c /home/peter/PHP5-5.4.20/ext/readline/readline.c  -fPIC -DPIC -o .libs/readline.o
/bin/bash /home/peter/PHP5-5.4.20/ext/readline/libtool --mode=compile cc  -I. -I/home/peter/PHP5-5.4.20/ext/readline -DPHP_ATOM_INC -I/home/peter/PHP5-5.4.20/ext/readline/include -I/home/peter/PHP5-5.4.20/ext/readline/main -I/home/peter/PHP5-5.4.20/ext/readline -I/usr/include/PHP5 -I/usr/include/PHP5/main -I/usr/include/PHP5/TSRM -I/usr/include/PHP5/Zend -I/usr/include/PHP5/ext -I/usr/include/PHP5/ext/date/lib  -DHAVE_CONfig_H  -g -O2   -c /home/peter/PHP5-5.4.20/ext/readline/readline_cli.c -o readline_cli.lo 
libtool: compile:  cc -I. -I/home/peter/PHP5-5.4.20/ext/readline -DPHP_ATOM_INC -I/home/peter/PHP5-5.4.20/ext/readline/include -I/home/peter/PHP5-5.4.20/ext/readline/main -I/home/peter/PHP5-5.4.20/ext/readline -I/usr/include/PHP5 -I/usr/include/PHP5/main -I/usr/include/PHP5/TSRM -I/usr/include/PHP5/Zend -I/usr/include/PHP5/ext -I/usr/include/PHP5/ext/date/lib -DHAVE_CONfig_H -g -O2 -c /home/peter/PHP5-5.4.20/ext/readline/readline_cli.c  -fPIC -DPIC -o .libs/readline_cli.o
/home/peter/PHP5-5.4.20/ext/readline/readline_cli.c:54:31: Fatal error: readline/readline.h: No such file or directory
compilation terminated.
make: *** [readline_cli.lo] Error 1

正如你所看到的那样,它终止了一个致命的错误,抱怨它无法找到readline.h.知道我做错了什么吗?难道只是因为它不能用于debian wheezy(7)吗? dotdeb页面instructions only talk about debian squeeze(6)…

解决方法:

debian上有一个新包:PHP5-readline

只需安装它(可能之前安装libreadline-dev)你将拥有PHP> PROMT.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐