php-fpm - Cannot display web page in user directory

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

php-fpm - Cannot display web page in user directory

David Breeding
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. 

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx