php - shell_exec를 사용하여 쉘 명령 실행

php - shell_exec를 사용하여 쉘 명령 실행

저는 서버(centos)에서 "shell_exec"를 실행하기 위해 ajax 호출을 사용하고 있습니다. 내가 실행하는 라인은 다음과 같습니다

echo shell_exec("php -q /websockets/timedactions.php");

서버 응답은 다음과 같습니다.

X-Powered-By: PHP/5.5.16
Access-Control-Allow-Origin: http://myIpAddress
Access-Control-Allow-Credentials: true
Content-type: text/html

이 명령을 실행한 후 활성화해야 하는 프로세스가 실행되고 있지 않은 것 같습니다.

루트 액세스 권한으로 쉘에서 동일한 명령 호출

php -q /websockets/timedactions.php

완벽하게 작동합니다.

shell_exec를 사용하여 스크립트를 작동시키려면 어떻게 해야 합니까?

더 많은 정보:

ps aux | grep httpd | awk '{print $1}' = nobody


sestatus|grep enforcing = {no result}


file permissions -rwxr-xr-x 1 root root 


ls -lZ timedactions.php -rwxr-xr-x root root ? timedactions.php*

답변1

그럼 알았어 그럼

대답은 매우 쉬웠던 것 같습니다(실망스러울 수도 있습니다 :-)) 방금 PHP에 대한 전체 경로를 추가했습니다. 이전에 오류가 발생하지 않은 이유와 작동하는 이유를 잘 모르겠습니다(설명할 수 있는 사람이 있는 경우).

shell_exec('/usr/local/bin/php -q /websockets/timedactions.php /dev/null 2>&1 &');

노력해주셔서 감사합니다...

관련 정보