Skip to content

Instantly share code, notes, and snippets.

@richardkall
Last active December 16, 2015 07:18
Show Gist options
  • Save richardkall/5397279 to your computer and use it in GitHub Desktop.
Save richardkall/5397279 to your computer and use it in GitHub Desktop.
Nginx + PHP5
charset utf-8;
gzip_disable "msie6";
gzip_types text/plain text/css application/x-javascript application/xml text/javascript;
# www.example.com
server {
listen 80;
server_name *.example.com;
rewrite ^(.*) http://example.com$1 permanent;
}
# example.com
server {
listen 80;
server_name example.com;
index index.php index.html;
root /var/www/example.com/html;
access_log /var/www/example.com/logs/access.log;
error_log /var/www/example.com/logs/error.log;
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
# Deny access to hidden files
location ~ /\. {
deny all;
}
# Remove index.php from URLs
location / {
try_files $uri $uri/ /index.php?$args;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment