Welcome! Log In Create A New Profile


php-fpm - Cannot display web page in user directory

David Breeding
January 12, 2020 11:32PM
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
add_header X-Debug-Script_Filename

# 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
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
#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
Subject Author Posted

php-fpm - Cannot display web page in user directory

David Breeding January 12, 2020 11:32PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready