I have a running nginx server with php5-fpm on a debian wheezy. I want /var/www/devel/
to be my development folder served at http://devel.example.com
. In this directory I have multiple projects like /proj-1/
/proj-2/
/proj-2/
etc. - some of them need to use Wordpress.
Now with every folder containing Wordpress I realised I have to add a separate location (marked as ##SPE-LOC##
in the following config) to enable rewrite aka pretty permalinks.
The config works, but what bothers me is, that I have to add the separate location for all the folders with Wordpress in them. How can I avoid those repeating blocks?
My nginx config:
server {
listen 80;
server_name devel.example.com;
root /var/www/devel;
index index.html index.php;
# Default location
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
##SPEC-LOC##
location /proj-1 {
try_files $uri $uri/ /proj-1/index.php?q=$uri&$args;
}
##SPEC-LOC##
location /proj-3/blog {
try_files $uri $uri/ /proj-3/blog/index.php?q=$uri&$args;
}
# PHP
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files
location ~ /\.ht {
deny all;
}
}