Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

673
Visualizações
PHP 7.4, NGINX, Laravel 8 - only shows index page, all routes show 404

I have put a Laravel 8 application on a AWS t2.nano Linux AMI ec2 instance. I would like to start up front by saying I have been at this for about a day now. I have tried a few configurations.

Here's some configurations I have tried:

  1. The default nginx config file from the Laravel 8 documentation https://laravel.com/docs/8.x/deployment#nginx

  2. Another very similar stackoverflow question referenced here Laravel on nginx says 404 for all routes except index

At the end of the day, I cannot get it to work properly. My index page loads, but any of the other routes end up at a 404 page. You can view the application here. https://technology.dvemedia.com/

So here are some tech specs and the current state of my conf file.

  • Laravel - 8
  • PHP - 7.4
  • NGINX - 1.12.2
# HTTP
server {
    listen 80;
    listen [::]:80;
    server_name technology;
    return 301 https://$host$request_uri; # Redirect to www
}

server {

     listen 80;
    listen [::]:80;
    server_name technology.dvemedia.com;

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

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

}

What am I missing or doing wrong, because I cannot get it to route to save my life.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Try this:

## Nginx php-fpm Upstream
upstream dvemedia {
    server unix:/var/run/php/php7.4-fpm.sock;
}

## Web Server Config
server
{
    ## Server Info
    listen 80;
    listen [::]:80;
    server_name technology.dvemedia.com;
    root /var/www/html/technology/public;
    index index.html index.php;
    
    ## DocumentRoot setup
    location / {
        try_files $uri $uri/ @handler;
        expires 30d;
    }
    
    ## Disable .htaccess and other hidden files
    location  /. {
        return 404;
    }
 
    ## Rewrite all request to index
    location @handler {
        rewrite / /index.php;
    }
 
    ## Execute PHP scripts
    location ~ \.php$ {
        try_files $uri = 404;
        expires          off;
        fastcgi_pass     dvemedia;
        fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include          fastcgi_params;
    }
}

and put all your optimisation/tweaks (like fastcgi_buffers ...) in fastcgi_params file

over 4 years ago · Santiago Trujillo Relatório

0

I made a bad assumption by thinking my php-fpm socket would stay the same. After looking at the directory structure, my socket for 7.4 ended up being here.

fastcgi_pass unix:/var/run/php-fpm/www.sock;

That actually fixed it and everything worked. I gave bad information when I wrote the path for my socket was actually this.

fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

@Latheesan answer would most likely have worked had I had given the correct information, minus the spelling mistake of course.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda