Skip to content

Instantly share code, notes, and snippets.

@maxcelos
Created June 18, 2020 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxcelos/f211cc129da3f22409c586b0e05367b7 to your computer and use it in GitHub Desktop.
Save maxcelos/f211cc129da3f22409c586b0e05367b7 to your computer and use it in GitHub Desktop.
Nginx vhost setup for laravel applications
server {
# Porta WEB
listen 80;
listen [::]:80;
# Nome do servidor
server_name example.com;
# Diretorio de Log
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
rewrite_log on;
# Diretorio dos arquivos web
root /var/www/apps/seu_app/public;
# Extensões de arquivos que serão lidos
index index.php index.html;
client_max_body_size 128M;
# URL amigáveis
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Configurações PHP FPM.
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# Bloqueia arquivo com .ht (Nginx não utiliza o .htaccess como o Apache)
location ~ /\.ht {
deny all;
}
# Configura cache das extensões abaixo para expirar em 365 dias
location ~* \.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ {
expires 365d;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment