Laravel routes not found after nginx install

前端 未结 6 789
失恋的感觉
失恋的感觉 2020-12-24 02:17

After I changed ICG to nginx all routes except index page does not work.

Laravel Config:

#/etc/nginx/sites-enabled/laravel
server {
    listen 80;

          


        
6条回答
  •  萌比男神i
    2020-12-24 02:52

    This is the correct basic config for Laravel and Nginx:

    server {
        listen   80 default_server;
    
        root /var/www/laravel/public/;
        index index.php index.html index.htm;
    
        location / {
             try_files $uri $uri/ /index.php$is_args$args;
        }
    
        # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
    }
    

    EDIT: Instead of:

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    

    As of November 2018, as PHP 7.2 is out, it would be:

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

提交回复
热议问题