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

3Descape's avatar

Nginx gives 404 not found

hello everybody. I am totally new to setting up a server with laravel. I have bought a server from digitalocean with lemp and can't get it to work, as I always get a 404 Not found with my laravel project, while the default index.html works fine. I have to note though, that I updated php to 7.1 with those commands https://ayesh.me/Ubuntu-PHP-7.1. Maybe someone can provide a step by step introduction on how to set up a server with digital ocean and laravel 5.5. I would be so grateful after more than 6 hours of frustration.

In the var/log/nginx/error.log file I saw the following error: 2017/10/05 19:37:57 [crit] 32391#32391: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 62.46.56.193, server: localhost, request: "GET / HTTP/1.1", upstream: "fas$

My /etc/nginx/sites-enabled/digitalocean file

# You may add here your
# server {
#       ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

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

        root /var/www/html/Maturamanager/public;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php$is_args$args;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

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


# another virtual host using mix of IP-, name-, and port-based configuration
0 likes
2 replies
ejdelmonico's avatar
Level 53

You should have used Laravel Forge and it is well worth the small monthly fee. Anyway, one your problems is the nginx config is calling for php7.0-fpm.sock and you stated you upgraded to php 7.1. If that is true, you need to use php7.1-fpm.sock.

You should have:

location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

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

Please or to participate in this conversation.