Dokuwiki在Apache上安装很简单,这里说说在Nginx的设置。
一、禁止Dokuwiki敏感目录的访问
在Apache下,因为各目录下的.htaccess文件已经设置好了,所以无需任何修改就可以用,但是Nginx下不仅要禁止目录访问,还要加密目录,否则输入文件名依然可以下载。加密目录的方法请参看LNMP下为Nginx目录设置访问验证的用户名密码。下面是配置文件。
location ^~ /conf/ { deny all; auth_basic "Authorized users only"; auth_basic_user_file 验证文件路径; } location ^~ /data/ { deny all; auth_basic "Authorized users only"; auth_basic_user_file 验证文件路径; } location ^~ /inc/ { deny all; auth_basic "Authorized users only"; auth_basic_user_file 验证文件路径; } location ^~ /bin/ { deny all; auth_basic "Authorized users only"; auth_basic_user_file 验证文件路径; }
location ^~ /conf/
{
deny all;
auth_basic "Authorized users only";
auth_basic_user_file 验证文件路径;
}
location ^~ /data/
{
deny all;
auth_basic "Authorized users only";
auth_basic_user_file 验证文件路径;
}
location ^~ /inc/
{
deny all;
auth_basic "Authorized users only";
auth_basic_user_file 验证文件路径;
}
location ^~ /bin/
{
deny all;
auth_basic "Authorized users only";
auth_basic_user_file 验证文件路径;
}
二、Nginx下配置Dokuwiki伪静态
安装在根目录下的配置文件:
rewrite ^(/)_media/(.*) $1lib/exe/fetch.php?media=$2 last; rewrite ^(/)_detail/(.*) $1lib/exe/detail.php?media=$2 last; rewrite ^(/)_export/([^/]+)/(.*) $1doku.php?do=export_$2&id=$3 last; location / { if (!-f $request_filename) { rewrite ^(/)(.*)?(.*) $1doku.php?id=$2&$3 last; rewrite ^(/)$ $1doku.php last; } }
rewrite ^(/)_media/(.*) $1lib/exe/fetch.php?media=$2 last;
rewrite ^(/)_detail/(.*) $1lib/exe/detail.php?media=$2 last;
rewrite ^(/)_export/([^/]+)/(.*) $1doku.php?do=export_$2&id=$3 last;
location /
{
if (!-f $request_filename)
{
rewrite ^(/)(.*)?(.*) $1doku.php?id=$2&$3 last;
rewrite ^(/)$ $1doku.php last;
}
}
--转自