Skip to content

Instantly share code, notes, and snippets.

@viirre
Last active August 29, 2015 13:58
Show Gist options
  • Save viirre/10298205 to your computer and use it in GitHub Desktop.
Save viirre/10298205 to your computer and use it in GitHub Desktop.
Default Nginx vhost
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
try_files $uri $uri/ /index.php?$args;
}
location /phpmyadmin {
root /usr/share;
index index.php index.html index.htm;
allow 81.229.83.83;
deny all;
proxy_read_timeout 300;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# pass the PHP scripts to FastCGI server listening on /tmp/php5-fpm.sock
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment