Last active
March 18, 2019 04:20
-
-
Save alfianmalik/8b26e81006f37111469c3c065a570616 to your computer and use it in GitHub Desktop.
PHP Apps (Laravel) in a Subdirectory in Nginx
This file contains hidden or 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
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/top/public; | |
index index.html index.htm index.php; | |
server_name _; | |
location / { | |
try_files $uri $uri/ /index.php$is_args$args; | |
} | |
location /nested { | |
alias /var/www/nested/public; | |
try_files $uri $uri/ @nested; | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
} | |
} | |
location @nested { | |
rewrite /nested/(.*)$ /nested/index.php?/$1 last; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
} | |
} |
This file contains hidden or 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
server { | |
listen 80; | |
root /home/alfian/Projects/api.account; | |
index index.php index.html index.htm; | |
server_name accounts.mynurz.local; | |
location / { | |
try_files $uri $uri/ /index.php$is_args$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
#fastcgi_pass unix:/run/php/php7.1-fpm.sock; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
# version 1 | |
location ^~ /personal { | |
alias /home/alfian/Projects/api.account/personal/public; | |
try_files $uri $uri/ @personal; | |
location ~* \.php { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
include /etc/nginx/fastcgi_params; | |
} | |
} | |
location @personal { | |
rewrite ^/personal/(.*)$ /personal/index.php/$1 last; # THIS IS THE IMPORTANT LINE | |
} | |
# end version 1 | |
# version 2 | |
location ^~ /provider { | |
alias /home/alfian/Projects/api.account/provider/public; | |
try_files $uri $uri/ @provider; | |
location ~* \.php { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
include /etc/nginx/fastcgi_params; | |
} | |
} | |
location @provider { | |
rewrite ^/provider/(.*)$ /provider/index.php/$1 last; # THIS IS THE IMPORTANT LINE | |
} | |
# end version 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment