PHP
- PHP Configuration for MediaWiki
This article details the PHP configuration necessary for running a stable and performant MediaWiki installation. Proper PHP configuration is crucial for MediaWiki's functionality, security, and overall performance. This guide is geared toward newcomers to server administration and MediaWiki setup.
Understanding PHP's Role in MediaWiki
PHP is the server-side scripting language that powers MediaWiki. It handles all dynamic content generation, database interactions, and user requests. A correctly configured PHP environment is essential for MediaWiki to function correctly. Issues with PHP configuration are a common source of problems in MediaWiki installations, and understanding the key settings can save considerable troubleshooting time. It is important to consult the [official MediaWiki documentation](https://www.mediawiki.org/wiki/Manual:Configuration_form) for the most up-to-date requirements. Also, be aware of the [PHP requirements](https://www.mediawiki.org/wiki/Manual:PHP) for your version of MediaWiki.
Required PHP Extensions
MediaWiki requires several PHP extensions to be enabled. These extensions provide functionality that MediaWiki relies upon. Failure to enable these extensions will result in errors.
Extension | Description | Required? |
---|---|---|
`intl` | Internationalization support. Essential for multilingual wikis. | Yes |
`mbstring` | Multibyte string support. Necessary for handling various character sets. | Yes |
`gd` | Graphics Draw library. Used for image manipulation and thumbnail generation. | Yes |
`mysql` or `mysqli` or `pdo_mysql` | MySQL database connectivity. Choose one, `mysqli` or `pdo_mysql` are recommended. | Yes |
`xml` | XML processing support. Used for various data formats. | Yes |
`zip` | ZIP archive support. Required for extensions and maintenance tasks. | Yes |
`json` | JSON support. Used for API interactions and data exchange. | Yes |
`curl` | Client URL Library. Used for external data retrieval. | Optional, but recommended for extensions |
To check which PHP extensions are currently enabled, you can create a `phpinfo.php` file containing the following code:
```php <?php phpinfo(); ?> ```
Accessing this file through your web browser will display detailed information about your PHP configuration, including a list of enabled extensions. Remember to remove this file after checking the configuration for security reasons. See [Security best practices](https://www.mediawiki.org/wiki/Manual:Security_best_practices) for more information.
Key PHP Configuration Settings
Several PHP settings need to be adjusted in your `php.ini` file to optimize MediaWiki's performance and stability. The location of your `php.ini` file varies depending on your operating system and PHP installation. Consult your operating system's documentation for details.
Setting | Recommended Value | Description |
---|---|---|
`memory_limit` | 256M or higher | Maximum amount of memory a script may consume. Insufficient memory can cause errors during complex operations. |
`upload_max_filesize` | 100M or higher | Maximum allowed size for uploaded files. Adjust based on your wiki's needs. |
`post_max_size` | 100M or higher | Maximum size of POST data that PHP will accept. Should be equal to or greater than `upload_max_filesize`. |
`max_execution_time` | 300 (seconds) | Maximum time a script is allowed to run. Increase if you experience timeouts during maintenance tasks. |
`max_input_time` | 60 (seconds) | Maximum time a script is allowed to parse input data. |
`session.save_path` | A dedicated directory with write permissions | Directory where PHP stores session data. Important for performance and reliability. |
`date.timezone` | Your server's timezone (e.g., America/Los_Angeles) | Sets the default timezone for PHP date and time functions. |
After modifying your `php.ini` file, you must restart your web server (e.g., Apache, Nginx) for the changes to take effect. See [Web server configuration](https://www.mediawiki.org/wiki/Manual:Configuration_form#Web_server_configuration) for details.
Caching & Performance Optimization
PHP caching can significantly improve MediaWiki's performance by reducing the need to recompile scripts repeatedly. Several caching mechanisms are available.
Caching Method | Description | Complexity |
---|---|---|
Opcode Cache (e.g., OPcache) | Caches compiled PHP code in memory, reducing CPU load. Highly recommended. | Medium |
Object Cache (e.g., Memcached, Redis) | Caches database query results and other frequently accessed data. Significant performance boost. | High |
Page Cache (e.g., Varnish, Nginx caching) | Caches entire rendered pages, reducing server load. Best for high-traffic wikis. | High |
Enabling and configuring these caches requires additional steps and expertise. Consult the documentation for your chosen caching solution and the [MediaWiki caching documentation](https://www.mediawiki.org/wiki/Manual:Caching) for detailed instructions. Consider using [maintenance scripts](https://www.mediawiki.org/wiki/Manual:Maintenance_scripts) regularly to clear caches.
Security Considerations
- **Disable `allow_url_fopen`:** This setting can introduce security vulnerabilities. Consider using `curl` instead for external data retrieval.
- **Restrict `open_basedir`:** Limit the directories PHP can access to prevent unauthorized file access.
- **Keep PHP updated:** Regularly update PHP to the latest stable version to patch security vulnerabilities. See [PHP Security](https://www.php.net/security) for more information.
- **Review `php.ini` regularly:** Periodically review your `php.ini` file to ensure it remains secure and optimized.
Further Resources
- [MediaWiki PHP Requirements](https://www.mediawiki.org/wiki/Manual:PHP)
- [PHP Official Documentation](https://www.php.net/)
- [PHP Security](https://www.php.net/security)
- [MediaWiki Caching](https://www.mediawiki.org/wiki/Manual:Caching)
- [MediaWiki Configuration Form](https://www.mediawiki.org/wiki/Manual:Configuration_form)
Special:Myuserpage Help:Contents Manual:Configuration_form Manual:PHP Manual:Security_best_practices Manual:Caching Manual:Maintenance_scripts Extension:Semantic MediaWiki Help:Formatting Help:Tables Help:Links Manual:FAQ Special:Search Special:Randompage Main Page
Help:Editing Help:Contents Manual:Upgrading Manual:Installation Manual:Configuration
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.* ⚠️