【问题标题】:Mediawiki on Google App Engine Links Missing Title ParameterGoogle App Engine 上的 Mediawiki 链接缺少标题参数
【发布时间】:2014-03-17 01:34:53
【问题描述】:

使用 dev_appserver.py 在 localhost 上安装和测试 mediawiki 的副本后,我将安装部署到 Google App Engine。我对 LocalSettings.php 文件进行了一些更改,以适应 localhost 和 Google 之间的差异——主要是 SQL 数据库和 $wgServer。我尝试运行标准的 mw_config 设置过程,但它从未完成 - 在表创建期间停止(我认为)。相反,我将 localhost 数据库的副本恢复到 Google Cloud SQL 数据库中。

它几乎可以工作了;它可以读取数据库、登录用户、保存对页面的更改……但是页面之间的链接存在一个奇怪的问题。页面上的链接缺少 '?title=xxxx' 部分,例如

/index.php/Special:用户登录

而不是

/index.php?title=Special:UserLogin

这使得它非常不可用。

有人有在 Google App Engine (GAE) 上运行 Mediawiki 的经验吗?我需要知道我需要进行哪些配置更改或页面更改才能使这些链接正常工作。

LocalSettings.php

<?php
# This file was automatically generated by the MediaWiki 1.21.2
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# http://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
    exit;
}

## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename = "Shattered Screens";
$wgMetaNamespace = "Shattered_Screens";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";
$wgScriptExtension = ".php";

## The protocol and server name to use in fully-qualified URLs
#$wgServer = "http://localhost:8080";
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
  $wgServer = "http://wiki.shatteredscreens.com";
}else{
  $wgServer = "http://localhost:8080";
}

## The relative URL path to the skins directory
$wgStylePath = "$wgScriptPath/skins";

## The relative URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo             = "$wgStylePath/common/images/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "ivan.hawkes@shatteredscreens.com";
$wgPasswordSender = "ivan.hawkes@shatteredscreens.com";

$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = "mysql";
#$wgDBserver = "localhost";
$wgDBname = "mediawiki";
$wgDBuser = "someaccount";
$wgDBpassword = "somepassword";

# Database server settings for local / GAE
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
  $wgDBserver = ":/cloudsql/shattered-screens-wiki:mediawiki";
}else{
  $wgDBserver = "localhost";
}

# MySQL specific settings
$wgDBprefix = "";

# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

# Experimental charset support for MySQL 5.0.
$wgDBmysql5 = false;

## Shared memory settings
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = array();

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = false;
#$wgUseImageMagick = true;
#$wgImageMagickConvertCommand = "/usr/bin/convert";

# InstantCommons allows wiki to use images from http://commons.wikimedia.org
$wgUseInstantCommons = false;

## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "en_US.utf8";

## If you want to use image uploads under safe mode,
## create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment
## this, if it's not already uncommented:
#$wgHashedUploadDirectory = false;

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";

# Site language code, should be one of the list in ./languages/Names.php
$wgLanguageCode = "en-gb";

$wgSecretKey = "xxx";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "xxx";

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
$wgDefaultSkin = "vector";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

# Query string length limit for ResourceLoader. You should only set this if
# your web server has a query string length limit (then set it to that limit),
# or if you have suhosin.get.max_value_length set in php.ini (then set it to
# that value)
$wgResourceLoaderMaxQueryLength = -1;

# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = false;


# End of automatically generated settings.
# Add more configuration options below.

app.yaml

application: shattered-screens-wiki
version: initialtest
runtime: php
api_version: 1

handlers:
# Static pages
- url: /(.*\.(htm$|html$|css$|js$))
  static_files: mediawiki/\1
  upload: mediawiki/(.*\.(htm$|html$|css$|js$))
  application_readable: true
  secure: always

# Serve images as static resources.
- url: /(.+\.(gif|png|jpg|css))$
  static_files: mediawiki/\1
  upload: mediawiki/.+\.(gif|png|jpg|css)$
  application_readable: true
  secure: always

# Misc files.
- url: /(.+\.(xsd|txt|))$
  static_files: mediawiki/\1
  upload: mediawiki/.+\.(xsd|txt)$
  application_readable: true
  secure: always

# Serve php5 scripts.
- url: /(.+\.php5)$
  script: mediawiki/\1

# Serve php scripts.
- url: /(.+\.php)$
  script: mediawiki/\1

【问题讨论】:

    标签: php google-app-engine mediawiki


    【解决方案1】:

    您应该使用$wgArticlePath 来设置内部链接的格式。尝试将其设置为{$wgScript}?title=$1

    /index.php/Special:UserLogin 实际上是installations on non CGI servers 的默认地址结构,也适用于most 服务器

    【讨论】:

    • 这个答案几乎是正确的,并且为我提供了足够的信息来解决这些小细节。由于 $wgArticlePath 的默认设置在测试服务器上工作得很好,我在实时服务器的设置 $wgServer 之后添加了一行 $wgArticlePath = "{$wgScriptPath}?title=$1";将允许链接在您的实时服务器上正常工作。
    • 我不确定我是否完全关注你,但很高兴它成功了!
    【解决方案2】:

    试试:

    - url: /.*
      script: mediawiki/index.php
    

    app.yaml 文件的末尾,它将确保所有其他请求都被路由到 mediawiki 主脚本。

    【讨论】:

      【解决方案3】:

      我个人更喜欢以下设置,因为它有更友好的 SEO 网址。

      $wgScriptPath = "/wiki"; // or /w/ like Wikipedia
      $wgArticlePath = "$wgScriptPath/$1";
      

      其实任何形式的链接,只要指定app.yaml,MediaWiki都可以正确解析。

      所以你可以设置

      - url: /.*
        script: mediawiki/index.php
      

      # Serve php5 scripts.
      - url: /wiki/(.+\.php5)$
        script: wiki/\1
      
      # Serve php scripts.
      - url: /wiki/(.+\.php)$
        script: wiki/\1
      
      # deal with the real urls
      - url: (.*)/(w|W)iki/(.*)
        script: wiki/index.php
        secure: optional
      

      对于第一个选项,它的缺点是您无法将损坏的链接重定向到自定义 404 页面。

      我在这里 (http://mediawiki-on-gae.appspot.com/) 上有一个在 Google App Engine 上运行的完整可行的 MediaWiki 实例。您可能还会发现其他一些有用的信息。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-01-27
        • 2014-01-17
        • 1970-01-01
        • 2013-05-09
        • 1970-01-01
        • 2011-07-09
        • 2012-02-21
        • 1970-01-01
        相关资源
        最近更新 更多