php-fpm - Cannot display web page in user directory

David Breeding db388696 at gmail.com
Mon Jan 13 04:31:39 UTC 2020


I don't believe this is an nginx problem,  (I think it's somewhere in the
php end) but don't know where to turn.  Hopefully since nginx seems to be
tied closely with php-fpm, someone her might be able to point me in the
right direction.

I'm experimenting with nginx on an Arch system.  I'm able to get pages from
document-Root for both static and php pages.  I can get static page from
User directory, but cannot get php page from there.  Here is  the location
block for this part.

--------------------- Begin Code -----------------------

        location ~ ^/~(.+)(/.+\.php)(.*)? {
            alias          /home/$1/public_html;
            fastcgi_split_path_info (/[^/]+\.php)(.*)?$;

            # Shows /home/user/public_html
            add_header X-Debug-Document-Root $document_root;

            #next two = /~user/public_html
            add_header X-Debug-Document-Uri $document_uri;
            add_header X-Debug-Request-uri $request_uri;

            # Shows /hello.php
            add_header X-Debug-script-name $fastcgi_script_name;

            # Does not display
            add_header X-Debug-path-info $fastcgi_path_info;

            # This displays exactly correct path. I can copy and
            # paste this path after "ls -l" on command line and list the
file
            add_header X-Debug-Script_Filename
$document_root$fastcgi_script_name;

            # Displays /~user/hello.php
            add_header X-Debug-uri $uri;

            # This doesn't return error error
            if (!-f $document_root$fastcgi_script_name) {
                return 404;
            }
            # This line causes Error 404 "File Not Found".
            # Without it -  ReturnsStatus code 200 with blank page
(expected result)
            # Hard-coding path here still produces Error 404
            # Hard-coding path to file in Document Root and it displays
correctly.
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME
$document_root$fastcgi_script_name;
            #include        fastcgi_params;
            return 200;    # To cause headers to show
        }

------------------------------------ End code --------------------------
 It almost seems to be some kind of permission problem, but everything from
/home down to the files in 'public_html' have read permissions for all
entitities set, and again, static files in this folder are read and
rendered.  I tried to find out if php needed any settings to allow reading
outside document_root, but could not find anything.

Probably something stupidly simple, but if anyone can tell me what I'm
doing wrong or missing, I'd appreciate it greatly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20200112/35e3958a/attachment.htm>


More information about the nginx mailing list