I have a php script hook.php
and is located at /var/utils
and the content is to print
<?php
echo "To be print.";
My nginx config is this.
server {
listen 8322;
server_name docs.com;
location /hook.php {
root `/var/utils`;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
When I try to execute it using docs.com:8322/hook.php
in a browser it won't print anything. When I tried executing it through cli $ php hook.php
it will print something. Net stat shows that my php-fpm is running in port 9000
What am I missing here?
Thanks!
UPDATE
The solution was too add fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
in the nginx config
server {
listen 8322;
server_name docs.com;
location /hook.php {
root `/var/utils`;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
[CLOSED]
You can try this:
sitename.com/script.php?f=your_function_name
in your script.php
file;
if(function_exists($_GET['f'])) {
$_GET['f']();
}
The solution was too add fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; in the nginx config
server {
listen 8322;
server_name docs.com;
location /hook.php {
root `/var/utils`;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.