Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jjb_official's avatar

Nginx not working even with permission of 777

I am setting up my application on a new server. I used the usual laravel nginx configuration, run chown $USER:www-data -R app and chmod 755 -R app but I kept getting file not found in the browser. After hours of debugging and searching online, I decided to uninstall nginx and re-install it. This time I created and test folder and edited the default nginx configuration to look like this

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;
        root /home/production/test;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php8.0-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
       }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

I updated the permissions on the /home/production/test folder but I still get the file not found error in the browser and stat() "/home/production/test/" failed (13: Permission denied), in the nginx error.log file. I changed the permissions to 777 but still got the same error.

The server is running Ubuntu 22.04 and nginx 1.18.0

Does anyone know how to fix this issue?

0 likes
2 replies
jjb_official's avatar

I had to add the user to the www-data group and reboot the server before it worked

Please or to participate in this conversation.