LocalSettings.php设置

来自Org
跳转至: 导航搜索

您当前所在的位置:首页 > 架设手册 > LocalSettings.php设置

这是WikiMedia网站的主要配置文件,我们已经用到的部分参数:

基本设置

站点名称、数据库、用户名、密码等。

$wgSitename         = "Wiki.18dao.com";

$wgScriptPath       = "";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";

$wgArticlePath      = "$wgScriptPath/$1";
# $wgArticlePath      = "$wgScript?title=$1";

$wgStylePath        = "$wgScriptPath/skins";
$wgStyleDirectory   = "$IP/skins";
$wgLogo             = "$wgStylePath/common/images/wiki.18dao.com.png";

$wgUploadPath       = "$wgScriptPath/images";
$wgUploadDirectory  = "$IP/images";

$wgEnableEmail      = true;
$wgEnableUserEmail  = true;

$wgEmergencyContact = "qijingsong@staff.027.net";
$wgPasswordSender = "qijingsong@staff.027.net";

$wgDBtype           = "mysql";
$wgDBserver         = "111.111.111.111";
$wgDBname           = "wiki18daocom";
$wgDBuser           = "user";
$wgDBpassword       = "password";
$wgDBport           = "5432";
$wgDBprefix         = "18dao";

$wgDBmysql5 = true;

对扩展程序的支持

require_once( "includes/DefaultSettings.php" );
require_once( "extensions/inputbox/inputbox.php" );
require_once( "extensions/LatexDoc/LatexDoc.php" );
require_once( "extensions/ParserFunctions/ParserFunctions.php" );
require_once( "extensions/DynamicPageList2/DynamicPageList2.php" );

Hahahaha. I’m not too brhigt today. Great post!

多Wiki站点共享设置

在实际使用中间,我们发现要设置数十个以上的Wiki站点群的LocalSettings.php文件是个麻烦事情,特别是有一点小的配置改动就需要修改数十个文件。为了让多个Wiki站点共享修改的配置,我们采取了调用一个共同的CommonSettings.php的办法。

在各个Wiki站点目录的上一级目录下建立一个common目录,专门用于放置各个站点共同使用的文件。例如各Wiki站点目录为:

  • /usr/local/apache2/htdocs/test
  • /usr/local/apache2/htdocs/www.18dao.org
  • /usr/local/apache2/htdocs/baby
  • /usr/local/apache2/htdocs/hardware
  • /usr/local/apache2/htdocs/2008
  • etc.

我们就新建一个目录:

  • /usr/local/apache2/htdocs/common

然后新建一个文件:

  • /usr/local/apache2/htdocs/common/CommonSettings.php

并且把扩展程序也复制到这个目录中,以免需要在每个Wiki站点的目录的extensions目录下复制:

  • /usr/local/apache2/htdocs/common/inputbox
  • /usr/local/apache2/htdocs/common/LatexDoc
  • /usr/local/apache2/htdocs/common/ParserFunctions
  • /usr/local/apache2/htdocs/common/DynamicPageList2
  • /usr/local/apache2/htdocs/common/SpamBlacklist
  • /usr/local/apache2/htdocs/common/Timeline
  • /usr/local/apache2/htdocs/common/CharInsert
  • etc.

CommonSettings.php中可以包含各种需要在每个Wiki站点的配置中修改的参数,例如:

<?php

# this is the common settings file of 18dao wiki project
# usement: add this line in the bottom of LocalSettings.php: require_once( "../common/CommonSettings.php" );

require_once( "inputbox/inputbox.php" );
require_once( "LatexDoc/LatexDoc.php" );
require_once( "ParserFunctions/ParserFunctions.php" );
require_once( "DynamicPageList2/DynamicPageList2.php" );

## Shared memory settings

$wgUseSquid = true;
$wgSquidServers = array('130.62.240.156');

$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = array();
	
$wgNamespacesWithSubpages = array(
	NS_MAIN           => true,
	NS_CATEGORY       => true,
	NS_PROJECT        => true,
	NS_IMAGE          => true,
	NS_MEDIAWIKI      => true,
	NS_TEMPLATE       => true,
	NS_HELP           => true,
	NS_TALK           => true,
	NS_USER           => true,
	NS_USER_TALK      => true,
	NS_PROJECT_TALK   => true,
	NS_IMAGE_TALK     => true,
	NS_MEDIAWIKI_TALK => true,
	NS_TEMPLATE_TALK  => true,
	NS_HELP_TALK      => true,
	NS_CATEGORY_TALK  => true
);

$wgEnableUploads       = true;

$wgAllowExternalImages = true;

$wgUseTeX           = true;
$wgMathPath         = "http://wiki.18dao.com/cgi-bin/mimetex.cgi"; 

$wgSharedDB         = "www18daoorg";

$wgRightsUrl = "http://www.gnu.org/copyleft/fdl.html";
$wgRightsIcon = "gnu-fdl.png";

?>

以后只要在需要共享这个设置文件的Wiki站点的LocalSettings.php文件底部添加一句调用就可以:

# When you make changes to this configuration file, this will make
# sure that cached pages are cleared.
$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
$wgCacheEpoch = max( $wgCacheEpoch, $configdate );
	
require_once( "../common/CommonSettings.php" );

?>

注意,如果某个Wiki网站大部分使用了与CommonSettings.php一样的配置,少部分不一样的话,仍然可以调用该文件,然后在调用语句的下方添加该网站特别的设置,就可以覆盖共同的内容,例如:

# When you make changes to this configuration file, this will make
# sure that cached pages are cleared.
$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
$wgCacheEpoch = max( $wgCacheEpoch, $configdate );
	
require_once( "../common/CommonSettings.php" );

$wgGroupPermissions['*'    ]['edit']            = false;
$wgGroupPermissions['*'    ]['createpage']      = false;

?>


关于“LocalSettings.php设置”的留言:

新增留言

--123.114.135.174 (IP 位置 | 谁是 | 贡献) 2010年4月14日 (三) 23:25 (CST)

留言:很有用.谢谢

新增相关留言