Last active
December 26, 2018 06:21
-
-
Save priatmoko/4c18622599c680322b2dc0f9ad4d6c8e to your computer and use it in GitHub Desktop.
NginX Configuration for removing public and index, laravel in sub directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The are a lot of methods to separate configuration of laravel in nginx. It is only one of them but not the best. | |
#Configuration for removing public and index in laravel or lumen that run on nginX | |
#This configuration implemented in ubuntu server | |
#We can copy this code directly to "/etc/nginx/site-enabled/default" | |
#or you can separate this file, to reduce complexity / large code in file "/etc/nginx/site-enabled/default" | |
#directory name | |
location /dir { | |
#we point the alias to the lavel public directory | |
#project root | |
alias /var/www/dir/public; | |
#calling the location defined below | |
try_files $uri $uri/ @dir_location; | |
#PHP configuration | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; | |
} | |
} | |
#define location | |
location @dir_location { | |
rewrite /dir/(.*)$ /dir/index.php?/$1 last; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment