0

I am using the default config with Nginx installed on my manjaro machine. I just added some simple configurations down below.

nginx.conf:

user http;
worker_processes auto;
worker_cpu_affinity auto;

.....

http{
.....
    server {
        listen       9000;
        server_name  localhost;
        root   /usr/share/nginx/html/exam;
    
        location / {
            index  index.php index.html index.htm;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
        
        
            if (!-e $request_filename){
                rewrite ^/(.+)$ /index.php?url=$1 break;
            }
        }
    
        location /. {
            return 404;
        }

        location ~ \.php$ {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            include /etc/nginx/fastcgi.conf;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            include fastcgi_params;
            fastcgi_index index.php;
            fastcgi_intercept_errors on;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_read_timeout 864000;

        }
    
        location ~ /\.ht {
            deny all;
        }

    }
....
}

since the user for Nginx is http, I also changed the ownership of the folder, subfolders and files as HTTP with:

chmod -R http:http exam/

it looks like this:

1838248 lrwxrwxrwx 1 http http   42 Eyl 13 17:42 exam

but still gives 403 Forbidden on browser with this error:

 2021/09/13 17:49:22 [error] 493923#493923: *4 open() "/usr/share/nginx/html/exam/index.php" failed (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET /exam HTTP/1.1", host: "localhost:9000"

I have tried every solution I found, but it did not work.

I also tried simple PHP files that runs like "phpinfo();" even they are not working.

ersincebi
  • 41
  • 9

1 Answers1

0

I moved the project file under /srv/http and redirect the root in the conf file to it. Now it is working.

m4n0
  • 29,823
  • 27
  • 76
  • 89
ersincebi
  • 41
  • 9