Directory Aliasing on nginx

last few day, i migrated web server from apache to nginx. Not a big problem when i configuring php with nginx, but the main problem is, how to configuring alias directory in nginx ?.

on apache, configuring alias directory is quite simple, like this :


Alias /wiki "/usr/local/www/mediawiki"
<Directory /usr/local/www/mediawiki>
Options FollowSymLinks
AllowOverride None
order deny,allow
deny from all
allow from xxxxxxx/y
</Directory>

but, in nginx ?  harder than using apache :D. Here’s example how to enabling alias directory in nginx

location /wiki {
alias //usr/local/www/mediawiki;
index index.php;
}
location ~ /wiki/.*\.php$ {
if ($fastcgi_script_name ~ /wiki(/.*\.php)$) {
set $valid_fastcgi_script_name $1;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/mediawiki$valid_fastcgi_script_name;
include fastcgi_params;
}

save nginx.conf and restart nginx.

done! :p

Advertisements