Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

666
Views
PHP 7.4, NGINX, Laravel 8: solo muestra la página de índice, todas las rutas muestran 404

He puesto una aplicación Laravel 8 en una instancia AWS t2.nano Linux AMI ec2. Me gustaría comenzar diciendo que he estado en esto durante aproximadamente un día. He probado algunas configuraciones.

Aquí hay algunas configuraciones que he probado:

  1. El archivo de configuración nginx predeterminado de la documentación de Laravel 8 https://laravel.com/docs/8.x/deployment#nginx

  2. Otra pregunta de stackoverflow muy similar a la que se hace referencia aquí Laravel en nginx dice 404 para todas las rutas excepto el índice

Al final del día, no puedo hacer que funcione correctamente. Mi página de índice se carga, pero cualquiera de las otras rutas termina en una página 404. Puedes ver la aplicación aquí. https://tecnología.dvemedia.com/

Aquí hay algunas especificaciones técnicas y el estado actual de mi archivo conf.

  • 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; } }

¿Qué me estoy perdiendo o haciendo mal, porque no puedo enrutarlo para salvar mi vida?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Prueba esto:

 ## 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; } }

y coloque todas sus optimizaciones/ajustes (como fastcgi_buffers ...) en el archivo fastcgi_params

over 4 years ago · Santiago Trujillo Report

0

Hice una mala suposición al pensar que mi socket php-fpm permanecería igual. Después de mirar la estructura del directorio, mi socket para 7.4 terminó aquí.

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

Eso realmente lo arregló y todo funcionó. Di mala información cuando escribí que la ruta para mi socket era en realidad esta.

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

La respuesta de @Latheesan probablemente habría funcionado si hubiera dado la información correcta, menos el error de ortografía, por supuesto.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!