Created
June 18, 2020 20:19
-
-
Save maxcelos/f211cc129da3f22409c586b0e05367b7 to your computer and use it in GitHub Desktop.
Nginx vhost setup for laravel applications
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 { | |
# 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