Created
January 23, 2014 02:28
-
-
Save hieubuiduc/8571777 to your computer and use it in GitHub Desktop.
Laravel 4 Nginx Configuration
This file contains 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 { | |
# Port that the web server will listen on. | |
listen 80; | |
# Host that will serve this project. | |
server_name laravel.com; | |
# The location of our projects public directory. | |
root /var/www/laravel.com/public/; | |
# Point index to the Laravel front controller. | |
index index.html index.php; | |
# Useful logs for debug. | |
access_log /var/www/laravel.com/logs/access.log; | |
error_log /var/www/laravel.com/logs/error.log; | |
rewrite_log on; | |
location / { | |
# URLs to attempt, including pretty ones. | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# Remove trailing slash to please routing system. | |
if (!-d $request_filename) { | |
rewrite ^/(.+)/$ /$1 permanent; | |
} | |
# Security: disbale upload file html, htm, shtml,php | |
location ~* ^/uploads/.*.(html|htm|shtml|php)$ { | |
types { } | |
default_type text/plain; | |
} | |
# Disable logging file robots.txt, favicon.ico | |
location = /robots.txt { access_log off; log_not_found off; } | |
location = /favicon.ico { access_log off; log_not_found off; } | |
# PHP FPM configuration. | |
location ~ \.php$ { | |
try_files $uri =404; | |
include fastcgi_params; | |
fastcgi_pass 127.0.0.1:9000; | |
#fastcgi_pass unix:/var/run/php-main.socket; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
#Prevent version info leakage | |
fastcgi_hide_header X-Powered-By; | |
} | |
# 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