Skip to content

Instantly share code, notes, and snippets.

@dragolabs
Forked from cbmd/default.conf
Created December 24, 2013 12:38
Show Gist options
  • Save dragolabs/8112753 to your computer and use it in GitHub Desktop.
Save dragolabs/8112753 to your computer and use it in GitHub Desktop.
server {
index index.php;
set $basepath "/var/www";
set $domain $host;
# check one name domain for simple application
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";
set $servername "${domain}.dev";
}
# check multi name domain to multi application
if ($domain ~ "^(.*)\.(.[^.]*)\.dev$") {
set $subdomain $1;
set $domain $2;
set $rootpath "${domain}/${subdomain}/www/";
set $servername "${subdomain}.${domain}.dev";
}
server_name $servername;
access_log "/var/log/nginx/server.${servername}.access.log";
error_log "/var/log/nginx/server.dev.error.log";
root $basepath/$rootpath;
# check file exist and send request sting to index.php
location / {
try_files $uri $uri/ /index.php?$args;
}
# allow php only in root index.php
#location ~ "^/index\.php$" {
# allow execute all php files
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;
}
# configure phpmyadmin path
location /phpmyadmin {
root /usr/share/;
index index.php;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
# disallow access to apache configs
location ~ /\.ht {
deny all;
}
# disallow access to git configs path
location ~ /\.git {
deny all;
}
# disallow access to yii code path
location ~ /(protected|themes/classic/views)/ {
deny all;
}
}
# sudo apt-get install dnsmasq
# echo "address=/.dev/127.0.0.1" >> /etc/dnsmasq.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment