dthor
dthor

Reputation: 1877

Why would an nginx+php program not write to a file? Or why aren't source file changes reflected after reloading nginx/php7.0-fpm?

Caveat: I know nothing about PHP (I use Python3 and C#), and I have only ever used Apache.

TL;DR

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.

Background

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."

Details

nginx config:

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/;
        }
}

What I've tried

I've tried all of the below items, none of which seemed to have any effect.


So what extremely basic thing am I missing?

Upvotes: 1

Views: 911

Answers (1)

Krishna Reddy
Krishna Reddy

Reputation: 3

start the nginx in debug mode.

servie nginx-debug start.

Upvotes: 0

Related Questions