1

I want my nginx to server files from my user home directory, but I keep getting error 403 forbidden.

nginx.conf

user http;
worker_processes  2;

error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {

include       mime.types;
default_type  application/octet-stream;

sendfile        on;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    server_name  localhost;
    #server_name_in_redirect off;

    root   /home/txx/http/www;

    location / {
        index  index.php index.html index.htm;
    }

    location ~ \.php$ {

        try_files $uri =404;
        fastcgi_pass unix:/var/run/php56-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

}

I have directory /home/user/http/www and all subfolders set to 775 with, and all belongs to http group.

drwxrwxr-x 10 txx http 4096 20.04.2017 19:28 www/

I've run 'chmod 755 -R www/*' 'chmod 775 -R www'

What could be this about?

6
  • 1
    You're using php-fpm, is that user also able to access the directory?
    – Seth
    Apr 26, 2017 at 11:19
  • If you're running a system that's using SELinux make sure it's either disabled using setenforce 0 or make sure that the proper context is set on the directory and the correct selinux boolean httpd_read_user_content_t and httpd_enable_homedirs Also see this post
    – Patrick
    Apr 26, 2017 at 12:14
  • @Seth I do not see user named 'php-fpm' in my system, neither a group called like this. Do you have another thought about this issue? What is curious about this 'forbidden' situation, is that it still happens even when all my directory tree is set to 777.
    – linearSpin
    Apr 27, 2017 at 9:33
  • @Patrick I do not use SELinux, I am running Chakra which is based on Arch Linux.
    – linearSpin
    Apr 27, 2017 at 9:33
  • The name of the user would depend on your PHP configuration. You're using a socket to interact with another daemon that is probably running using a different user and that user might be lacking permission to do stuff.
    – Seth
    Apr 27, 2017 at 10:47

0

You must log in to answer this question.

Browse other questions tagged .