Reputation: 1877
Caveat: I know nothing about PHP (I use Python3 and C#), and I have only ever used Apache.
I can't figure out why this PHP code refuses to write to a bloody file and why reloading nginx/php7.0-fpm will not reflect the changes made to the file.
I have been "gifted" an in-house program that was written in PHP7 and runs on Nginx, Ubuntu 16.04.4 (terminal only). This program does not have a web UI, and only exists to handle HTTP GET and PUT requests. Said program is not running as expected and I'm trying to debug why. However, it appears that any changes I make to the PHP code do not get reflected in the behavior.
Basically I want to set up some kind of logging - write to nginx logs, write to a file, send an email, anything - so that I can find out where things are failing. Then I can report things properly to the people who know instead of just saying "Program no work. You fix."
/var/www/servername
.upstream php { server unix:/run/php/php70-fpm.sock; }
server {
server_name 192.168.11.80;
root /var/www/servername/public/;
rewrite ^/$ /index.php;
rewrite ^/\$metadata$ /metadata.xml;
rewrite ^/Search\(\)/\$count$ /count.php;
rewrite ^/Search\(\)$ /search.php;
rewrite ^/Packages\(\)$ /search.php;
rewrite ^/Packages\(Id='([^']+)',Version='([^']+)'\)$ /findByID.php?id=$1&version=$2;
rewrite ^/GetUpdates\(\)$ /updates.php;
rewrite ^/FindPackagesById\(\)$ /findByID.php;
rewrite ^//?download/([^/]+)/([^/]+)$ /download.php?id=$1&version=$2;
rewrite ^/([^/]+)/([^/]+)$ /delete.php?id=$1&version=$2;
rewrite ^/api/v2/package/$ /index.php;
rewrite ^/api/v2/package/([^/]+)/([^/]+)$ /delete.php?id=$1&version=$2;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php;
}
location = /index.php {
dav_methods PUT DELETE;
include fastcgi_params;
fastcgi_pass php;
# PHP doesn't parse request body for PUT requests, so fake a POST.
fastcgi_param REQUEST_METHOD POST;
fastcgi_param HTTP_X_METHOD_OVERRIDE $request_method;
}
# Used with X-Accel-Redirect
location /packagefiles {
internal;
root /var/www/servername/;
}
}
I've tried all of the below items, none of which seemed to have any effect.
file_put_contents
. For some reason, this just doesn't work.
file_put_contents('php://stderr', 'TESTING');
does not append anything to the nginx log files /var/log/nginx/[access|error].log
file_put_contents('/var/log/sns/debug.log, 'TESTING');
also does not write to the debug.log
file
/var/log/sns
folder has 777 permissions.die()
.sudo service php7.0-fpm restart & sudo service nginx restart
based off this answer./var/log/php7.0-fpm.log
only has the startup/shutdown notices ("fpm is running", "read to handle connections", "terminating", etc.)/var/log/nginx/access.log
correctly shows all the GET and PUT requests, but nothing else/var/log/nginx/error.log
only shows the "Using xKiB of shared memory" (the startup info).index.php
and then restarting nginx & php7.0-fpm - somehow the program still works!error_log('msg', 3 '/var/log/sns/debug.log')
, file_put_contents(...)
, and die()
and then completely rebooting the server. Still doesn't write to a file.So what extremely basic thing am I missing?
Upvotes: 1
Views: 911