Linux

From Server rent store
Jump to navigation Jump to search
  1. Linux Server Configuration for MediaWiki

This article provides a comprehensive overview of configuring a Linux server for optimal MediaWiki 1.40 performance and security. It's geared towards newcomers to server administration and assumes basic familiarity with the command line.

Choosing a Linux Distribution

Several Linux distributions are suitable for hosting a MediaWiki instance. Popular choices include Debian, Ubuntu Server, CentOS Stream, and Rocky Linux. The selection often depends on personal preference and familiarity. Debian and Ubuntu are known for their ease of use and large community support, while CentOS Stream and Rocky Linux offer stability with a focus on enterprise environments.

For this guide, we'll generally assume a Debian/Ubuntu-based system, as the package management commands (apt) will be used. Adapt the commands accordingly if using a different distribution (e.g., use `yum` or `dnf` on CentOS/Rocky Linux).

Essential Software Installation

Before installing MediaWiki itself, several core components need to be installed on the server. These include a web server (Apache or Nginx), a database server (MySQL/MariaDB, PostgreSQL, or SQLite – though SQLite is not recommended for production), and PHP.

Web Server (Apache)

Apache is a widely used web server. To install it on Debian/Ubuntu:

```bash sudo apt update sudo apt install apache2 ```

After installation, ensure Apache is running:

```bash sudo systemctl status apache2 ```

Database Server (MariaDB)

MariaDB is a popular open-source relational database management system and a drop-in replacement for MySQL. Install with:

```bash sudo apt install mariadb-server ```

Secure the installation:

```bash sudo mysql_secure_installation ```

PHP and Required Extensions

PHP is the scripting language MediaWiki is written in. Install PHP and the necessary extensions. The exact version may vary, but 7.4 or 8.1 are good choices for MediaWiki 1.40.

```bash sudo apt install php libapache2-mod-php php-mysql php-gd php-curl php-mbstring php-xml php-zip php-intl php-bcmath php-json ```

Verify PHP version:

```bash php -v ```

Server Performance Tuning

Optimizing server performance is crucial, especially for high-traffic wikis.

PHP Configuration

Edit the `php.ini` file (location varies by distribution, often `/etc/php/[version]/apache2/php.ini`). Adjust the following settings:

Setting Recommended Value Description
`memory_limit` `256M` or higher Maximum amount of memory a script may consume.
`upload_max_filesize` `100M` or higher Maximum allowed size for uploaded files.
`post_max_size` `100M` or higher Maximum size of POST data allowed.
`max_execution_time` `300` Maximum time in seconds a script is allowed to run.

Restart Apache after modifying `php.ini`:

```bash sudo systemctl restart apache2 ```

MariaDB Configuration

Edit the MariaDB configuration file (`/etc/mysql/mariadb.conf.d/50-server.cnf` on Debian/Ubuntu). Adjust the `innodb_buffer_pool_size` based on available RAM. A good starting point is 50-80% of total RAM.

Setting Recommended Value Description
`innodb_buffer_pool_size` `2G` (example) Size of the buffer pool for InnoDB tables.
`key_buffer_size` `32M` Size of the buffer used for index blocks.
`max_connections` `200` Maximum number of concurrent connections.

Restart MariaDB after modifying the configuration:

```bash sudo systemctl restart mariadb ```

Apache Configuration

Enable necessary Apache modules and adjust settings for performance.

```bash sudo a2enmod headers sudo a2enmod rewrite ```

Consider using a caching module like `mod_cache` and `mod_disk_cache`. Consult the Apache documentation for detailed configuration.

Security Considerations

Securing your server is paramount.

Firewall Configuration

Use a firewall (e.g., `ufw` on Ubuntu) to restrict access to only necessary ports (80 for HTTP, 443 for HTTPS, 22 for SSH - restrict SSH access if possible).

```bash sudo ufw allow 80 sudo ufw allow 443 sudo ufw allow 22 sudo ufw enable ```

Regular Updates

Keep all software packages up to date with regular updates:

```bash sudo apt update sudo apt upgrade ```

Secure Shell (SSH) Hardening

Disable password authentication for SSH and use key-based authentication instead. Change the default SSH port. Consider using fail2ban to prevent brute-force attacks.

MediaWiki Specific Security

Refer to the MediaWiki Security page on the wiki for specific MediaWiki security recommendations. This includes configuring `$wgSecretKey`, using HTTPS, and regularly updating MediaWiki itself. Also, review Configuring MediaWiki for initial setup.

Monitoring and Logging

Regularly monitor server resources (CPU, memory, disk space) using tools like `top`, `htop`, or `vmstat`. Check the Apache and MariaDB logs for errors. Consider using a log analysis tool like Logstash or the ELK stack for centralized logging and analysis. See Server Administration for additional details.


Summary of Key Software Versions

Software Recommended Version Notes
Linux Distribution Debian 11 or Ubuntu Server 20.04 LTS Choose based on preference.
Apache 2.4 Stable and widely supported.
MariaDB 10.5 or higher Drop-in replacement for MySQL.
PHP 7.4 or 8.1 Ensure compatibility with MediaWiki 1.40.

Further Resources


Intel-Based Server Configurations

Configuration Specifications Benchmark
Core i7-6700K/7700 Server 64 GB DDR4, NVMe SSD 2 x 512 GB CPU Benchmark: 8046
Core i7-8700 Server 64 GB DDR4, NVMe SSD 2x1 TB CPU Benchmark: 13124
Core i9-9900K Server 128 GB DDR4, NVMe SSD 2 x 1 TB CPU Benchmark: 49969
Core i9-13900 Server (64GB) 64 GB RAM, 2x2 TB NVMe SSD
Core i9-13900 Server (128GB) 128 GB RAM, 2x2 TB NVMe SSD
Core i5-13500 Server (64GB) 64 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Server (128GB) 128 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Workstation 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000

AMD-Based Server Configurations

Configuration Specifications Benchmark
Ryzen 5 3600 Server 64 GB RAM, 2x480 GB NVMe CPU Benchmark: 17849
Ryzen 7 7700 Server 64 GB DDR5 RAM, 2x1 TB NVMe CPU Benchmark: 35224
Ryzen 9 5950X Server 128 GB RAM, 2x4 TB NVMe CPU Benchmark: 46045
Ryzen 9 7950X Server 128 GB DDR5 ECC, 2x2 TB NVMe CPU Benchmark: 63561
EPYC 7502P Server (128GB/1TB) 128 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/2TB) 128 GB RAM, 2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/4TB) 128 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/1TB) 256 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/4TB) 256 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 9454P Server 256 GB RAM, 2x2 TB NVMe

Order Your Dedicated Server

Configure and order your ideal server configuration

Need Assistance?

⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️