command line interface - How to execute a php file using a php5-fpm pool socket? -
i need execute php script command line, if call directly "php5 myfile.php", have security issue (mainly openbasedir restrictions , user&group rights).
so i'd execute php file same constraints fpm process (/etc/php5/fpm/pool.d/specific_process.conf). process has sock file @ /var/run/php5-fpm-specific.sock, which, believe, constrained in conf file (same user&group, php_admin_value, etc).
but can't see how can command line, , giving arguments.
i tried :
php5 --bindpath /var/run/php5-fpm-specific.sock -f /path/to/my/file.php param1 param2 but of course not work. how can ?
note: file i'm calling expects parameters (here, param1 , param2).
thank help.
you need executable cgi-fcgi (in debian part of libfcgi0ldbl package), can executing command (this 1 line \ escaping newlines, should able paste shell this):
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 you receive output, sent http server, include http headers, example script containing <?php echo "the time ", date("h:i:s");:
content-type: text/html time 13:46:35 there couple of more parameters these essential ones (see how map $_server array, that's what's happening in background):
script_namescript name seen http side. in example file have been accessed viahttp://localhost/file.phpscript_filenamelocal path script -- it's http server determine url, here need specify yourselfquery_stringcan used if want pass in after?in url, aware in shell, you'd need escape ampersand this:\&
see fastcgi example in nginx documentation more parameters.
Comments
Post a Comment