Created
April 4, 2014 22:41
-
-
Save Ilyes512/9984485 to your computer and use it in GitHub Desktop.
Nginx Laravel 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 { | |
listen 80; | |
server_name [www.laravel.dev]; | |
# This will redirect users from "www.laravel.dev" to "laravel.dev" | |
return 301 $scheme://[laravel.dev]$request_uri; | |
} | |
server { | |
listen 80; | |
server_name [laravel.dev] [*.laravel.dev]; # "*.laravel.dev" will allow sub-domain routing | |
root [laravel/public]; | |
index index.html index.htm index.php app.php app_dev.php; | |
access_log /var/log/nginx/[laravel.dev]/access.log; | |
error_log /var/log/nginx/[laravel.dev]/error.log; | |
charset utf-8; | |
location / { | |
try_files \$uri \$uri/ /app.php?\$query_string /index.php?\$query_string; | |
} | |
location = /favicon.ico { log_not_found off; access_log off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
error_page 404 /index.php; | |
# pass the PHP scripts to php5-fpm | |
# Note: \.php$ is susceptible to file upload attacks | |
# Consider using: "location ~ ^/(index|app|app_dev|config)\.php(/|$) {" | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# With php5-fpm: | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; | |
fastcgi_param LARA_ENV local; # Environment variable for Laravel | |
fastcgi_param HTTPS off; | |
} | |
# Deny .htaccess file access | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment