MediaWiki

来自MalacoKnowledge
imported>Malacology2022年5月19日 (四) 20:42的版本 (fix the heading issue)

安装

# pacman -S mediawiki

PHP 配置

# pacman -S php7-fpm

/etc/php7/php.ini 中的

;extension=iconv

去掉 ;

如果使用 mariadb 对下述使用一样的方法处理

;extension=mysqli
;extension=pdo_mysql

MariaDB 配置

# pacman -S mariadb

根据 MariaDB 创建数据库。

Nginx 配置

替换 DOMAIN 以及 /var/run/php-fpm7/php-fpm.sock 根据自己的 php-fpm 版本,这里使用 php-fpm7

server {
            listen 80;
            server_name DOMAIN;
            return 301 https://$server_name$request_uri;
}
server {
    listen 443 ssl http2;
    server_name DOMAIN;
    root /usr/share/webapps/mediawiki;
    ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;
    access_log /var/log/nginx/mediawiki_access.log;
    location / {
        index index.php;
        try_files $uri $uri/ @mediawiki;
    }
    location @mediawiki {
        rewrite ^/(.*)$ /index.php;
    }
   location ~ \.php$ {
       include /etc/nginx/fastcgi_params;
       fastcgi_pass unix:/var/run/php-fpm7/php-fpm.sock;
       fastcgi_index index.php;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       try_files $uri @mediawiki;
    }
   location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
       try_files $uri /index.php;
       expires max;
       log_not_found off;
    }
    # Restrictions based on the .htaccess files
    location ~ ^/(cache|includes|maintenance|languages|serialized|tests|images/deleted)/ {
       deny all;
    }
    location ~ ^/(bin|docs|extensions|includes|maintenance|mw-config|resources|serialized|tests)/ {
       internal;
    }
    location ^~ /images/ {
       try_files $uri /index.php;
    }
    location ~ /\. {
       access_log off;
       log_not_found off;
       deny all;
    }
    location /rest.php {
       try_files $uri $uri/ /rest.php?$args;
    }
}

美化

编辑 /usr/share/webapps/mediawiki/LocalSettings.php

$wgLogos = [ '1x' => "$wgResourceBasePath/logo.png" ];

$wgLogo = "$wgResourceBasePath/logo.png";

$wgFavicon = "$wgResourceBasePath/favicon.ico";
            listen 80;
            server_name knwl.malacology.net;
            return 301 https://$server_name$request_uri;
}
server {
    listen 443 ssl http2;
    server_name knwl.malacology.net;
    root /usr/share/webapps/mediawiki;
    ssl_certificate /etc/letsencrypt/live/malacology.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/malacology.net/privkey.pem;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;
    access_log /var/log/nginx/mediawiki_access.log;
   location / {
   index index.php;
   try_files $uri $uri/ @mediawiki;
}
location @mediawiki {
   rewrite ^/(.*)$ /index.php;
}
location ~ \.php$ {
   include /etc/nginx/fastcgi_params;
   fastcgi_pass unix:/var/run/php-fpm7/php-fpm.sock;
   fastcgi_index index.php;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   try_files $uri @mediawiki;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
   try_files $uri /index.php;
   expires max;
   log_not_found off;
}
# Restrictions based on the .htaccess files
location ~ ^/(cache|includes|maintenance|languages|serialized|tests|images/deleted)/ {
   deny all;
}
location ~ ^/(bin|docs|extensions|includes|maintenance|mw-config|resources|serialized|tests)/ {
   internal;
}
location ^~ /images/ {
   try_files $uri /index.php;
}
location ~ /\. {
   access_log off;
   log_not_found off;
   deny all;
}
location /rest.php {
   try_files $uri $uri/ /rest.php?$args;
}
}