第1行: |
第1行: |
| + | == 入门 == |
| + | |
| + | * [https://meta.wikimedia.org/wiki/Help:Contents 用户指南] |
| + | * [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings MediaWiki 配置设置列表] |
| + | * [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ/zh-hans MediaWiki 常见问题] |
| + | * [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki 发布邮件列表] |
| + | * [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources 本地化 MediaWiki 到您的语言] |
| + | * [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam 了解如何在您的 wiki 上应对垃圾骚扰] |
| + | |
| == 安装 == | | == 安装 == |
| + | |
| + | 在 Ubuntu Server 中安装,使用 Nginx 服务器和 SQLite 数据库 |
| + | |
| + | sudo apt install php php-fpm php-sqlite3 php-intl php-xml php-mbstring |
| + | cd /srv/mediawiki |
| + | curl -O https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.14.tar.gz |
| + | tar xzf mediawiki-1.31.14.tar.gz |
| + | |
| + | 然后打开网站,跟随向导。 |
| + | |
| + | 参考 |
| + | * [[mw:Manual:Installation_guide|安装指南]] |
| + | * [[mw:Manual:Running_MediaWiki_on_Debian_or_Ubuntu|Ubuntu 安装指南]] |
| + | * [[mw:Manual:SQLite|SQLite]] |
| + | |
| + | == [[Nginx]] 配置 == |
| + | |
| + | <syntaxhighlight lang=nginx> |
| + | server { |
| + | server_name wiki.ruo-chen.wang; |
| + | root /srv/mediawiki/mediawiki; |
| + | index index.php; |
| + | |
| + | client_max_body_size 5m; |
| + | client_body_timeout 60; |
| + | |
| + | location / { |
| + | try_files $uri $uri/ @rewrite; |
| + | } |
| + | location @rewrite { |
| + | rewrite ^/wiki/(.*)$ /index.php?title=$1&$args; |
| + | } |
| + | location ^~ /maintenance/ { |
| + | return 403; |
| + | } |
| + | |
| + | location ~ [^/]\.php(/|$) { |
| + | fastcgi_param HTTP_PROXY ""; |
| + | fastcgi_pass unix:/run/php/php-fpm.sock; |
| + | fastcgi_index index.php; |
| + | include fastcgi_params; |
| + | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| + | } |
| + | } |
| + | </syntaxhighlight> |
| + | |
| + | 参考 |
| + | * [https://www.nginx.com/resources/wiki/start/topics/recipes/mediawiki/ Nginx MediaWiki 配置] |
| + | * [https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/ Nginx PHP FastCGI Example] |
| + | |
| + | == MediaWiki 配置 == |
| + | |
| + | === Wiki 路径 === |
| + | <syntaxhighlight lang=php> |
| + | $wgArticlePath = "/wiki/$1"; |
| + | </syntaxhighlight> |
| + | |
| + | === 锚点转义方式 === |
| + | |
| + | 旧式转义会转义非 ASCII 字符的所有字节。使用新的 HTML5 方式会尽量少转义字符。 |
| + | |
| + | <syntaxhighlight lang=php> |
| + | $wgFragmentMode = ['html5', 'legacy']; |
| + | </syntaxhighlight> |
| + | |
| + | === 权限 === |
| + | <syntaxhighlight lang=php> |
| + | $wgGroupPermissions['*']['createaccount'] = false; |
| + | $wgGroupPermissions['*']['edit'] = false; |
| + | $wgGroupPermissions['sysop']['interwiki'] = true; |
| + | $wgGroupPermissions['sysop']['editinterface'] = true; |
| + | $wgGroupPermissions['sysop']['editsitecss'] = true; |
| + | $wgGroupPermissions['sysop']['editsitejs'] = true; |
| + | </syntaxhighlight> |
| + | |
| + | === 移动版皮肤 === |
| + | <syntaxhighlight lang=php> |
| + | wfLoadSkin('MinervaNeue'); |
| + | $wgMFDefaultSkinClass = 'SkinMinerva'; |
| + | </syntaxhighlight> |
| + | |
| + | == 笔记 == |
| + | |
| + | === 脚注 === |
| + | |
| + | 在正文中使用 <code><nowiki>{{ref|footnoteid}}</nowiki></code>,并在页面结尾增加「脚注」二级标题,将脚注内容用 <code><nowiki>{{note|footnoteid}} footnote text</nowiki></code> 写在有序列表中。<ref>[[metawikimedia:Help:Footnotes#Ref_and_note_template]]</ref> |
| + | |
| + | === 链接到分类 === |
| + | |
| + | <code><nowiki>[[:分类:分类名]]</nowiki></code> <ref>[[mw:Help:Categories#Linking_to_a_category]]</ref> |
| + | |
| + | === 可排序表格 === |
| + | |
| + | <ref>[[mw:Help:Tables/zh]]</ref> <ref>[[mw:Help:Sorting#Sorting_rows_of_a_table]]</ref> |
| + | <syntaxhighlight lang=text> |
| + | {| class="wikitable sortable" |
| + | ! 可排序列 |
| + | ! class="unsortable" | 不可排序列 |
| + | |- |
| + | | 单元格 || 单元格 |
| + | |- |
| + | | 单元格 || 单元格 |
| + | |} |
| + | </syntaxhighlight> |
| + | |
| + | === 中文页面在类别列表中的位置 === |
| + | |
| + | 默认情况下,类别页面下的页面是按照第一个字符排序的,使用 <code><nowiki>[[Category:ABC|Nihao]]</nowiki></code> 可将页面加入 ABC 类,并让它在 ABC 类下的位置排序时使用 Nihao 进行排序。<ref>[[mw:Help:Categories#Sort_key]]</ref> |
| + | |
| + | 或者可以直接设置该页面的默认排序关键词(default sort key),使用 <code><nowiki>{{DEFAULTSORT:Nihao}}</nowiki></code>。<ref>[[mw:Help:Magic_words#Miscellany]]</ref> |
| + | |
| + | === 清除页面缓存 === |
| + | |
| + | 在 URL 之后添加 <code>?action=purge</code>。 |
| + | |
| + | == 扩展 == |
| + | |
| + | === SyntaxHighlight_GeSHi === |
| + | |
| + | 语法高亮。在 MediaWiki 1.31 中已自带 <ref>This extension comes with MediaWiki 1.21 and above. [[mw:Extension:SyntaxHighlight]]</ref>。启用后可使用 <code><syntaxhighlight></code> 标签。 |
| + | |
| + | <syntaxhighlight lang=php> |
| + | wfLoadExtension('SyntaxHighlight_GeSHi'); |
| + | </syntaxhighlight> |
| + | |
| + | === MobileFrontend === |
| + | |
| + | [[mw:Extension:MobileFrontend|移动版本前端]]。下载 [[mw:Skin:Minerva_Neue|Minerva_Neue 皮肤]] 并安装到 <code>mediawiki/skins</code> 下。 |
| + | |
| + | <syntaxhighlight lang=php> |
| + | wfLoadSkin('MinervaNeue'); |
| + | $wgMFDefaultSkinClass = 'SkinMinerva'; |
| + | wfLoadExtension('MobileFrontend'); |
| + | </syntaxhighlight> |
| + | |
| + | === Gadgets === |
| + | |
| + | 在 MediaWiki 1.31 中已自带。启用的小工具见[[特殊:小工具]]。配置在 [[MediaWiki:Gadgets-definition]]。 |
| + | |
| + | 使用: |
| + | <syntaxhighlight lang=php> |
| + | wfLoadExtension('Gadgets'); |
| + | </syntaxhighlight> |
| + | |
| + | ==== [[mw:Reference Tooltips|Reference Tooltips]] ==== |
| + | |
| + | 鼠标移动到参考文献的方括号上时显示引用的内容。在 [[MediaWiki:Gadgets-definition]] 中加入 |
| + | |
| + | * ReferenceTooltips[ResourceLoader|default]|ReferenceTooltips.js|ReferenceTooltips.css |
| + | |
| + | == 升级 == |
| + | |
| + | 更新文件后访问 <code>/mw-config/index.php</code>,跟随向导。 |
| + | |
| + | == 参考 == |
| + | |
| + | <references /> |
| + | |
| + | [[Category:Server]] |