MediaWiki添加自定义尾注 footer添加自定义链接、文字

MediaWiki网站底部,添加自定义链接、备注!

// Add a link to this page (https://www.mediawiki.org/wiki/?curid=6031)

// Add a link to this page (https://www.mediawiki.org/wiki/?curid=6031)
// test-desc is an i18n message of the text
$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
    if ( $key === 'places' ) {
        $footerlinks['test'] = Html::element( 'a',
            [
                'href' => 'https://www.mediawiki.org/wiki/?curid=6031',
                'rel' => 'noreferrer noopener' // not required, but recommended for security reasons
            ],
        $skin->msg( 'test-desc' )->text()
        );
    };
};

//添加广州为电技术有限公司版权

// Add a link to this page (https://www.mediawiki.org/wiki/?curid=6031)
// test-desc is an i18n message of the text
$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
    if ( $key === 'places' ) {
        $footerlinks['test'] = Html::element( 'a',
            [
                'href' => 'https://iec.wiki/',
                'rel' => 'noreferrer noopener' // not required, but recommended for security reasons
            ],
        $skin->msg( '广州为电技术有限公司 © 2024 All rights reserved.' )->text()
        );
    };
};

MediaWiki添加备案号

$wgHooks['SkinAddFooterLinks'][] = function( $skin, $key, &$footerlinks ) {
       if ( $key === 'places' ) {
               $footerlinks['ICP_Number'] = Html::rawElement( 'a', [ 'href' => 'https://beian.miit.gov.cn/' ], '粤ICP备15102220号' );
       }
};
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = function( $sk, &$tpl ) {
    $tpl->set( 'ICP_Number', Linker::makeExternalLink( 'https://beian.miit.gov.cn/', '你的备案号' ) );
    $tpl->data['footerlinks']['places'][] = 'ICP_Number';
    return true;
};

Mediawiki 怎么都不显示ico 图标

服务器伪静态规则

location ~ ^\/.+$ {
if ($request_uri ~ ^/resources) { break; }
if ($request_uri ~ ^/images) { break; }
if ($request_uri ~ ^/skins) { break; }
if ($request_uri ~ ^/index.php) { break; }
if ($request_uri ~ ^/favicon.ico){ break; }
rewrite ^/(.+)$ /index.php?title=$1 last;
}

MW伪静态MW伪静态

$wgScriptPath = "";
$wgArticlePath = "$wgScriptPath/$1";
$wgUsePathInfo = true;
$wgScriptExtension = ".php";

mediawiki 伪静态

对nginx的rewrite文件写入如下内容,如果是宝塔面板,那么如下图所示添加,并保存。

location ~ ^\/.+$ {
if ($request_uri ~ ^/resources) { break; }
if ($request_uri ~ ^/images) { break; }
if ($request_uri ~ ^/index\.php) { break; }
rewrite ^/(.+)$ /index.php?title=$1 last;
}

or

location ~ ^\/.+$ {
if ($request_uri ~ ^/resources) { break; }
if ($request_uri ~ ^/index\.php) { break; }
rewrite ^/(.+)$ /index.php?title=$1 last;
}

宝塔mediawiki 伪静态.PNG

然后再在 LocalSettings.php文件里面添加如下代码

# 伪静态
$wgScriptPath       = ""; 
$wgArticlePath = "$wgScriptPath/$1";
$wgUsePathInfo      = true; 
$wgScriptExtension  = ".php";

宝塔面板404设置

1,在根目录里面放置404页面
2、在如下配置,去掉“网站设置” -=》 配置文件 =》404前置#号

