Google Cloud Storage
- Google Cloud Storage Configuration for MediaWiki
This article details configuring Google Cloud Storage (GCS) for use with your MediaWiki installation. Using GCS allows you to offload file storage from your primary server, improving performance and scalability. This guide assumes you have a working MediaWiki 1.40 installation and a Google Cloud Platform account with billing enabled. We will cover setup, configuration, and troubleshooting.
Prerequisites
Before beginning, ensure you have the following:
- A Google Cloud Platform account.
- The Google Cloud SDK installed and configured on your server. (Refer to the Google Cloud SDK documentation for installation instructions).
- Basic familiarity with the command line.
- Sufficient permissions within your GCP project to create and manage storage buckets and service accounts.
- PHP configured with necessary extensions (see PHP Configuration for details).
Step 1: Creating a Google Cloud Storage Bucket
First, create a bucket in GCS to store your MediaWiki files. Buckets are the fundamental containers for data in GCS.
1. Open the Google Cloud Console. 2. Navigate to Storage > Browser. 3. Click "Create Bucket." 4. Choose a globally unique name for your bucket (e.g., `mediawiki-files-yourproject`). 5. Select a storage class (Multi-Regional, Regional, Nearline, Coldline, Archive). For active MediaWiki files, `Multi-Regional` is usually a good choice. 6. Choose a location for your bucket. 7. Set access control to "Uniform." 8. Click "Create."
Bucket Details
Property | Value |
---|---|
Bucket Name | `mediawiki-files-yourproject` (Example) |
Storage Class | Multi-Regional |
Location | US (Example) |
Access Control | Uniform |
Step 2: Creating a Service Account
Next, create a service account with the necessary permissions to access your GCS bucket.
1. In the Google Cloud Console, navigate to IAM & Admin > Service Accounts. 2. Click "Create Service Account." 3. Enter a Service Account name (e.g., `mediawiki-storage`). 4. Grant the service account the "Storage Object Admin" role. This allows read/write access to objects in your bucket. 5. Click "Done." 6. Find the created service account in the list. 7. Click on the three vertical dots next to the service account and select "Manage Keys." 8. Click "Add Key" and choose "Create new key." 9. Select "JSON" as the key type and click "Create." This will download a JSON file containing your service account credentials. **Keep this file secure!**
Step 3: Configuring MediaWiki
Now, configure MediaWiki to use your GCS bucket.
1. Edit your `LocalSettings.php` file. (See Configuring LocalSettings.php for details). 2. Add the following lines, replacing the placeholders with your actual values:
```php $wgStorageSearchPaths['GCS'] = 'gs://mediawiki-files-yourproject'; // Your GCS bucket name $wgHashedUploads = true; $wgUploadDirectory = '/tmp'; //A temporary directory is needed. $wgUploadPath = '/tmp'; $wgGCSKeyFile = '/path/to/your/service-account-key.json'; // Path to your service account key file ```
3. Ensure the `/tmp` directory exists and is writable by the web server user.
Configuration Details
Setting | Description |
---|---|
`$wgStorageSearchPaths['GCS']` | Specifies the GCS bucket to use for storage. |
`$wgHashedUploads` | Enables hashed file names for security and scalability. |
`$wgUploadDirectory` | Specifies a temporary directory for uploads. |
`$wgGCSKeyFile` | Specifies the path to your service account key file. |
Step 4: Permissions and Verification
Verify that your MediaWiki server has access to the GCS bucket.
1. Upload a test file through the MediaWiki interface (e.g., a small image). 2. Check your GCS bucket to confirm the file was uploaded correctly. 3. If the upload fails, check the MediaWiki logs (see MediaWiki Logging for details) for error messages related to GCS connectivity or permissions. Ensure the service account key file path is correct and the service account has the "Storage Object Admin" role.
Troubleshooting
- **Permissions Errors:** Double-check the service account role. It *must* have "Storage Object Admin."
- **Connectivity Issues:** Ensure your server has internet access. Verify the Google Cloud SDK is correctly configured.
- **File Upload Failures:** Examine the MediaWiki logs for specific error messages. Incorrect file paths or insufficient disk space in the temporary upload directory can also cause issues.
- **Slow Uploads:** Consider the geographic proximity of your server and the GCS bucket location. Using a Multi-Regional bucket can help improve performance.
Common Errors
Error Message | Possible Solution |
---|---|
"Access Denied" | Verify service account role and key file path. |
"Could not connect to Google Cloud Storage" | Check internet connectivity and Google Cloud SDK configuration. |
"Disk quota exceeded" | Ensure sufficient disk space in the temporary upload directory. |
Further Reading
- MediaWiki Configuration
- PHP Configuration
- MediaWiki Logging
- Google Cloud Storage Documentation
- Google Cloud SDK documentation
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.* ⚠️