debian wheezy에 readline 지원 기능이 포함된 php5 설치

debian wheezy에 readline 지원 기능이 포함된 php5 설치

php5-cli는 debian wheezy에서 readline 지원을 제공하지 않습니다. 이는 대화형 PHP 셸( 다음으로 실행 $ php -a)에 프롬프트( )가 없고 php >대신 단지 말하고 Interactive mode enabled빈 줄에 커서를 남겨둔다는 의미입니다. php를 실행할 수는 있지만 어색합니다. 예를 들어 <? echo 'hi'; ?> enterctrldphp 명령을 실행하지만 확실히 readline을 지원하는 프롬프트만큼 좋지는 않습니다.

몇 가지 지침을 찾았습니다.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

원격 업그레이드

$ 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. 제가 뭘 잘못하고 있는지 아시나요? 데비안 wheezy(7)에서는 작동하지 않나요? 뎁 페이지를 클릭하세요설명에 대해서만 이야기합니다.데비안 스퀴즈(6)...

답변1

데비안에는 새로운 패키지가 있습니다:php5-readline

그냥 설치하세요(어쩌면libreadline-devphp >이전) 프롬프트를 받게 됩니다 .

답변2

나는 debian wheezy의 readline을 지원하기 위해 dotdeb php-cli를 사용하려는 시도를 포기했습니다. 대화형 셸을 사용하여 cli 모드에서 PHP를 실행하는 것이 이렇게 어려울 것이라고 누가 생각이나 했겠습니까? ? 혹시 이 문제를 해결하신 분이 계시다면 어떻게 해결하셨는지 알고 싶습니다. 답변을 여기에 게시해 주세요...

그러나 또 다른 동등한 솔루션은 Facebook의 입니다 . 이는 함수 이름 완성 및 알림 구문 강조 phpsh와 같은 몇 가지 멋진 기능을 갖춘 대화형 PHP 셸입니다 .tabtab

제가 설치한 방법은 다음과 같습니다.

$ sudo apt-get install python # this is necessary to run phpsh
$ cd ~/

$ wget https://github.com/facebook/phpsh/zipball/master
$ unzip phpsh-master.zip

$ cd phpsh-master
$ sudo cp -r src /etc/phpsh # phpsh seems to complain unless it resides at /etc/phpsh
$ sudo ln -s /etc/phpsh/phpsh /usr/bin/phpsh # put phpsh on the $PATH

보라, 어떤 디렉토리에서도 사용할 수 있다:

$ cd /etc/apt # some random dir

$ phpsh
Starting php
type 'h' or 'help' to see instructions & features
php> echo 'hi';
hi
php>

답변3

다음 패키지가 설치되어 있습니까? re2c 및 libreadline-dev

따라서 ext/readline 디렉토리의 sapi 디렉토리에 대한 심볼릭 링크를 추가해야 합니다. ln -s ../../sapi

그런 다음 readline을 다시 컴파일해 보십시오.

답변4

도트 뎁을 사용하세요. 1분 작업과 같습니다.

따르다https://www.dotdeb.org/instructions/

1, 3, 4번만 하세요(2번은 생략)

그런 다음

sudo apt-get install php5-readline

관련 정보