折腾mediawiki千百遍,终于在nginx下成功设置了短网址
运行环境:
主机:阿里云ECS CentOS 6.5
服务器:nginx 1.9.12
语言:PHP 7.0.3
软件:mediawiki 1.27.1
server {
listen 80;
server_name wiki.mmhub.cn;
access_log /path/to/wiki.mmhub.cn_nginx.log combined;
index index.html index.htm index.php;
root /path/to/mywiki;
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location / {
index index.php;
error_page 404 = @mediawiki;
}
location @mediawiki {
rewrite ^/wiki([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}
}
nginx设置代码如上
LocalSettings.php文件设置如下
$wgScriptPath = ""; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
折腾到底,还是弄好了。