Apache web server
- Apache Web Server Configuration for MediaWiki 1.40
This article details the necessary configuration of the Apache web server to host a MediaWiki 1.40 installation. It is geared towards system administrators and newcomers alike, providing a comprehensive guide to ensure a secure and performant setup. Proper Apache configuration is crucial for MediaWiki's functionality, security, and scalability. We will cover essential modules, virtual host setup, and performance optimizations.
Prerequisites
Before beginning, ensure you have:
- A server with a supported operating system (Linux distributions like Ubuntu, Debian, CentOS are common).
- Apache 2.4 or later installed. Verify with `apache2 -v` or `httpd -v`.
- Root or sudo access to the server.
- Basic familiarity with the command line.
- A working MediaWiki 1.40 installation (files placed in the webroot). See MediaWiki Installation for details.
- Understanding of Virtual Hosts and their purpose.
Required Apache Modules
MediaWiki relies on several Apache modules for its operation. These modules must be enabled. The commands to enable modules vary depending on your operating system. Here’s a typical list:
Module Name | Description | Enable Command (Ubuntu/Debian) | Enable Command (CentOS/RHEL) |
---|---|---|---|
`mod_rewrite` | Enables URL rewriting, essential for MediaWiki's clean URLs. | `sudo a2enmod rewrite` | `sudo yum install mod_rewrite` (then restart Apache) |
`mod_expires` | Allows setting of HTTP headers for browser caching. | `sudo a2enmod expires` | `sudo yum install mod_expires` (then restart Apache) |
`mod_deflate` | Compresses HTTP responses, improving performance. | `sudo a2enmod deflate` | `sudo yum install mod_deflate` (then restart Apache) |
`mod_headers` | Allows modification of HTTP response headers. | `sudo a2enmod headers` | `sudo yum install mod_headers` (then restart Apache) |
`mod_ssl` | Provides support for HTTPS (SSL/TLS). Required for secure connections. | `sudo a2enmod ssl` | `sudo yum install mod_ssl` (then restart Apache) |
After enabling modules, *always* restart Apache: `sudo systemctl restart apache2` (Ubuntu/Debian) or `sudo systemctl restart httpd` (CentOS/RHEL). Check your Apache error logs if you encounter issues. See Apache Error Logs for assistance.
Virtual Host Configuration
A virtual host allows you to host multiple websites (or in this case, a MediaWiki installation) on a single server. This is best practice.
1. Create a new virtual host configuration file (e.g., `/etc/apache2/sites-available/mediawiki.conf` on Ubuntu/Debian or `/etc/httpd/conf.d/mediawiki.conf` on CentOS/RHEL).
2. Add the following configuration, adjusting paths to match your setup. Replace `yourdomain.com` with your actual domain name:
```apache <VirtualHost *:80>
ServerName yourdomain.com DocumentRoot /var/www/mediawiki <Directory /var/www/mediawiki> Options FollowSymLinks AllowOverride All Require all granted </Directory>
ErrorLog ${APACHE_LOG_DIR}/mediawiki_error.log CustomLog ${APACHE_LOG_DIR}/mediawiki_access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName yourdomain.com DocumentRoot /var/www/mediawiki <Directory /var/www/mediawiki> Options FollowSymLinks AllowOverride All Require all granted </Directory>
ErrorLog ${APACHE_LOG_DIR}/mediawiki_ssl_error.log CustomLog ${APACHE_LOG_DIR}/mediawiki_ssl_access.log combined
SSLEngine on SSLCertificateFile /path/to/your/certificate.pem SSLCertificateKeyFile /path/to/your/private.key
</VirtualHost> ```
3. Enable the virtual host (Ubuntu/Debian): `sudo a2ensite mediawiki.conf`. Then, restart Apache.
Key Configuration Directives
Several Apache directives are critical for MediaWiki's proper functioning.
- `AllowOverride All`: This allows MediaWiki's `.htaccess` file to override Apache's default configuration. This is necessary for URL rewriting and other features.
- `Require all granted`: Allows access to the MediaWiki directory from all sources. Adjust this for more restrictive security if needed (see Apache Security).
- `DocumentRoot`: Specifies the directory where your MediaWiki files are located.
- `ErrorLog` and `CustomLog`: Define the paths to the error and access logs. Essential for troubleshooting.
- `SSLEngine on`: Enables SSL/TLS for secure HTTPS connections.
- `SSLCertificateFile` and `SSLCertificateKeyFile`: Point to your SSL certificate and private key files.
Performance Optimization
Optimizing Apache can significantly improve MediaWiki's performance.
Optimization | Description | Configuration Example |
---|---|---|
Browser Caching | Instructs browsers to cache static assets (images, CSS, JavaScript). | `Header append Cache-Control "max-age=604800, public"` (in virtual host configuration) |
Gzip Compression | Compresses HTTP responses, reducing bandwidth usage and improving load times. | `mod_deflate` must be enabled. Configuration in virtual host. |
Keep-Alive | Enables persistent connections, reducing overhead. | `KeepAlive On` and `MaxKeepAliveRequests 100` (in Apache main configuration) |
Consider using a caching reverse proxy like Varnish or Nginx in front of Apache for even greater performance gains.
Security Considerations
- **SSL/TLS:** Always use HTTPS to encrypt communication between the server and users. Obtain a valid SSL certificate from a trusted Certificate Authority (CA). See SSL Configuration.
- **`.htaccess` Restrictions:** Carefully review and restrict the permissions within your `.htaccess` file to prevent unauthorized access.
- **Regular Updates:** Keep Apache and all related modules up to date to patch security vulnerabilities.
- **Firewall:** Configure a firewall to restrict access to your server to only necessary ports (e.g., 80, 443). See Server Firewall.
- **Disable Directory Listing:** Prevent Apache from listing directory contents if an index file is not present. Use `Options -Indexes` in your virtual host configuration.
Troubleshooting
- **500 Internal Server Error:** Check your Apache error logs for details. Common causes include incorrect file permissions or errors in your `.htaccess` file.
- **403 Forbidden:** Indicates a permission issue. Ensure the Apache user has read access to the MediaWiki files.
- **404 Not Found:** Verify that your virtual host configuration is correct and that the `DocumentRoot` points to the correct directory. Also, check that your MediaWiki URL rewriting rules are properly configured.
Further Reading
- MediaWiki Installation
- Apache Error Logs
- Apache Security
- SSL Configuration
- Server Firewall
- Virtual Hosts
- Varnish
- Nginx
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?
- Telegram: @powervps Servers at a discounted price
⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️