Config nginx for Laravel In a subfolder

后端 未结 7 697
失恋的感觉
失恋的感觉 2020-12-14 18:28

I have and old project that now requires new functionality, I\'m going to use laravel to provide it, everything in working ok in xampp with apache but my server con nginx sh

相关标签:
7条回答
  • 2020-12-14 19:19

    after I spend some hours on this issue, finally I could fixed my site with a subdomain address :

    If you want to put your laravel project in a subfolder on a server with ngnix-ubuntu 16-php.7.2, so here is update ngnix config :

    1) your nested(subfolder) isn't inside your main folder

    /var/www/main:
    /var/www/nested:
    

    then your config :

    location /nested {
    
            alias /var/www/nested/public;
    
            try_files $uri $uri/ @nested;
    
                   location ~ \.php$ {
                            include fastcgi_params;
                            fastcgi_param SCRIPT_FILENAME $request_filename;
                            fastcgi_pass   unix:/run/php/php7.2-fpm.sock;
    
                                    }
       }
    
    location @nested {
            rewrite /nested/(.*)$ /nested/index.php?/$1 last;
    }
    

    2) The laravel-test folder (subfolder) inside the main folder :

    /var/www/main:
    /var/www/main/nested:
    

    then your config :

    location /laravel-test {
    
        alias /var/www/main/laravel-test/public;
    
        try_files $uri $uri/ @laravelTest;
    
               location ~ \.php$ {
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                        fastcgi_pass   unix:/run/php/php7.2-fpm.sock;
    
                                }
    
    
      }
    
    location @laravelTest {
            rewrite /laravel-test/(.*)$ /laravel-test/index.php?/$1 last;
    }
    
    0 讨论(0)
提交回复
热议问题