Skip to content

Instantly share code, notes, and snippets.

@agkairos
Created February 28, 2020 15:46
Show Gist options
  • Save agkairos/80dede0fc2fd7b85673f44b9fff918ff to your computer and use it in GitHub Desktop.
Save agkairos/80dede0fc2fd7b85673f44b9fff918ff to your computer and use it in GitHub Desktop.
Publicar Laravel em subpasta nginx php7.2 php-fpm
server {
listen 80;
root /var/www/html;
index index.php index.html;
server_name www.domain.com domain.com;
access_log on;
error_log /var/log/nginx/error.log error;
# Local do projeto projeto1
location /projeto1 {
alias /var/www/html/projeto1/public;
try_files $uri $uri/ @projeto1;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
# Rewrite projeto projeto1
location @projeto1 {
rewrite /projeto1/(.*)$ /projeto1/index.php?/$1 last;
}
# Local do projeto projeto2
location /projeto2 {
alias /var/www/html/projeto2/public;
try_files $uri $uri/ @projeto2;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
# Rewrite projeto projeto2
location @projeto2 {
rewrite /projeto2/(.*)$ /projeto2/index.php?/$1 last;
}
location / {
try_files $uri $uri/ =404;
# try_files $uri $uri/ /index.php?$query_string
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.well-known {
allow all;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment