User:MeowyCats2/Install CreateWiki and ManageWiki on your wiki: Difference between revisions

From Meta Wiki
Jump to navigation Jump to search
TODO
 
Cocopuff2018 (talk | contribs)
+small update for empty databases
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{note}} This is less of a "tutorial" and more of a "memo" on the means by which I have been successful. Disclaimer: I, Waki285, will not be liable for any damages caused by this memo.<br>
{{note}} This memo is an slightly modified version of the memo originally made by Waki285 from Miraheze Meta at [[mh:meta:User:Waki285/Install CreateWiki and ManageWiki on your wiki]] to make it work with newer CreateWiki versions.<br>
{{note}} This is less of a "tutorial" and more of a "memo" on the means by which I have been successful. Disclaimer: I will not be liable for any damages caused by this memo.<br>
{{note}} This was done for production, but could also be used for development as an extension development.
{{note}} This was done for production, but could also be used for development as an extension development.
== Prerequisites ==
== Prerequisites ==
This is the environment in which I have succeeded. I am not sure if I would be successful in any other environment than this.
This is the environment in which I have succeeded. I am not sure if I would be successful in any other environment than this.
* VPS with 4-core CPU, 8GB memory, free IP port open, and sudo privileges
* VPS with free IP port open and sudo privileges (you may have to sudo the commands if you're not root)
* Ubuntu Server 22.02
* Ubuntu Server 22.02
* Nginx 1.18.0
* Nginx
* MySQL 8.0.36
* MySQL or MariaDB
* Cloudflare (I bought 1 domain for this)
* Cloudflare (optional)
* Domain with ability to add A wildcard record


== Procedure ==
== Procedure ==
<ol>
<ol>
<li>Install packages such as php-intl and mysql, which are required for a normal MediaWiki installation. We will also purchase a domain and connect it to Cloudflare.</li>
<li>Install packages such as PHP and MySQL, which are required for a normal MediaWiki installation. We will also purchase a domain and connect it to Cloudflare.</li>
<ol>
<li>Run <code>add-apt-repository ppa:ondrej/php</code></li>
<li>Run <code>apt install php</code></li>
<li>Run <code>apt install php-fpm</code></li>
<li>Run <code>apt install nginx</code></li>
<li>Run <code>apt install php-mbstring php-xml php-intl</code></li>
<li>Run <code>apt install php-mysql</code></li>
<li>Run <code>apt install mariadb-server</code></li>
<li>Run <code>mysql_secure_installation</code></li>
<li>If you would like to create a seperate MySQL user for authentication, run <code>CREATE USER 'mediawiki'@'localhost' IDENTIFIED BY 'password';</code> and <code>GRANT ALL PRIVILEGES ON *.* TO 'mediawiki'@'localhost' WITH GRANT OPTION;</code></li>
</ol>
<li>Extract MediaWiki to <code>/var/www/mediawiki</code>.</li>
<li>Extract MediaWiki to <code>/var/www/mediawiki</code>.</li>
<li>Enter MySQL and create a database named "testwiki".</li>
<li>Enter MySQL and create a database named "testwiki".</li>
Line 39: Line 53:
     }
     }


    location ~ ^/cw_cache/ {
        deny all;
    }
   
     error_log /var/log/nginx/mediawiki_error.log;
     error_log /var/log/nginx/mediawiki_error.log;
     access_log /var/log/nginx/mediawiki_access.log;
     access_log /var/log/nginx/mediawiki_access.log;
}
}
</syntaxhighlight>
</syntaxhighlight>
<li>Go to Cloudflare and add the following to your DNS.</li>
<li>Remember to open port 80 if you are using a firewall.</li>
:'''Type:''' <code>A</code> '''Name''': <code>*</code> '''IPv4 address''': Your VPS IP '''Proxy status''': <code>Proxied</code>
<li>Go to Cloudflare if you're using it, or otherwise your domain registry, and add the following to your DNS.</li>
<li>Go to the Cloudflare SSL/TLS settings and set the SSL/TLS encryption mode to '''Flexible'''.</li>
:'''Type:''' <code>A</code> '''Name''': <code>*</code> '''IPv4 address''': Your VPS IP '''Proxy status''': <code>Proxied</code> (if using Cloudflare)
<li>Go to the Cloudflare SSL/TLS settings and set the SSL/TLS encryption mode to '''Flexible'''. (if using Cloudflare, otherwise set up SSL, maybe with Let's Encrypt)</li>
<ol>
<li>If you're not using Cloudflare and would like to use certbot with Let's Encrypt, follow the below steps.</li>
<li>Install certbot with <code>sudo snap install certbot --classic</code></li>
</ol>
<li>At this point, go to test.[yourdomain.tld] and you should see "LocalSettings.php not found. Please set up the wiki first."</li>
<li>At this point, go to test.[yourdomain.tld] and you should see "LocalSettings.php not found. Please set up the wiki first."</li>
<li>Click "set up the wiki", set up the wiki as usual, but install the extensions AbuseFilter, Interwiki and Echo. Set the database name to "testwiki" created earlier and leave the table prefix blank.</li>
<li>Click "set up the wiki", set up the wiki as usual, but install the extensions AbuseFilter, Interwiki, Echo, and WikiEditor. DON'T INSTALL MinervaNeue. Set the database name to "testwiki" created earlier and leave the table prefix blank.</li>
<li>After setup is complete and the downloaded LocalSettings.php is in place, verify that MediaWiki starts properly.</li>
<li>After setup is complete and the downloaded LocalSettings.php is in place, verify that MediaWiki starts properly.</li>
<li>Install [[mw:Extension:AntiSpoof]].</li>
<li>Install [[mw:Extension:AntiSpoof]]. Follow the guide on the MediaWiki Extension page.</li>
<li>TODO</li>
<li>Install [[mw:Extension:CheckUser]]. Follow the guide on the MediaWiki Extension page.</li>
<li>[[mw:Extension:CentralAuth]].</li>
<ol>
<li>Download and extract.</li>
<li>Enter MySQL and create a database named <code>centralauth</code>.</li>
<li>Put this to your LocalSettings.</li>
<syntaxhighlight lang="php">
wfLoadExtension( 'CentralAuth' );
$wgCentralAuthDatabase = 'centralauth';
</syntaxhighlight>
<li>Run <code>php maintenance/run.php sql --wikidb centralauth extensions/CentralAuth/schema/mysql/tables-generated.sql</code></li>
<li>Run <code>php maintenance/run.php sql --wikidb centralauth extensions/AntiSpoof/sql/mysql/tables-generated.sql</code></li>
<li>Run <code>php maintenance/run.php CentralAuth:migratePass0.php</code></li>
<li>Run <code>php maintenance/run.php CentralAuth:migratePass1.php</code></li>
</ol>
<li>Have a cup of coffee.</li>
<li>Install [[mw:Extension:CreateWiki]].</li>
<ol>
<li>Download and extract.</li>
<li>Enter MySQL and create a database named <code>wikidb</code>.</li>
<li>Put this to your LocalSettings.</li>
<syntaxhighlight lang="php">
#wfLoadExtension( 'CreateWiki' );
$wgCreateWikiDatabase = 'wikidb';
</syntaxhighlight>
<li>Make <code>cw_cache</code> directory and give 777 permission.</li>
<li>Put <code>$wgCreateWikiCacheDirectory = 'cw_cache';</code> to your LocalSettings.</li>
<li>Run these commands.</li>
<syntaxhighlight lang="bash">
php maintenance/run sql --wikidb wikidb extensions/CreateWiki/sql/cw_wikis.sql
php maintenance/run sql --wikidb wikidb extensions/CreateWiki/sql/cw_comments.sql
php maintenance/run sql --wikidb wikidb extensions/CreateWiki/sql/cw_requests.sql
</syntaxhighlight>
<li>Remove # from <code>#wfLoadExtension( 'CreateWiki' );</code>.</li>
<li>Create <code>SetupCreateWiki.php</code> and paste this, and change wiki_url and database password. {{note}} This script is copied and edited by https://github.com/miraheze/ci-scripts/blob/master/mediawiki/globals/setup-CreateWiki.php </li>
<syntaxhighlight lang="php">
<?php
 
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
        exit;
}
 
use MediaWiki\MediaWikiServices;
use Miraheze\CreateWiki\WikiInitialize;
use Wikimedia\Rdbms\DBQueryError;
 
$wgWikimediaJenkinsCI = true;
 
define( 'CW_DB', 'wikidb' );
 
require_once "$IP/extensions/CreateWiki/includes/WikiInitialize.php";
 
$wgHooks['MediaWikiServices'][] = 'insertWiki';
 
function insertWiki( MediaWikiServices $services ) {
wfLoadConfiguration();
try {
if ( getenv( 'WIKI_CREATION_SQL_EXECUTED' ) ) {
return;
}
 
$db = wfInitDBConnection();
 
$db->selectDomain( 'wikidb' );
$db->newInsertQueryBuilder()
->insertInto( 'cw_wikis' )
->ignore()
->row( [
'wiki_dbname' => 'testwiki',
'wiki_dbcluster' => 'c1',
'wiki_sitename' => 'TestWiki',
'wiki_language' => 'en',
'wiki_private' => (int)0,
'wiki_creation' => $db->timestamp(),
'wiki_category' => 'uncategorised',
'wiki_closed' => (int)0,
'wiki_deleted' => (int)0,
'wiki_locked' => (int)0,
'wiki_inactive' => (int)0,
'wiki_inactive_exempt' => (int)0,
'wiki_url' => 'https://test.yourdomain.tld', # CHANGE THIS
] )
->caller( __METHOD__ )
->execute();
 
putenv( 'WIKI_CREATION_SQL_EXECUTED=true' );
} catch ( DBQueryError $e ) {
return;
}
}
 
function wfLoadConfiguration() {
global $wgCreateWikiGlobalWiki, $wgCreateWikiDatabase,
$wgCreateWikiCacheDirectory, $wgConf;
 
$wgCreateWikiGlobalWiki = 'wikidb';
$wgCreateWikiDatabase = 'wikidb';
$wgCreateWikiCacheDirectory = MW_INSTALL_PATH . '/cache';
 
$wi = new WikiInitialize();
 
$wi->setVariables(
MW_INSTALL_PATH . '/cache',
[
''
],
[
'127.0.0.1' => ''
]
);
 
$wi->config->settings += [
'cwClosed' => [
'default' => false,
],
'cwInactive' => [
'default' => false,
],
'cwPrivate' => [
'default' => false,
],
'cwExperimental' => [
'default' => false,
],
];
 
$wi->readCache();
$wi->config->extractAllGlobals( $wi->dbname );
$wgConf = $wi->config;
}
 
function wfInitDBConnection() {
return MediaWikiServices::getInstance()->getDatabaseFactory()->create( 'mysql', [
'host' => $GLOBALS['wgDBserver'],
'user' => 'root',
'password' => 'y0ur p@$$w0rd' # CHANGE THIS
] );
}
 
