MediaWiki: Difference between revisions

From NixOS Wiki
imported>Threddast
(Make comment about admin account more visible)
imported>Webxem
No edit summary
Line 7: Line 7:
services.mediawiki = {
services.mediawiki = {
   enable = true;
   enable = true;
   name = "Sample MediaWiki instance";
  # Prior to NixOS 24.05, there is a admin name bug that prevents using spaces in the mediawiki name https://github.com/NixOS/nixpkgs/issues/298902
   name = "Sample_MediaWiki";
   httpd.virtualHost = {
   httpd.virtualHost = {
     hostName = "example.com";
     hostName = "example.com";
     adminAddr = "admin@example.com";
     adminAddr = "admin@example.com";
   };
   };
   # File for initial password for the admin account.  
   # Administrator account username is admin.
  # Admin account username is Wiki
  # Set initial password to "cardbotnine" for the account admin.
   passwordFile = "/var/mediawiki/passwordFile";  
   passwordFile = pkgs.writeText "password" "cardbotnine";
   extraConfig = ''
   extraConfig = ''
     # Disable anonymous editing
     # Disable anonymous editing

Revision as of 10:12, 28 March 2024

MediaWiki (wikipedia:en:MediaWiki) is available as a module.

Configuration Examples

Small Configuration

services.mediawiki = {
  enable = true;
  # Prior to NixOS 24.05, there is a admin name bug that prevents using spaces in the mediawiki name https://github.com/NixOS/nixpkgs/issues/298902
  name = "Sample_MediaWiki";
  httpd.virtualHost = {
    hostName = "example.com";
    adminAddr = "admin@example.com";
  };
  # Administrator account username is admin.
  # Set initial password to "cardbotnine" for the account admin.
  passwordFile = pkgs.writeText "password" "cardbotnine";
  extraConfig = ''
    # Disable anonymous editing
    $wgGroupPermissions['*']['edit'] = false;
  '';

  extensions = {
    # some extensions are included and can enabled by passing null
    VisualEditor = null;

    # https://www.mediawiki.org/wiki/Extension:TemplateStyles
    TemplateStyles = pkgs.fetchzip {
      url = "https://extdist.wmflabs.org/dist/extensions/TemplateStyles-REL1_40-c639c7a.tar.gz";
      hash = "sha256-YBL0Cs4hDSNnoutNJSJBdLsv9zFWVkzo7m5osph8QiY=";
    };
  };
};

Web Server

By default, the services.mediawiki module creates a services.httpd.virtualHost which can be configured via the services.mediawiki.httpd.virtualHost submodule.

If you are using another web server (like Nginx), you can configure MediaWiki for a reverse proxy with the services.mediawiki.virtualHost.listen option:

services.mediawiki.httpd.virtualHost.listen = [
  {
    ip = "127.0.0.1";
    port = 8080;
    ssl = false;
  }
];

Alternatively, services.mediawiki.webserver can be set to "nginx" to use nginx instead of apache.

Troubleshooting

Edit php.ini

An fpm pool is automatically created when Mediawiki is enabled. The php.ini file can be modified by using phpOptions. The following example shows how to increase the allowed file upload size.

services.phpfpm.pools.mediawiki.phpOptions = ''
    upload_max_filesize = 10M
    post_max_size = 15M
'';

See Also