我有一个 Mediawiki 农场,除图像显示外,一切正常。图像上传的工作原理是将它们与拇指一起放入正确的文件夹中,但图像不会显示。不过,我想继续在站点根目录之外托管图像。
Mediawiki 安装在:/var/www/mediawiki
图像文件夹位于:/var/cats.wiki/images
我的 nginx 配置是:
server {
listen 80;
server_name cats.wiki; #made up name for example
root /var/www/mediawiki;
client_max_body_size 100M;
location /images {
alias /var/cats.wiki/images; #relevant part
}
location / {
index index.php;
error_page 404 = @mediawiki;
}
location @mediawiki {
rewrite ^/w([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MW_INSTALL_PATH /var/www/mediawiki;
fastcgi_param WIKI_PATH "catwiki.php";
}
location ~* \.(js|css|svg|png|jpg|jpeg|gif|ico)$ {
try_files $uri /index.php;
expires 365d;
log_not_found off;
gzip_static on;
gzip_comp_level 5;
access_log off;
add_header Cache-Control private;
}
}
和我的 LocalSettings 的相关部分,徽标也不会显示在浏览器上
$wgLogo = "/var/cats.wiki/images/logo.png";
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgUploadDirectory = "/var/cats.wiki/images";
$wgUploadPath = "/images";
谢谢!:)