?>
</syntaxhighlight>
<li>Insert <code>require_once "$IP/SetupCreateWiki.php";</code> TOP of LocalSettings.php (below <code><?php</code>)</li>
<li>Visit tets.yourdomain.tld. You will get an MediaWiki error message. Ignore it and check if TestWiki exists in wikidb.cw_wikis using e.g. phpMyAdmin.</li>
<li>Remove <code>require_once "$IP/SetupCreateWiki.php";</code></li>.
</ol>
<li>Get MirahezeFunctions.php from https://github.com/miraheze/mw-config/blob/master/initialise/MirahezeFunctions.php and paste it to /var/www/mediawiki/MirahezeFunctions.php</li>
<li>Modify <code>MirahezeFunctions.php</code>. Please change <code>default</code>. Not sure if you need to remove <code>beta</code> on all of the following. I did not remove it.</li>
<ol>
<li>Change ALLOWED_DOMAINS and DEFAULT_SERVER to yourdomain.tld</li>
<li>Change CACHE_DIRECTORY to /var/www/mediawiki/cw_cache</li>
<li>Change CENTRAL_DATABASE to testwiki</li>
<li>Change GLOBAL_DATABASE to wikidb</li>
<li>Change MEDIAWIKI_DIRECTORY to /var/www/mediawiki/</li>
<li>Change path to correct path for <code>LocalSettings.php</code>, <code>ManageWikiExtensions.php</code>, <code>ManageWikiNamespaces.php</code>, <code>ManageWikiSettings.php</code> and extensions(skins) folder path. For Example: '/../LocalSettings.php' → '/LocalSettings.php', '/../ManageWikiExtensions.php' → '/ManageWikiExtensions.php', <code>self::MEDIAWIKI_DIRECTORY . $this->version . '/extensions/*/extension*.json'</code> → <code>self::MEDIAWIKI_DIRECTORY . '/extensions/*/extension*.json'</code></li>
</ol>
</ol>
<li>Add this to LocalSettings. Put BEFORE loading extensions</li>
<syntaxhighlight lang="php">
require_once "$IP/MirahezeFunctions.php";
$wi = new MirahezeFunctions();
</syntaxhighlight>
<li>Add this to LocalSettings.php Put JUST UNDER <code>$wi = new MirahezeFunctions();</code>. Remember to change yourdomain.tld</li>
<syntaxhighlight lang="php">
$wgConf->settings += [
'wgCentralAuthDatabase' => [
'default' => 'centralauth',
],
'wgCreateWikiUseJobQueue' => [
'default' => true,
],
'wgCreateWikiSubdomain' => [
'default' => 'yourdomain.tld',
],
'wgCreateWikiUseClosedWikis' => [
'default' => true,
],
'wgCreateWikiUseCustomDomains' => [
'default' => true,
],
'wgCreateWikiUseEchoNotifications' => [
'default' => true,
],
'wgCreateWikiUseExperimental' => [
'default' => true,
],
'wgCreateWikiUseInactiveWikis' => [
'default' => true,
],
'wgCreateWikiUsePrivateWikis' => [
'default' => true,
],
'wgCreateWikiCacheDirectory' => [
'default' => 'cw_cache',
],
'wgCreateWikiDatabaseSuffix' => [
'default' => 'wiki',
],
'wgCreateWikiDisableRESTAPI' => [
'default' => true,
'metawiki' => false,
],
'wgCreateWikiGlobalWiki' => [
'default' => 'testwiki',
],
'wgCreateWikiEmailNotifications' => [
'default' => true,
],
'wgFileExtensions' => [
'default' => [
'djvu',
'gif',
'ico',
'jpg',
'jpeg',
'ogg',
'pdf',
'png',
'svg',
'webp',
],
],
'wgArticlePath' => [
'default' => '/wiki/$1',
],
'wgScriptPath' => [
'default' => '',
],
'wgUsePathInfo' => [
'default' => true,
],
'wgResourceBasePath' => [
'default' => '',
],
'wgCreateWikiSQLfiles' => [
'default' => [
"$IP/maintenance/tables-generated.sql",
"$IP/extensions/AbuseFilter/db_patches/mysql/tables-generated.sql",
"$IP/extensions/AntiSpoof/sql/mysql/tables-generated.sql",
#"$IP/extensions/BetaFeatures/sql/tables-generated.sql",
#"$IP/extensions/CheckUser/schema/mysql/tables-generated.sql",
#"$IP/extensions/DataDump/sql/data_dump.sql",
"$IP/extensions/Echo/sql/mysql/tables-generated.sql",
#"$IP/extensions/GlobalBlocking/sql/mysql/tables-generated-global_block_whitelist.sql",
"$IP/extensions/OATHAuth/sql/mysql/tables-generated.sql",
#"$IP/extensions/RottenLinks/sql/rottenlinks.sql",
#"$IP/extensions/UrlShortener/schemas/tables-generated.sql",
],
],
'wgManageWikiPermissionsAdditionalAddGroups' => [
'default' => [],
],
'wgManageWikiPermissionsAdditionalRights' => [
'default' => [
'*' => [
'autocreateaccount' => true,
'read' => true,
'oathauth-enable' => true,
'viewmyprivateinfo' => true,
'editmyoptions' => true,
'editmyprivateinfo' => true,
'editmywatchlist' => true,
'writeapi' => true,
],
'checkuser' => [
'checkuser' => true,
'checkuser-log' => true,
'abusefilter-privatedetails' => true,
'abusefilter-privatedetails-log' => true,
],
'suppress' => [
'abusefilter-hidden-log' => true,
'abusefilter-hide-log' => true,
'browsearchive' => true,
'deletedhistory' => true,
'deletedtext' => true,
'deletelogentry' => true,
'deleterevision' => true,
'hideuser' => true,
'suppressionlog' => true,
'suppressrevision' => true,
'viewsuppressed' => true,
],
'steward' => [
'userrights' => true,
],
'user' => [
'mwoauthmanagemygrants' => true,
'user' => true,
],
],
'+metawiki' => [
'steward' => [
'abusefilter-modify-global' => true,
'centralauth-lock' => true,
'centralauth-suppress' => true,
'centralauth-rename' => true,
'centralauth-unmerge' => true,
'createwiki' => true,
'createwiki-deleterequest' => true,
'globalblock' => true,
'handle-import-request-interwiki' => true,
'handle-import-requests' => true,
'managewiki-core' => true,
'managewiki-extensions' => true,
'managewiki-namespaces' => true,
'managewiki-permissions' => true,
'managewiki-settings' => true,
'managewiki-restricted' => true,
'noratelimit' => true,
'oathauth-verify-user' => true,
'userrights' => true,
'userrights-interwiki' => true,
'globalgroupmembership' => true,
'globalgrouppermissions' => true,
'view-private-import-requests' => true,
],
]
],
'wgManageWikiPermissionsAdditionalRemoveGroups' => [
'default' => [],
],
'wgManageWikiPermissionsDisallowedRights' => [
'default' => [
'any' => [
'abusefilter-hide-log',
'abusefilter-hidden-log',
'abusefilter-modify-global',
'abusefilter-private',
'abusefilter-private-log',
'abusefilter-privatedetails',
'abusefilter-privatedetails-log',
'aft-oversighter',
'autocreateaccount',
'bigdelete',
'centralauth-createlocal',
'centralauth-lock',
'centralauth-suppress',
'centralauth-rename',
'centralauth-unmerge',
'checkuser',
'checkuser-log',
'createwiki',
'createwiki-deleterequest',
'createwiki-suppressionlog',
'createwiki-suppressrequest',
'editincidents',
'editothersprofiles-private',
'flow-suppress',
'generate-random-hash',
'globalblock',
'globalblock-exempt',
'globalgroupmembership',
'globalgrouppermissions',
'handle-import-request-interwiki',
'handle-import-requests',
'handle-pii',
'hideuser',
'investigate',
'ipinfo',
'ipinfo-view-basic',
'ipinfo-view-full',
'ipinfo-view-log',
'managewiki-restricted',
'managewiki-editdefault',
'moderation-checkuser',
'mwoauthmanageconsumer',
'mwoauthmanagemygrants',
'mwoauthsuppress',
'mwoauthviewprivate',
'mwoauthviewsuppressed',
'oathauth-api-all',
'oathauth-enable',
'oathauth-disable-for-user',
'oathauth-verify-user',
'oathauth-view-log',
'renameuser',
'request-import',
'requestwiki',
'siteadmin',
'securepoll-view-voter-pii',
'smw-admin',
'smw-patternedit',
'smw-viewjobqueuewatchlist',
'stopforumspam',
'suppressionlog',
'suppressrevision',
'themedesigner',
'titleblacklistlog',
'updatepoints',
'userrights',
'userrights-interwiki',
'view-private-import-requests',
'viewglobalprivatefiles',
'viewpmlog',
'viewsuppressed',
'writeapi',
],
'user' => [
'autoconfirmed',
'noratelimit',
'skipcaptcha',
'managewiki-core',
'managewiki-extensions',
'managewiki-namespaces',
'managewiki-permissions',
'managewiki-settings',
'globalblock-whitelist',
'ipblock-exempt',
'interwiki',
],
'*' => [
'read',
'skipcaptcha',
'torunblocked',
'centralauth-merge',
'generate-dump',
'editsitecss',
'editsitejson',
'editsitejs',
'editusercss',
'edituserjson',
'edituserjs',
'editmyoptions',
'editmyprivateinfo',
'editmywatchlist',
'globalblock-whitelist',
'interwiki',
'ipblock-exempt',
'viewmyprivateinfo',
'viewmywatchlist',
'managewiki-core',
'managewiki-extensions',
'managewiki-namespaces',
'managewiki-permissions',
'managewiki-settings',
'noratelimit',
'autoconfirmed',
],
],
],
'wgManageWikiPermissionsDisallowedGroups' => [
'default' => [
'checkuser',
'smwadministrator',
'oversight',
'steward',
'staff',
'suppress',
'techteam',
'trustandsafety',
],
],
'wgManageWikiPermissionsDefaultPrivateGroup' => [
'default' => 'member',
],
'wgWhitelistRead' => [
'default' => [
'Special:UserLogin',
'Special:UserLogout',
'Special:CreateAccount',
'Main Page',
],
],
'wgWhitelistReadRegexp' => [
'default' => [
'/^(Special):CentralAutoLogin.*/',
'/^(Special):CentralLogin.*/',
],
],
'wgManageWikiExtensionsDefault' => [
'default' => [
'categorytree',
'cite',
'citethispage',
'codeeditor',
'codemirror',
'darkmode',
'globaluserpage',
'minervaneue',
'mobilefrontend',
'syntaxhighlight_geshi',
'textextracts',
'urlshortener',
'wikiseo',
],
],
'wgUseImageMagick' => [
'default' => true,
],
'wgImageMagickConvertCommand' => [
'default' => '/usr/bin/convert',
],
'wgSharedTables' => [
'default' => [],
],
'wgEnableUploads' => [
'default' => true,
],
'+wgVirtualDomainsMapping' => [
'default' => [
'virtual-botpasswords' => [
'db' => 'centralauth',
],
'virtual-centralauth' => [
'db' => 'centralauth',
],
'virtual-globalblocking' => [
'db' => 'centralauth',
],
'virtual-oathauth' => [
'db' => 'centralauth',
],
'virtual-importdump' => [
'db' => 'testwiki',
],
'virtual-createwiki' => [
'db' => 'wikidb',
],
'virtual-createwiki-central' => [
'db' => 'testwiki',
],
'virtual-requestssl' => [
'db' => 'centralauth',
],
],
],
];
</syntaxhighlight>
<li>Remove $wgServer, $wgSitename, $wgLanguageCode, $wgLocaltimezone, $wgLogos, $wgDBname definition.</li>
<li>Kick cache through <code>rm -rf cw_cache/*</code></li>
<li>Run update script with <code>php maintenance/run update --wiki testwiki</code> . </li>
<li>Make sure you can access the wiki without error.</li>
<li>Have a cup of coffee.</li>
<li>Get ManageWikiExtensions.php and place /var/www/mediawiki/ManageWikiExtensions.php from https://github.com/miraheze/mw-config/blob/master/ManageWikiExtensions.php .</li>
<li>Get ManageWikiNamespaces.php and place /var/www/mediawiki/ManageWikiNamespaces.php from https://github.com/miraheze/mw-config/blob/master/ManageWikiNamespaces.php .</li>
<li>Get ManageWikiNamespaces.php and place /var/www/mediawiki/ManageWikiSettings.php from https://github.com/miraheze/mw-config/blob/master/ManageWikiSettings.php .</li>
<li>Put <code>require_once "$IP/ManageWikiExtensions.php";</code> to LocalSettings. Put under $wgConf->settings definition.</li>
<li>Put this to LocalSettings. Put under ManageWikiExtensions.php loading.</li>
<syntaxhighlight lang="php">
$globals = MirahezeFunctions::getConfigGlobals();
// phpcs:ignore MediaWiki.Usage.ForbiddenFunctions.extract
extract($globals);
</syntaxhighlight>
<li>Install [[mw:Extension:ManageWiki]].</li>
<ol>
<li>Download and extract.</li>
<li>Put <code>$wgManageWiki = ['cdb' => false, 'core' => true, 'extensions' => true, 'namespaces' => true, 'permissions' => true, 'settings' => true];</code> to LocalSettings. Put JUST ABOVE <code>require_once "$IP/MirahezeFunctions.php";</code>.</li>
<li>Run these commands.</li>
<syntaxhighlight>
php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/mw_namespaces.sql
php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/mw_permissions.sql
php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/mw_settings.sql
php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/defaults/mw_namespaces.sql
php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/defaults/mw_permissions.sql
</syntaxhighlight>
<li>Put <code>wfLoadExtension( 'ManageWiki' );</code> to LocalSettings. Put ABOVE <code>require_once "$IP/MirahezeFunctions.php";</code></li>
<li>Move <code>wfLoadExtension( 'CreateWiki' );</code> to above <code>wfLoadExtension( 'ManageWiki' );</code>.</li>
<li>Move all wfLoadExtension and wfLoadSkin to above <code>wfLoadExtension( 'CreateWiki' );</code>.</li>
<li>Run update script with <code>php maintenance/run update --wiki testwiki</code> . </li>
</ol>
<li>Have a cup of coffee.</li>
<li>Put this to LocalSettings. Put BELOW <code>extract($globals);</code>.</li>
<syntaxhighlight lang="php">
$wi->loadExtensions();
require_once __DIR__ . '/ManageWikiNamespaces.php';
require_once __DIR__ . '/ManageWikiSettings.php';
</syntaxhighlight>
<li>Log in to the wiki using the account you used during installation.</li>
<li>Put the below to LocalSettings. Put at bottom.</li>
<syntaxhighlight lang="php">
$wgHooks['CreateWikiDataFactoryBuilder'][] = 'MirahezeFunctions::onCreateWikiDataFactoryBuilder';
$wgHooks['CreateWikiGenerateDatabaseLists'][] = 'MirahezeFunctions::onGenerateDatabaseLists';
$wgHooks['ManageWikiCoreAddFormFields'][] = 'MirahezeFunctions::onManageWikiCoreAddFormFields';
$wgHooks['ManageWikiCoreFormSubmission'][] = 'MirahezeFunctions::onManageWikiCoreFormSubmission';
$wgHooks['MediaWikiServices'][] = 'MirahezeFunctions::onMediaWikiServices';
</syntaxhighlight>
<li>Put <code>$wgGroupPermissions['bureaucrat']['createwiki'] = true;</code> to LocalSettings. Put very bottom.</li>
<li>Put <code>$wgGroupPermissions['*']['createaccount'] = true;</code> to LocalSettings. Put very bottom.</li>
<li>Create new account for enabling CentralAuth. (don't switch account)</li>
<li>Go to Special:CreateWiki, Database name <code>metawiki</code>, Requester the account you just created, Sitename MetaWiki. Create wiki. </li>
<li>Wait a minute, go to meta.yourdomain.tld and verify that the site exists.</li>
<li>Verify that ManageWiki is working properly and that installation of extensions and assignment of permissions is functional.</li>
<li>Congratulations!</li>
<li>Change wgCreateWikiGlobalWiki to metawiki (LocalSettings)</li>
<li>Change CENTRAL_DATABASE to metawiki (MirahezeFunctions)</li>
<li>Run <code>php maintenance/run CreateWiki:deleteWiki --wiki testwiki --deletewiki testwiki --delete</code> to delete testwiki. (The TestWiki at this point has a lot of bugs)</li>
<li>Enter MySQL and Drop database testwiki.</li>
<li>Remove this from LocalSettings.php.</li>
<syntaxhighlight lang="php">
$wgGroupPermissions['bureaucrat']['createwiki'] = true;
$wgGroupPermissions['*']['createaccount'] = true;
</syntaxhighlight>
<li>Run the below in MySQL as the wiki may not be fully deleted.</li>
<syntaxhighlight lang="sql">
DELETE FROM localuser WHERE lu_wiki='wikidb';
DELETE FROM localnames WHERE ln_wiki='wikidb';
</syntaxhighlight>
<li>Crreatewiki will create empty databases so to fix this you need to do wgCreateWikiSQLfiles -> wgCreateWikiSQLFiles and make job queue is running </li>
<li>ALL DONE!</li>
</ol>
== Common Errors ==
You can view error in /var/log/nginx/mediawiki_error.log
=== Uncaught InvalidArgumentException: Database must be null or a non-empty string. ===
Sometimes, especially after purging the cache, the subdomain is lost at some point while accessing the wiki. Please re-add the subdomain.
=== Permission denied ===
Sometimes after performing maintenance scripts, you may encounter this error, which may be hidden under a blank screen. To fix this, try giving cw_cache 777 permission or chown it to www-data again. If it appears the relevant file is outside cw_cache, you may have to chmod or chown another folder, which may be /var/www/mediawiki.
=== Wikis not creating fully ===
Create opcache-blacklist.txt in your PHP config folder with the contents as <code> /var/www/mediawiki</code> and add <code>opcache.blacklist_filename=(your PHP folder)/opcache-blacklist.txt</code> to your php.ini.

Latest revision as of 03:00, 27 December 2024

 Note: This memo is an slightly modified version of the memo originally made by Waki285 from Miraheze Meta at mh:meta:User:Waki285/Install CreateWiki and ManageWiki on your wiki to make it work with newer CreateWiki versions.
 Note: This is less of a "tutorial" and more of a "memo" on the means by which I have been successful. Disclaimer: I will not be liable for any damages caused by this memo.
 Note: This was done for production, but could also be used for development as an extension development.

Prerequisites

This is the environment in which I have succeeded. I am not sure if I would be successful in any other environment than this.

  • VPS with free IP port open and sudo privileges (you may have to sudo the commands if you're not root)
  • Ubuntu Server 22.02
  • Nginx
  • MySQL or MariaDB
  • Cloudflare (optional)
  • Domain with ability to add A wildcard record

Procedure

  1. Install packages such as PHP and MySQL, which are required for a normal MediaWiki installation. We will also purchase a domain and connect it to Cloudflare.
    1. Run add-apt-repository ppa:ondrej/php
    2. Run apt install php
    3. Run apt install php-fpm
    4. Run apt install nginx
    5. Run apt install php-mbstring php-xml php-intl
    6. Run apt install php-mysql
    7. Run apt install mariadb-server
    8. Run mysql_secure_installation
    9. If you would like to create a seperate MySQL user for authentication, run CREATE USER 'mediawiki'@'localhost' IDENTIFIED BY 'password'; and GRANT ALL PRIVILEGES ON *.* TO 'mediawiki'@'localhost' WITH GRANT OPTION;
  2. Extract MediaWiki to /var/www/mediawiki.
  3. Enter MySQL and create a database named "testwiki".
  4. Write the following in /etc/nginx/conf.d/mediawiki.conf (the file name can be anything, but it should end with .conf), save it, and reload nginx with systemctl reload nginx.
  5. server {
        listen 80;
        listen [::]:80;
        server_name .yourdomain.tld; # Make sure to insert '.' first to your domain
    
        root /var/www/mediawiki;
        index index.php index.html index.htm;
    
        location / {
            rewrite ^/$ /wiki/ permanent;
        }
    
        location /wiki/ {
            rewrite ^/wiki/([^\?]*) /index.php?title=$1&$args last;
        }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;  # Make sure to change it to your PHP version
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    
        location ~ ^/cw_cache/ {
            deny all;
        }
        
        error_log /var/log/nginx/mediawiki_error.log;
        access_log /var/log/nginx/mediawiki_access.log;
    }
    
  6. Remember to open port 80 if you are using a firewall.
  7. Go to Cloudflare if you're using it, or otherwise your domain registry, and add the following to your DNS.
  8. Type: A Name: * IPv4 address: Your VPS IP Proxy status: Proxied (if using Cloudflare)
  9. Go to the Cloudflare SSL/TLS settings and set the SSL/TLS encryption mode to Flexible. (if using Cloudflare, otherwise set up SSL, maybe with Let's Encrypt)
    1. If you're not using Cloudflare and would like to use certbot with Let's Encrypt, follow the below steps.
    2. Install certbot with sudo snap install certbot --classic
  10. At this point, go to test.[yourdomain.tld] and you should see "LocalSettings.php not found. Please set up the wiki first."
  11. Click "set up the wiki", set up the wiki as usual, but install the extensions AbuseFilter, Interwiki, Echo, and WikiEditor. DON'T INSTALL MinervaNeue. Set the database name to "testwiki" created earlier and leave the table prefix blank.
  12. After setup is complete and the downloaded LocalSettings.php is in place, verify that MediaWiki starts properly.
  13. Install mw:Extension:AntiSpoof. Follow the guide on the MediaWiki Extension page.
  14. Install mw:Extension:CheckUser. Follow the guide on the MediaWiki Extension page.
  15. mw:Extension:CentralAuth.
    1. Download and extract.
    2. Enter MySQL and create a database named centralauth.
    3. Put this to your LocalSettings.
    4. wfLoadExtension( 'CentralAuth' );
      $wgCentralAuthDatabase = 'centralauth';
      
    5. Run php maintenance/run.php sql --wikidb centralauth extensions/CentralAuth/schema/mysql/tables-generated.sql
    6. Run php maintenance/run.php sql --wikidb centralauth extensions/AntiSpoof/sql/mysql/tables-generated.sql
    7. Run php maintenance/run.php CentralAuth:migratePass0.php
    8. Run php maintenance/run.php CentralAuth:migratePass1.php
  16. Have a cup of coffee.
  17. Install mw:Extension:CreateWiki.
    1. Download and extract.
    2. Enter MySQL and create a database named wikidb.
    3. Put this to your LocalSettings.
    4. #wfLoadExtension( 'CreateWiki' );
      $wgCreateWikiDatabase = 'wikidb';
      
    5. Make cw_cache directory and give 777 permission.
    6. Put $wgCreateWikiCacheDirectory = 'cw_cache'; to your LocalSettings.
    7. Run these commands.
    8. php maintenance/run sql --wikidb wikidb extensions/CreateWiki/sql/cw_wikis.sql
      php maintenance/run sql --wikidb wikidb extensions/CreateWiki/sql/cw_comments.sql
      php maintenance/run sql --wikidb wikidb extensions/CreateWiki/sql/cw_requests.sql
      
    9. Remove # from #wfLoadExtension( 'CreateWiki' );.
    10. Create SetupCreateWiki.php and paste this, and change wiki_url and database password.  Note: This script is copied and edited by https://github.com/miraheze/ci-scripts/blob/master/mediawiki/globals/setup-CreateWiki.php
    11. <?php
      
      # Protect against web entry
      if ( !defined( 'MEDIAWIKI' ) ) {
              exit;
      }
      
      use MediaWiki\MediaWikiServices;
      use Miraheze\CreateWiki\WikiInitialize;
      use Wikimedia\Rdbms\DBQueryError;
      
      $wgWikimediaJenkinsCI = true;
      
      define( 'CW_DB', 'wikidb' );
      
      require_once "$IP/extensions/CreateWiki/includes/WikiInitialize.php";
      
      $wgHooks['MediaWikiServices'][] = 'insertWiki';
      
      function insertWiki( MediaWikiServices $services ) {
      	wfLoadConfiguration();
      	try {
      		if ( getenv( 'WIKI_CREATION_SQL_EXECUTED' ) ) {
      			return;
      		}
      
      		$db = wfInitDBConnection();
      
      		$db->selectDomain( 'wikidb' );
      		$db->newInsertQueryBuilder()
      			->insertInto( 'cw_wikis' )
      			->ignore()
      			->row( [
      				'wiki_dbname' => 'testwiki',
      				'wiki_dbcluster' => 'c1',
      				'wiki_sitename' => 'TestWiki',
      				'wiki_language' => 'en',
      				'wiki_private' => (int)0,
      				'wiki_creation' => $db->timestamp(),
      				'wiki_category' => 'uncategorised',
      				'wiki_closed' => (int)0,
      				'wiki_deleted' => (int)0,
      				'wiki_locked' => (int)0,
      				'wiki_inactive' => (int)0,
      				'wiki_inactive_exempt' => (int)0,
      				'wiki_url' => 'https://test.yourdomain.tld', # CHANGE THIS
      			] )
      			->caller( __METHOD__ )
      			->execute();
      
      		putenv( 'WIKI_CREATION_SQL_EXECUTED=true' );
      	} catch ( DBQueryError $e ) {
      		return;
      	}
      }
      
      function wfLoadConfiguration() {
      	global $wgCreateWikiGlobalWiki, $wgCreateWikiDatabase,
      		$wgCreateWikiCacheDirectory, $wgConf;
      
      	$wgCreateWikiGlobalWiki = 'wikidb';
      	$wgCreateWikiDatabase = 'wikidb';
      	$wgCreateWikiCacheDirectory = MW_INSTALL_PATH . '/cache';
      
      	$wi = new WikiInitialize();
      
      	$wi->setVariables(
      		MW_INSTALL_PATH . '/cache',
      		[
      			''
      		],
      		[
      			'127.0.0.1' => ''
      		]
      	);
      
      	$wi->config->settings += [
      		'cwClosed' => [
      			'default' => false,
      		],
      		'cwInactive' => [
      			'default' => false,
      		],
      		'cwPrivate' => [
      			'default' => false,
      		],
      		'cwExperimental' => [
      			'default' => false,
      		],
      	];
      
      	$wi->readCache();
      	$wi->config->extractAllGlobals( $wi->dbname );
      	$wgConf = $wi->config;
      }
      
      function wfInitDBConnection() {
      	return MediaWikiServices::getInstance()->getDatabaseFactory()->create( 'mysql', [
      		'host' => $GLOBALS['wgDBserver'],
      		'user' => 'root',
      		'password' => 'y0ur p@$$w0rd' # CHANGE THIS
      	] );
      }
      
      ?>
      
    12. Insert require_once "$IP/SetupCreateWiki.php"; TOP of LocalSettings.php (below <?php)
    13. Visit tets.yourdomain.tld. You will get an MediaWiki error message. Ignore it and check if TestWiki exists in wikidb.cw_wikis using e.g. phpMyAdmin.
    14. Remove require_once "$IP/SetupCreateWiki.php";
    15. .
  18. Get MirahezeFunctions.php from https://github.com/miraheze/mw-config/blob/master/initialise/MirahezeFunctions.php and paste it to /var/www/mediawiki/MirahezeFunctions.php
  19. Modify MirahezeFunctions.php. Please change default. Not sure if you need to remove beta on all of the following. I did not remove it.
    1. Change ALLOWED_DOMAINS and DEFAULT_SERVER to yourdomain.tld
    2. Change CACHE_DIRECTORY to /var/www/mediawiki/cw_cache
    3. Change CENTRAL_DATABASE to testwiki
    4. Change GLOBAL_DATABASE to wikidb
    5. Change MEDIAWIKI_DIRECTORY to /var/www/mediawiki/
    6. Change path to correct path for LocalSettings.php, ManageWikiExtensions.php, ManageWikiNamespaces.php, ManageWikiSettings.php and extensions(skins) folder path. For Example: '/../LocalSettings.php' → '/LocalSettings.php', '/../ManageWikiExtensions.php' → '/ManageWikiExtensions.php', self::MEDIAWIKI_DIRECTORY . $this->version . '/extensions/*/extension*.json'self::MEDIAWIKI_DIRECTORY . '/extensions/*/extension*.json'
  20. Add this to LocalSettings. Put BEFORE loading extensions
  21. require_once "$IP/MirahezeFunctions.php";
    $wi = new MirahezeFunctions();
    
  22. Add this to LocalSettings.php Put JUST UNDER $wi = new MirahezeFunctions();. Remember to change yourdomain.tld
  23. $wgConf->settings += [
    	'wgCentralAuthDatabase' => [
    		'default' => 'centralauth',
    	],
    
    	'wgCreateWikiUseJobQueue' => [
    		'default' => true,
    	],
    	'wgCreateWikiSubdomain' => [
    		'default' => 'yourdomain.tld',
    	],
    	'wgCreateWikiUseClosedWikis' => [
    		'default' => true,
    	],
    	'wgCreateWikiUseCustomDomains' => [
    		'default' => true,
    	],
    	'wgCreateWikiUseEchoNotifications' => [
    		'default' => true,
    	],
    	'wgCreateWikiUseExperimental' => [
    		'default' => true,
    	],
    	'wgCreateWikiUseInactiveWikis' => [
    		'default' => true,
    	],
    	'wgCreateWikiUsePrivateWikis' => [
    		'default' => true,
    	],
    	'wgCreateWikiCacheDirectory' => [
    		'default' => 'cw_cache',
    	],
    	'wgCreateWikiDatabaseSuffix' => [
    		'default' => 'wiki',
    	],
    	'wgCreateWikiDisableRESTAPI' => [
    		'default' => true,
    		'metawiki' => false,
    	],
    	'wgCreateWikiGlobalWiki' => [
    		'default' => 'testwiki',
    	],
    	'wgCreateWikiEmailNotifications' => [
    		'default' => true,
    	],
    
    	'wgFileExtensions' => [
    		'default' => [
    			'djvu',
    			'gif',
    			'ico',
    			'jpg',
    			'jpeg',
    			'ogg',
    			'pdf',
    			'png',
    			'svg',
    			'webp',
    		],
    	],
    	'wgArticlePath' => [
    		'default' => '/wiki/$1',
    	],
    	'wgScriptPath' => [
    		'default' => '',
    	],
    	'wgUsePathInfo' => [
    		'default' => true,
    	],
    	'wgResourceBasePath' => [
    		'default' => '',
    	],
    	'wgCreateWikiSQLfiles' => [
    		'default' => [
    			"$IP/maintenance/tables-generated.sql",
    			"$IP/extensions/AbuseFilter/db_patches/mysql/tables-generated.sql",
    			"$IP/extensions/AntiSpoof/sql/mysql/tables-generated.sql",
    			#"$IP/extensions/BetaFeatures/sql/tables-generated.sql",
    			#"$IP/extensions/CheckUser/schema/mysql/tables-generated.sql",
    			#"$IP/extensions/DataDump/sql/data_dump.sql",
    			"$IP/extensions/Echo/sql/mysql/tables-generated.sql",
    			#"$IP/extensions/GlobalBlocking/sql/mysql/tables-generated-global_block_whitelist.sql",
    			"$IP/extensions/OATHAuth/sql/mysql/tables-generated.sql",
    			#"$IP/extensions/RottenLinks/sql/rottenlinks.sql",
    			#"$IP/extensions/UrlShortener/schemas/tables-generated.sql",
    		],
    	],
    	'wgManageWikiPermissionsAdditionalAddGroups' => [
    		'default' => [],
    	],
    	'wgManageWikiPermissionsAdditionalRights' => [
    		'default' => [
    			'*' => [
    				'autocreateaccount' => true,
    				'read' => true,
    				'oathauth-enable' => true,
    				'viewmyprivateinfo' => true,
    				'editmyoptions' => true,
    				'editmyprivateinfo' => true,
    				'editmywatchlist' => true,
    				'writeapi' => true,
    			],
    			'checkuser' => [
    				'checkuser' => true,
    				'checkuser-log' => true,
    				'abusefilter-privatedetails' => true,
    				'abusefilter-privatedetails-log' => true,
    			],
    			'suppress' => [
    				'abusefilter-hidden-log' => true,
    				'abusefilter-hide-log' => true,
    				'browsearchive' => true,
    				'deletedhistory' => true,
    				'deletedtext' => true,
    				'deletelogentry' => true,
    				'deleterevision' => true,
    				'hideuser' => true,
    				'suppressionlog' => true,
    				'suppressrevision' => true,
    				'viewsuppressed' => true,
    			],
    			'steward' => [
    				'userrights' => true,
    			],
    			'user' => [
    				'mwoauthmanagemygrants' => true,
    				'user' => true,
    			],
    		],
    		'+metawiki' => [
    			'steward' => [
    				'abusefilter-modify-global' => true,
    				'centralauth-lock' => true,
    				'centralauth-suppress' => true,
    				'centralauth-rename' => true,
    				'centralauth-unmerge' => true,
    				'createwiki' => true,
    				'createwiki-deleterequest' => true,
    				'globalblock' => true,
    				'handle-import-request-interwiki' => true,
    				'handle-import-requests' => true,
    				'managewiki-core' => true,
    				'managewiki-extensions' => true,
    				'managewiki-namespaces' => true,
    				'managewiki-permissions' => true,
    				'managewiki-settings' => true,
    				'managewiki-restricted' => true,
    				'noratelimit' => true,
    				'oathauth-verify-user' => true,
    				'userrights' => true,
    				'userrights-interwiki' => true,
    				'globalgroupmembership' => true,
    				'globalgrouppermissions' => true,
    				'view-private-import-requests' => true,
    			],
    		]
    	],
    	'wgManageWikiPermissionsAdditionalRemoveGroups' => [
    		'default' => [],
    	],
    	'wgManageWikiPermissionsDisallowedRights' => [
    		'default' => [
    			'any' => [
    				'abusefilter-hide-log',
    				'abusefilter-hidden-log',
    				'abusefilter-modify-global',
    				'abusefilter-private',
    				'abusefilter-private-log',
    				'abusefilter-privatedetails',
    				'abusefilter-privatedetails-log',
    				'aft-oversighter',
    				'autocreateaccount',
    				'bigdelete',
    				'centralauth-createlocal',
    				'centralauth-lock',
    				'centralauth-suppress',
    				'centralauth-rename',
    				'centralauth-unmerge',
    				'checkuser',
    				'checkuser-log',
    				'createwiki',
    				'createwiki-deleterequest',
    				'createwiki-suppressionlog',
    				'createwiki-suppressrequest',
    				'editincidents',
    				'editothersprofiles-private',
    				'flow-suppress',
    				'generate-random-hash',
    				'globalblock',
    				'globalblock-exempt',
    				'globalgroupmembership',
    				'globalgrouppermissions',
    				'handle-import-request-interwiki',
    				'handle-import-requests',
    				'handle-pii',
    				'hideuser',
    				'investigate',
    				'ipinfo',
    				'ipinfo-view-basic',
    				'ipinfo-view-full',
    				'ipinfo-view-log',
    				'managewiki-restricted',
    				'managewiki-editdefault',
    				'moderation-checkuser',
    				'mwoauthmanageconsumer',
    				'mwoauthmanagemygrants',
    				'mwoauthsuppress',
    				'mwoauthviewprivate',
    				'mwoauthviewsuppressed',
    				'oathauth-api-all',
    				'oathauth-enable',
    				'oathauth-disable-for-user',
    				'oathauth-verify-user',
    				'oathauth-view-log',
    				'renameuser',
    				'request-import',
    				'requestwiki',
    				'siteadmin',
    				'securepoll-view-voter-pii',
    				'smw-admin',
    				'smw-patternedit',
    				'smw-viewjobqueuewatchlist',
    				'stopforumspam',
    				'suppressionlog',
    				'suppressrevision',
    				'themedesigner',
    				'titleblacklistlog',
    				'updatepoints',
    				'userrights',
    				'userrights-interwiki',
    				'view-private-import-requests',
    				'viewglobalprivatefiles',
    				'viewpmlog',
    				'viewsuppressed',
    				'writeapi',
    			],
    			'user' => [
    				'autoconfirmed',
    				'noratelimit',
    				'skipcaptcha',
    				'managewiki-core',
    				'managewiki-extensions',
    				'managewiki-namespaces',
    				'managewiki-permissions',
    				'managewiki-settings',
    				'globalblock-whitelist',
    				'ipblock-exempt',
    				'interwiki',
    			],
    			'*' => [
    				'read',
    				'skipcaptcha',
    				'torunblocked',
    				'centralauth-merge',
    				'generate-dump',
    				'editsitecss',
    				'editsitejson',
    				'editsitejs',
    				'editusercss',
    				'edituserjson',
    				'edituserjs',
    				'editmyoptions',
    				'editmyprivateinfo',
    				'editmywatchlist',
    				'globalblock-whitelist',
    				'interwiki',
    				'ipblock-exempt',
    				'viewmyprivateinfo',
    				'viewmywatchlist',
    				'managewiki-core',
    				'managewiki-extensions',
    				'managewiki-namespaces',
    				'managewiki-permissions',
    				'managewiki-settings',
    				'noratelimit',
    				'autoconfirmed',
    			],
    		],
    	],
    	'wgManageWikiPermissionsDisallowedGroups' => [
    		'default' => [
    			'checkuser',
    			'smwadministrator',
    			'oversight',
    			'steward',
    			'staff',
    			'suppress',
    			'techteam',
    			'trustandsafety',
    		],
    	],
    	'wgManageWikiPermissionsDefaultPrivateGroup' => [
    		'default' => 'member',
    	],
    
    	'wgWhitelistRead' => [
    		'default' => [
    			'Special:UserLogin',
    			'Special:UserLogout',
    			'Special:CreateAccount',
    			'Main Page',
    		],
    	],
    	'wgWhitelistReadRegexp' => [
    		'default' => [
    			'/^(Special):CentralAutoLogin.*/',
    			'/^(Special):CentralLogin.*/',
    		],
    	],
    
    	'wgManageWikiExtensionsDefault' => [
    		'default' => [
    			'categorytree',
    			'cite',
    			'citethispage',
    			'codeeditor',
    			'codemirror',
    			'darkmode',
    			'globaluserpage',
    			'minervaneue',
    			'mobilefrontend',
    			'syntaxhighlight_geshi',
    			'textextracts',
    			'urlshortener',
    			'wikiseo',
    		],
    	],
    
    	'wgUseImageMagick' => [
    		'default' => true,
    	],
    	'wgImageMagickConvertCommand' => [
    		'default' => '/usr/bin/convert',
    	],
    
    	'wgSharedTables' => [
    		'default' => [],
    	],
    
    	'wgEnableUploads' => [
    		'default' => true,
    	],
    
    	'+wgVirtualDomainsMapping' => [
    		'default' => [
    			'virtual-botpasswords' => [
    				'db' => 'centralauth',
    			],
    			'virtual-centralauth' => [
    				'db' => 'centralauth',
    			],
    			'virtual-globalblocking' => [
    				'db' => 'centralauth',
    			],
    			'virtual-oathauth' => [
    				'db' => 'centralauth',
    			],
    			'virtual-importdump' => [
    				'db' => 'testwiki',
    			],
    			'virtual-createwiki' => [
    				'db' => 'wikidb',
    			],
     			'virtual-createwiki-central' => [
    				'db' => 'testwiki',
    			],
    			'virtual-requestssl' => [
    				'db' => 'centralauth',
    			],
    		],
    	],
    ];
    
  24. Remove $wgServer, $wgSitename, $wgLanguageCode, $wgLocaltimezone, $wgLogos, $wgDBname definition.
  25. Kick cache through rm -rf cw_cache/*
  26. Run update script with php maintenance/run update --wiki testwiki .
  27. Make sure you can access the wiki without error.
  28. Have a cup of coffee.
  29. Get ManageWikiExtensions.php and place /var/www/mediawiki/ManageWikiExtensions.php from https://github.com/miraheze/mw-config/blob/master/ManageWikiExtensions.php .
  30. Get ManageWikiNamespaces.php and place /var/www/mediawiki/ManageWikiNamespaces.php from https://github.com/miraheze/mw-config/blob/master/ManageWikiNamespaces.php .
  31. Get ManageWikiNamespaces.php and place /var/www/mediawiki/ManageWikiSettings.php from https://github.com/miraheze/mw-config/blob/master/ManageWikiSettings.php .
  32. Put require_once "$IP/ManageWikiExtensions.php"; to LocalSettings. Put under $wgConf->settings definition.
  33. Put this to LocalSettings. Put under ManageWikiExtensions.php loading.
  34. $globals = MirahezeFunctions::getConfigGlobals();
    
    // phpcs:ignore MediaWiki.Usage.ForbiddenFunctions.extract
    extract($globals);
    
  35. Install mw:Extension:ManageWiki.
    1. Download and extract.
    2. Put $wgManageWiki = ['cdb' => false, 'core' => true, 'extensions' => true, 'namespaces' => true, 'permissions' => true, 'settings' => true]; to LocalSettings. Put JUST ABOVE require_once "$IP/MirahezeFunctions.php";.
    3. Run these commands.
    4. php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/mw_namespaces.sql
      php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/mw_permissions.sql
      php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/mw_settings.sql
      php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/defaults/mw_namespaces.sql
      php maintenance/run sql --wikidb wikidb --wiki testwiki extensions/ManageWiki/sql/defaults/mw_permissions.sql
    5. Put wfLoadExtension( 'ManageWiki' ); to LocalSettings. Put ABOVE require_once "$IP/MirahezeFunctions.php";
    6. Move wfLoadExtension( 'CreateWiki' ); to above wfLoadExtension( 'ManageWiki' );.
    7. Move all wfLoadExtension and wfLoadSkin to above wfLoadExtension( 'CreateWiki' );.
    8. Run update script with php maintenance/run update --wiki testwiki .
  36. Have a cup of coffee.
  37. Put this to LocalSettings. Put BELOW extract($globals);.
  38. $wi->loadExtensions();
    require_once __DIR__ . '/ManageWikiNamespaces.php';
    require_once __DIR__ . '/ManageWikiSettings.php';
    
  39. Log in to the wiki using the account you used during installation.
  40. Put the below to LocalSettings. Put at bottom.
  41. $wgHooks['CreateWikiDataFactoryBuilder'][] = 'MirahezeFunctions::onCreateWikiDataFactoryBuilder';
    $wgHooks['CreateWikiGenerateDatabaseLists'][] = 'MirahezeFunctions::onGenerateDatabaseLists';
    $wgHooks['ManageWikiCoreAddFormFields'][] = 'MirahezeFunctions::onManageWikiCoreAddFormFields';
    $wgHooks['ManageWikiCoreFormSubmission'][] = 'MirahezeFunctions::onManageWikiCoreFormSubmission';
    $wgHooks['MediaWikiServices'][] = 'MirahezeFunctions::onMediaWikiServices';
    
  42. Put $wgGroupPermissions['bureaucrat']['createwiki'] = true; to LocalSettings. Put very bottom.
  43. Put $wgGroupPermissions['*']['createaccount'] = true; to LocalSettings. Put very bottom.
  44. Create new account for enabling CentralAuth. (don't switch account)
  45. Go to Special:CreateWiki, Database name metawiki, Requester the account you just created, Sitename MetaWiki. Create wiki.
  46. Wait a minute, go to meta.yourdomain.tld and verify that the site exists.
  47. Verify that ManageWiki is working properly and that installation of extensions and assignment of permissions is functional.
  48. Congratulations!
  49. Change wgCreateWikiGlobalWiki to metawiki (LocalSettings)
  50. Change CENTRAL_DATABASE to metawiki (MirahezeFunctions)
  51. Run php maintenance/run CreateWiki:deleteWiki --wiki testwiki --deletewiki testwiki --delete to delete testwiki. (The TestWiki at this point has a lot of bugs)
  52. Enter MySQL and Drop database testwiki.
  53. Remove this from LocalSettings.php.
  54. $wgGroupPermissions['bureaucrat']['createwiki'] = true;
    $wgGroupPermissions['*']['createaccount'] = true;
    
  55. Run the below in MySQL as the wiki may not be fully deleted.
  56. DELETE FROM localuser WHERE lu_wiki='wikidb';
    DELETE FROM localnames WHERE ln_wiki='wikidb';
    
  57. Crreatewiki will create empty databases so to fix this you need to do wgCreateWikiSQLfiles -> wgCreateWikiSQLFiles and make job queue is running
  58. ALL DONE!

Common Errors

You can view error in /var/log/nginx/mediawiki_error.log

Uncaught InvalidArgumentException: Database must be null or a non-empty string.

Sometimes, especially after purging the cache, the subdomain is lost at some point while accessing the wiki. Please re-add the subdomain.

Permission denied

Sometimes after performing maintenance scripts, you may encounter this error, which may be hidden under a blank screen. To fix this, try giving cw_cache 777 permission or chown it to www-data again. If it appears the relevant file is outside cw_cache, you may have to chmod or chown another folder, which may be /var/www/mediawiki.

Wikis not creating fully

Create opcache-blacklist.txt in your PHP config folder with the contents as /var/www/mediawiki and add opcache.blacklist_filename=(your PHP folder)/opcache-blacklist.txt to your php.ini.