MediaWiki:修订间差异

来自MalacoKnowledge
imported>Malacology
init
 
imported>Malacology
add tags
 
(未显示同一用户的2个中间版本)
第12行: 第12行:
  ;extension=pdo_mysql
  ;extension=pdo_mysql


= MariaDB 配置 =
== MariaDB 配置 ==
  # pacman -S mariadb
  # pacman -S mariadb
根据 [[MariaDB]] 创建数据库。
根据 [[MariaDB]] 创建数据库。
第76行: 第76行:
编辑 <code>/usr/share/webapps/mediawiki/LocalSettings.php</code>
编辑 <code>/usr/share/webapps/mediawiki/LocalSettings.php</code>
  $wgLogos = [ '1x' => "$wgResourceBasePath/logo.png" ];
  $wgLogos = [ '1x' => "$wgResourceBasePath/logo.png" ];
  $wgLogo = "$wgResourceBasePath/logo.png";
  $wgLogo = "$wgResourceBasePath/logo.png";
  $wgFavicon = "$wgResourceBasePath/favicon.ico";
  $wgFavicon = "$wgResourceBasePath/favicon.ico";
            listen 80;
[[分类:Server]]
 
[[分类:Linux]]
            server_name knwl.malacology.net;
 
            return 301 <nowiki>https://$server_name$request_uri</nowiki>;
 
}
 
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;
 
}
 
}

2022年5月19日 (四) 21:06的最新版本

安装

# 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";