MediaWiki Manual:Configuration settings
- MediaWiki Manual:Configuration settings
This article details the core configuration settings available in MediaWiki, aimed at beginners seeking to understand and modify their wiki's behavior. Understanding these settings is crucial for tailoring MediaWiki to your specific needs, from basic appearance to advanced functionality. We will cover the primary configuration file, `LocalSettings.php`, and the key settings within it. This guide assumes you have a basic understanding of accessing your server's files. Always back up your `LocalSettings.php` file before making any changes!
Introduction to `LocalSettings.php`
The `LocalSettings.php` file is the heart of your MediaWiki installation's configuration. It's a PHP script that contains variables defining how MediaWiki operates. This file is *not* present in a fresh MediaWiki download; it’s created during the installation process. The installer generates a basic `LocalSettings.php` file, which you then customize.
The location of `LocalSettings.php` is typically in the root directory of your MediaWiki installation. Accessing and editing this file requires server access, usually via FTP, SSH, or a file manager provided by your web hosting provider. Use a plain text editor (like Notepad++, Sublime Text, VS Code, or similar) to avoid introducing formatting issues. Avoid word processors like Microsoft Word.
Basic Configuration Settings
Let’s explore some of the most common and important configuration settings within `LocalSettings.php`.
- `$wgSitename` : This variable sets the name of your wiki, which appears in the page title, breadcrumbs, and other locations. Example: `$wgSitename = "My Awesome Wiki";` This is a fundamental setting for branding and identifying your wiki.
- `$wgServer` : Specifies the URL of your MediaWiki installation. This is vital for generating correct URLs for images, pages, and other resources. Example: `$wgServer = "https://www.example.com/wiki";` Ensure the protocol (http or https) matches your server configuration. Incorrect settings here can lead to broken links.
- `$wgScriptPath` : Defines the path to the `index.php` file, which is the entry point for your wiki. Usually, this is "/wiki" or just "/". Example: `$wgScriptPath = "/wiki";` This is crucial for correct URL generation. If your wiki is installed in the root directory, set this to "/".
- `$wgDBtype` : Specifies the database type your wiki uses (e.g., 'mysql', 'postgresql', 'mysqli'). Example: `$wgDBtype = 'mysql';` The installer usually sets this correctly.
- `$wgDBserver` : The hostname or IP address of your database server. Example: `$wgDBserver = 'localhost';`
- `$wgDBname` : The name of the database that MediaWiki uses. Example: `$wgDBname = 'my_wiki_db';`
- `$wgDBuser` : The username for accessing the database. Example: `$wgDBuser = 'my_wiki_user';`
- `$wgDBpassword` : The password for accessing the database. Example: `$wgDBpassword = 'my_secret_password';` *Keep this secure!*
- `$wgSecretKey` : A random string used for cryptographic operations, such as generating secure cookies and preventing cross-site request forgery (CSRF) attacks. *This is extremely important for security.* During installation, a random key is generated. If you suspect a compromise, change this immediately. You can generate a strong key using an online tool or a command-line utility.
- `$wgUploadDirectory` : Specifies the directory where uploaded files are stored. Example: `$wgUploadDirectory = "$IP/images";` `$IP` is a predefined variable representing the path to your MediaWiki installation.
- `$wgUploadPath` : The URL path to the upload directory. Example: `$wgUploadPath = "/images";`
User Management and Authentication
- `$wgAllowUserRegistration` : Determines whether users can create accounts themselves. Set to `true` to allow self-registration, `false` to disable it. Example: `$wgAllowUserRegistration = false;` Disabling self-registration can improve security but requires administrators to create accounts for all users. See User rights management for additional details.
- `$wgDefaultUserOptions` : Sets default user preferences for new accounts. This can include the default skin, language, and other settings. Example: `$wgDefaultUserOptions['skin'] = 'vector';`
- `$wgAuth` : Allows integration with external authentication providers, such as LDAP, OAuth, or OpenID Connect. This is a more advanced setting. See Extending authentication for more information. Integration with systems like [Auth0](https://auth0.com/) or [Keycloak](https://www.keycloak.org/) can streamline user management.
Appearance and Skin Settings
- `$wgDefaultSkin` : Sets the default skin for your wiki. Popular options include 'vector', 'monobook', 'modern', and 'timeless'. Example: `$wgDefaultSkin = 'vector';` Users can override this setting in their individual preferences. Consider the [accessibility](https://www.w3.org/WAI/standards-guidelines/wcag/) of different skins.
- `$wgLogos` : Allows you to define different logos for different user groups or conditions. This is a more advanced customization option.
- `$wgCustomNavigation` : Allows customizing the navigation menu. This can be used to add links to external websites or specific pages within your wiki.
Extension Configuration
MediaWiki’s functionality can be greatly extended through extensions. Each extension typically has its own configuration settings that must be defined in `LocalSettings.php`.
- To enable an extension, you usually need to include its configuration file using `require_once( "$IP/extensions/ExtensionName/ExtensionName.php" );`.
- Extension-specific settings are documented on the extension's page (usually on MediaWiki.org).
For example, to configure the VisualEditor extension, you might include lines like:
```php require_once( "$IP/extensions/VisualEditor/VisualEditor.php" ); $wgVisualEditorDefaultCategory = 'VisualEditor'; ```
See Extensions for more information on installing and configuring extensions. Popular extensions include [Semantic MediaWiki](https://semantic-mediawiki.org/), [REST API](https://www.mediawiki.org/wiki/Extension:REST_API), and [PageForms](https://www.mediawiki.org/wiki/Extension:PageForms).
Advanced Configuration Settings
- `$wgCacheDirectory` : Specifies the directory where MediaWiki stores cached data. Caching improves performance by reducing the load on the database and server. Ensure this directory is writable by the web server process.
- `$wgMainCacheType` : Sets the type of caching used by MediaWiki. Options include 'hash', 'memcached', and 'redis'. Memcached and Redis offer significantly better performance than the default 'hash' caching, especially for high-traffic wikis. See [Caching strategies](https://www.mediawiki.org/wiki/Manual:Caching) for more details.
- `$wgParserCacheTime` : Controls how long parsed pages are cached. Increasing this value can improve performance but may result in outdated content being displayed if changes are made to templates or pages.
- `$wgSessionCacheType` : Sets the type of session caching used. Options include 'file', 'database', and 'memcached'. Memcached is generally the fastest option.
- `$wgDebugToolbar` : Enables the debug toolbar, which provides useful information for developers and administrators. Disable this in production environments for security reasons.
- `$wgShowExceptionDetails` : Displays detailed error messages in the browser. This is helpful for debugging but should be disabled in production.
- `$wgEnableUTF8CJK` : Enables full support for Unicode characters, including Chinese, Japanese, and Korean (CJK). Enable this if your wiki will contain content in these languages.
- `$wgRateLimits` : Controls rate limits to prevent abuse and denial-of-service attacks. This allows you to limit the number of edits or API requests that a user can make within a certain time period. See [Rate limiting](https://www.mediawiki.org/wiki/Manual:$wgRateLimits) for details.
- `$wgSpamRegex` : Allows you to define regular expressions to detect and block spam. This is a crucial setting for preventing spam from polluting your wiki. Consider using [SpamPrevention](https://www.mediawiki.org/wiki/Extension:SpamPrevention) extension.
- `$wgRestrictUploads` : Controls which file types are allowed to be uploaded. This is important for security and preventing malicious files from being uploaded. Use a whitelist approach, only allowing explicitly permitted file types.
- `$wgFullTextIndexes` : Used for full-text search functionality. Proper configuration is critical for fast and accurate search results.
Security Considerations
- **Keep MediaWiki up to date:** Regularly update to the latest version to benefit from security patches.
- **Secure `LocalSettings.php`:** Ensure that `LocalSettings.php` is not publicly accessible.
- **Strong passwords:** Use strong passwords for database users and administrator accounts.
- **Enable HTTPS:** Use HTTPS to encrypt communication between the server and users.
- **Limit file uploads:** Restrict file uploads to only necessary file types.
- **Rate limiting:** Implement rate limiting to prevent abuse.
- **Regular backups:** Regularly back up your wiki's database and files.
- **Consider a Web Application Firewall (WAF):** A WAF can help protect your wiki from common web attacks.
Debugging Configuration Issues
If you encounter problems after modifying `LocalSettings.php`, here are some debugging tips:
- **Check the error logs:** MediaWiki logs errors to a file (usually `errors.log` in the `maintenance` directory). Examine this file for clues about what went wrong.
- **Enable debug mode:** Set `$wgDebug` to `true` to display more detailed error messages. *Remember to disable this in production.*
- **Check the web server logs:** The web server logs (e.g., Apache or Nginx) may contain errors related to PHP or MediaWiki.
- **Simplify changes:** If you made multiple changes, try reverting them one by one to identify the problematic setting.
- **Consult the MediaWiki documentation:** The official MediaWiki documentation is a valuable resource for troubleshooting configuration issues. See MediaWiki documentation.
- **Seek help from the community:** The MediaWiki community is a great place to ask questions and get help from experienced users. See MediaWiki Help.
Further Resources
- [MediaWiki Configuration Manual](https://www.mediawiki.org/wiki/Manual:Configuration_settings)
- [MediaWiki Installation Guide](https://www.mediawiki.org/wiki/Manual:Installation)
- [MediaWiki Extension Directory](https://www.mediawiki.org/wiki/Extension_directory)
- [PHP Documentation](https://www.php.net/)
- [Database Documentation (MySQL, PostgreSQL, etc.)](https://dev.mysql.com/doc/, https://www.postgresql.org/docs/)
- [Security best practices for MediaWiki](https://www.mediawiki.org/wiki/Security_best_practices)
Understanding and correctly configuring MediaWiki's settings is essential for running a successful and secure wiki. Take your time, back up your files, and consult the documentation when needed.
Main Page Help:Contents Extensions User rights management Extending authentication MediaWiki documentation MediaWiki Help Caching strategies Rate limiting SpamPrevention MediaWiki security
Start Trading Now
Sign up at IQ Option (Minimum deposit $10) Open an account at Pocket Option (Minimum deposit $5)
Join Our Community
Subscribe to our Telegram channel @strategybin to receive: ✓ Daily trading signals ✓ Exclusive strategy analysis ✓ Market trend alerts ✓ Educational materials for beginners