Skip to content

Instantly share code, notes, and snippets.

@aristidesneto
Created November 18, 2017 22:34
Show Gist options
  • Save aristidesneto/e0b7af91a7275d634d9f6e55ec8d3237 to your computer and use it in GitHub Desktop.
Save aristidesneto/e0b7af91a7275d634d9f6e55ec8d3237 to your computer and use it in GitHub Desktop.
Configuração de site Nginx
server {
# Port that the web server will listen on.
listen 80;
listen [::]:80;
# Host that will serve this project.
server_name localhost;
# Useful logs for debug.
access_log /var/log/nginx/localhost_access.log;
error_log /var/log/nginx/localhost_error.log;
rewrite_log on;
# The location of our projects public directory.
root /usr/share/nginx/html;
# Point index to the Laravel front controller.
index index.php index.html;
location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# PHP FPM configuration.
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# We don't need .ht files with nginx.
location ~ /\.ht {
deny all;
}
# Set header expirations on per-project basis
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