Nginx Config for Laravel Application in sub folder
To run Laravel Application on sub folder of a web site, use following configuration. If you run Laravel application as main site, see Nginx Config for Laravel Application
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# subFolderApp1 location /subFolderApp1 { alias /home/yorudomain.com/html/subFolderApp1/public; try_files $uri $uri/ @nested1; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass unix:/run/php/php7.2-fpm-torrentp.sock; } } location @nested1 { rewrite /subFolderApp1/(.*)$ /subFolderApp1/index.php?/$1 last; } # end subFolderApp1 |
Here you place Laravel application in a subdirectory “subFolderApp1”.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
server { server_name serverok.in www.serverok.in; root /home/serverok.in/html/; index index.php index.html index.htm; client_max_body_size 1000M; proxy_read_timeout 600s; fastcgi_read_timeout 600s; fastcgi_send_timeout 600s; location / { try_files $uri $uri/ /index.php?$query_string; } # service location /service { alias /home/serverok.in/html/service/public; try_files $uri $uri/ @nested1; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass unix:/run/php/php7.2-fpm-torrentp.sock; } } location @nested1 { rewrite /service/(.*)$ /service/index.php?/$1 last; } # end service location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_intercept_errors on; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_pass unix:/run/php/php7.2-fpm-torrentp.sock; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/serverok.in/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/serverok.in/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = www.serverok.in) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = serverok.in) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name serverok.in www.serverok.in; return 404; # managed by Certbot } |