string exec ( string$command
[, array&$output
[, int&$return_var
]] );
php exec 로 명령어를 실행했을때 $return_var 값이 127 이 나왔다.
쉘상으로는 정상적으로 실행되는 명령어인대 실행이 되지 않는다.
관련 답변을 찾다가 아래의 글을 찾았다.
http://gallery.menalto.com/node/2639#comment-8638
exec() returns 127 no matter what I do
I had gallery 1.3.2 working as well as my own working php scripts that used exec, then I upgraded apache and php now all exec calls return 127.
I'm using PHP Version 4.2.3. I just did a rebuild with debug and some other "enable"s on but it didn't help. Here is my php info:
System OpenBSD 3.2 GENERIC#0 i386
Build Date Dec 17 2002 19:15:56
Configure Command './configure' '--with-apxs=/usr/sbin/apxs' '--without-mysql' '--without-xml' '--enable-cli' '--with-iconv=/usr/local' '--with-gettext=/usr/local' '--enable-dio' '--without-pear' '--enable-bcmath' '--enable-session' '--enable-trans-sid' '--enable-calendar' '--enable-ctype' '--enable-ftp' '--with-pcre-regex' '--with-posix' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-yp' '--with-recode=/usr/local' '--enable-shared' '--enable-debug' '--with-config-file-path=/var/www/conf' '--enable-inline-optimization' '--with-pic' '--with-openssl' '--with-zlib' '--prefix=/usr/local' '--sysconfdir=/etc'
Server API Apache
Virtual Directory Support disabled
Configuration File (php.ini) Path ..path/php.ini
Debug Build yes
Thread Safety disabledAnd here is what happens when I try to upload an image:
Processing status...
- Adding paranoia.jpgExecuting:
..path/jpegtopnm ..path/albums/test/aal.jpg | ..path/pnmscale -xysize 150 150 | ..path/pnmtojpeg --quality=95 > ..path/albums/test/aal.thumb.jpg
Results:
none
Error messages:
Status: 127 (expected 0)
Error: Unable to make thumbnail (0)!I tried the command by hand and it will resize images no problem. I noticed in the FAQ a mention of "exec() returns 127 no matter what I do" but it didn't mention how to fix this other than don't use "--enable-sigchild" which I don't think I do. Any ideas?
I found the problem. The problem was my security-paranoid OpenBSD. When upgrading from 3.1 to 3.2 they added:
- Apache runs chroot'd by default. To disable this, see the new -u option.
The chroot prevented Apache from accessing anything outside of a directory, so I moved everything into the apache directory including netpbm. Everything was accessible and executable, but I guess it was still in some sort of "safe mode" because the exec() always returned 127.
Anyway, running httpd with the -u option went back to the less secure non chroot'd apache startup, which allowed the exec() to work again.
'Story > php' 카테고리의 다른 글
window 에서 php fgetcsv 사용시 한글문제 (0) | 2012.12.10 |
---|---|
디바이스별 viewport 설정 (0) | 2012.11.29 |
php gd image crop 투명 배경 이미지 잘라내기 (0) | 2012.03.30 |
올더게이트 결제모듈 연동 (0) | 2012.03.22 |
쇼핑몰 작업시 오픈마켓 상품노출방법 (0) | 2012.03.08 |