Created
April 3, 2016 16:46
-
-
Save voskobovich/d746899b1488beee69505193dfcc1d46 to your computer and use it in GitHub Desktop.
Yii2 Basic Nginx Host Config Example
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.hostname.com; | |
rewrite ^(.+)$ http://hostname.com permanent; | |
} | |
server { | |
charset utf-8; | |
client_max_body_size 128M; | |
listen 80; ## listen for ipv4 | |
server_name hostname.com www.hostname.com; | |
root /var/www/hostname.com/web; | |
index index.php; | |
access_log /var/log/nginx/hostname.com.access.log; | |
error_log /var/log/nginx/hostname.com.error.log; | |
location / { | |
# Redirect everything that isn't a real file to index.php | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# uncomment to avoid processing of calls to non-existing static files by Yii | |
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { | |
# try_files $uri =404; | |
#} | |
#error_page 404 /404.html; | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | |
if (!-f $document_root$fastcgi_script_name) { | |
return 404; | |
} | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param SCRIPT_NAME $fastcgi_script_name; | |
include fastcgi_params; | |
fastcgi_read_timeout 600s; | |
} | |
location ~ /\.(git) { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment