Skip to content

Instantly share code, notes, and snippets.

@trungtnm trungtnm/nginx.conf forked from ashleydw/nginx.conf
Last active Oct 19, 2017

Embed
What would you like to do?
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
# remove this if need logging
#access_log /var/www/example.com/logs/access.log;
#error_log /var/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;
# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
log_not_found off;
}
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# for location of php*.sock file, look at the file /etc/php/5.6/fpm/pool.d/www.conf -> listen = ...
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; # for php 7.0
fastcgi_pass unix:/run/php/php5.6-fpm.sock; # may also be: 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.