개발! 딱 깔끔하고 센스있게!

어떻게 php5 fpm 탱크 소켓을 사용하여 php 파일을 실행합니까? 본문

개발 스크랩 메모/PHP

어떻게 php5 fpm 탱크 소켓을 사용하여 php 파일을 실행합니까?

렉사이 2020. 12. 19. 22:42

나는 명령행에서 php 스크립트를 실행해야 하는데, 만약 내가 'php5 my file.phphp' (주로 openbasedir 제한과 사용자와 그룹 권한을 바로 호출할 수 있다.

따라서 fpm 프로세스와 같은 제한을 사용하여 이 php 파일 (/etc/php5/fpm/pol.d/specificu process.conf)를 실행하고 싶습니다.

이 프로세스는 / var/ run/ phpm-sppm-specific.sock, conf 파일처럼 구속을 받을 수 있을 것이라고 믿는다.

그러나 나는 명령행과 인자를 어떻게 해서 이 점을 할 것인지 모르겠다.

나는 이런 방법을 시도해 보았다:

php5 --bindpath /var/run/php5-fpm-specific.sock -f /path/to/my/file.php param1 param2 

하지만 안 되지.나 어떡하지?

주의: 내가 호출한 파일에 인자가 필요합니다.

(param1 과 param2) 입니다.

도와 주셔서 감사합니다.

대답

실행할 수 있는 cgi fcgi (libfcgi0ldbldbl 가방의 Debian 부분) 을 실행할 수 있습니다.

이 명령을 실행할 수 있습니다.

SCRIPT_NAME=/file.php \ SCRIPT_FILENAME=/path/to/my/file.php \ REQUEST_METHOD=GET \ QUERY_STRING=param1=x\¶m2=y \ cgi-fcgi -bind -connect /var/run/php5-fpm-specific.sock 

다음 출력을 받을 것입니다.

HTP 서버에 HTTP 헤드를 포함할 것입니다.

php echo '시간' ('H:i:s') 날짜:

Content-type: text/html The time is 13:46:35 

또 몇 개의 인자가 있지만, 이것은 가장 기본적인 인자입니다.

(이것들은 어떻게 $u 서버 배열에 나타날지 보시기 바랍니다):

  • SCRIPT_NAME this is the script name as it is seen from the HTTP side. In my example the file could have been accessed via http://localhost/file.php
  • SCRIPT_FILENAME this is the local path to the script -- it's what the HTTP server will usually determine from the URL, here you need to specify it yourself
  • QUERY_STRING can be used if you also want to pass in something that would be after the ? in a URL, be aware that we are in a shell, so you'd need to escape the ampersand like this: \&

다시 보기:

Comments