#SSL-END
#引用重定向规则,注释后配置的重定向代理将无效
include /www/server/panel/vhost/nginx/redirect/www.emc.wiki/*.conf;
    
#ERROR-PAGE-START  错误页配置,可以注释、删除或修改
error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END

MediaWiki 伪静态静态化

MediaWiki 伪静态静态化

官方的Nginx伪静态设置
https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx

估计你们也难搞,建议采用宝塔面板,网站配置里面的静态化规则:

laravel5的规则

location / {  
    try_files $uri $uri/ /index.php$is_args$query_string;  
}  

MVC规则

location /{
    if (!-e $request_filename) {
       rewrite  ^(.*)$  /index.php/$1  last;
       break;
    }
}

MediaWiki上传数据库出现502 bad gateway

MediaWiki上传数据库出现502 bad gateway

MediaWiki是比较大,MediaWiki的数据库里会存储每次的编辑记录,所以大。所以,在导出MediaWiki的数据库时候选择gz压缩就行了,能压缩掉2/3,因为sql是纯文本的内容。

需要,设置nginx的fcgi超时时间调大一点,如下所示默认是60s,如果是数据库很大,就可以适当将连接时间设置长一点。

如下是某国内阿里云深圳服务器原始nginx配置

user  www www;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
        include       mime.types;
        #include luawaf.conf;

        include proxy.conf;

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 300m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
        limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;

server
    {
        listen 888;
        server_name phpmyadmin;
        index index.html index.htm index.php;
        root  /www/server/phpmyadmin;
            location ~ /tmp/ {
                return 403;
            }

        #error_page   404   /404.html;
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}

一、啥时候用到
用来设置请求资源和服务器返回的时间,保证一个请求占用固定时间,超出后报504超时!这样可以保证一个请求占用过长时间。

二、主要参数
使用nginx服务器如果遇到timeou情况时可以如下设置参数,使用fastcgi:

fastcgi_connect_timeout 75; 链接

fastcgi_read_timeout 600; 读取

fastcgi_send_timeout 600; 发请求

这两个选项.
fastcgi_read_timeout是指fastcgi进程向nginx进程发送response的整个过程的超时时间

fastcgi_send_timeout是指nginx进程向fastcgi进程发送request的整个过程的超时时间

这两个选项默认都是秒(s),可以手动指定为分钟(m),小时(h)等

三、其他常用参数以及参数说明
keepalive_timeout 600; 连接超时时间,1分钟,具体时间可以根据请求(例如后台导入)需要的时间来设置

proxy_connect_timeout 600; 1分钟

proxy_read_timeout 600; 1分钟

nginx超时配置参数说明:

keepalive_timeout

语法 keepalive_timeout timeout [ header_timeout ]

默认值 75s

上下文 http server location

说明 第一个参数指定了与client的keep-alive连接超时时间。服务器将会在这个时间后关闭连接。可选的第二个参数指定了在响应头Keep-Alive: timeout=time中的time值。这个头能够让一些浏览器主动关闭连接,这样服务器就不必要去关闭连接了。没有这个参数,nginx不会发送Keep-Alive响应头(尽管并不是由这个头来决定连接是否“keep-alive”)

两个参数的值可并不相同

注意不同浏览器怎么处理“keep-alive”头

MSIE和Opera忽略掉”Keep-Alive: timeout=” header.

MSIE保持连接大约60-65秒,然后发送TCP RST

Opera永久保持长连接

Mozilla keeps the connection alive for N plus about 1-10 seconds.

Konqueror保持长连接N秒

proxy_connect_timeout

语法 proxy_connect_timeout time

默认值 60s

上下文 http server location

说明 该指令设置与upstream server的连接超时时间,有必要记住,这个超时不能超过75秒。

这个不是等待后端返回页面的时间,那是由proxy_read_timeout声明的。如果你的upstream服务器起来了,但是hanging住了(例如,没有足够的线程处理请求,所以把你的请求放到请求池里稍后处理),那么这个声明是没有用的,由于与upstream服务器的连接已经建立了。

proxy_read_timeout

语法 proxy_read_timeout time

默认值 60s

上下文 http server location

说明 该指令设置与代理服务器的读超时时间。它决定了nginx会等待多长时间来获得请求的响应。这个时间不是获得整个response的时间,而是两次reading操作的时间。

client_header_timeout

语法 client_header_timeout time

默认值 60s

上下文 http server

说明 指定等待client发送一个请求头的超时时间(例如:GET / HTTP/1.1).仅当在一次read中,没有收到请求头,才会算成超时。如果在超时时间内,client没发送任何东西,nginx返回HTTP状态码408(“Request timed out”)

client_body_timeout

语法 client_body_timeout time

默认值 60s

上下文 http server location

说明 该指令设置请求体(request body)的读超时时间。仅当在一次readstep中,没有得到请求体,就会设为超时。超时后,nginx返回HTTP状态码408(“Request timed out”)

lingering_timeout

语法 lingering_timeout time

默认值 5s

上下文 http server location

说明 lingering_close生效后,在关闭连接前,会检测是否有用户发送的数据到达服务器,如果超过lingering_timeout时间后还没有数据可读,就直接关闭连接;否则,必须在读取完连接缓冲区上的数据并丢弃掉后才会关闭连接。

resolver_timeout

语法 resolver_timeout time

默认值 30s

上下文 http server location

说明 该指令设置DNS解析超时时间

proxy_send_timeout

语法 proxy_send_timeout time

默认值 60s

上下文 http server location

说明 这个指定设置了发送请求给upstream服务器的超时时间。超时设置不是为了整个发送期间,而是在两次write操作期间。如果超时后,upstream没有收到新的数据,nginx会关闭连接

proxy_upstream_fail_timeout(fail_timeout)

语法 server address [fail_timeout=30s]

默认值 10s

上下文 upstream

说明 Upstream模块下 server指令的参数,设置了某一个upstream后端失败了指定次数(max_fails)后,该后端不可操作的时间,默认为10秒

四、实例

这里来看一个把Nginx的超时时间上调的例子。
看看时间是否符合要求,在nginx.config里面的三个参数:

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
以上的单位是秒。

将MediaWiki移至另一台服务器或换域名

MediaWiki搬家、换域名
官方说明 https://www.mediawiki.org/wiki/Manual:Moving_a_wiki

本页说明了如何将Wiki移至另一台服务器。当移至其他Web服务器或域(或两者)时,通常需要这样做。

最安全的方法是在两个Wiki上使用相同的MediaWiki版本。但是,可以在新服务器上安装较新的MediaWiki版本,并直接在新服务器上执行升级。实际上,如果要将Wiki升级到要求比旧服务器上的要求更高的新版本(例如php版本),则这可能是您唯一的选择。

其他页面中基本解释了这些步骤:

备份您的Wiki
将备份从旧服务器转移到新服务器。
在新服务器上还原备份

  • 重新创建数据库,用户和权限
  • 导入数据库备份
  • 导入MediaWiki文件
  • 检查配置文件
  • 测试