Command Line Interface
- Command Line Interface (CLI) Configuration
This article details how to interact with your MediaWiki 1.40 server via the Command Line Interface (CLI). Understanding the CLI is crucial for advanced server administration, troubleshooting, and automated tasks. This guide assumes you have shell access to the server hosting your MediaWiki installation.
Accessing the CLI
Typically, you'll access the CLI using SSH (Secure Shell). The exact method depends on your hosting provider and operating system. Common clients include PuTTY (Windows), Terminal (macOS/Linux), and similar tools. You'll need the server's IP address or hostname, your username, and password (or an SSH key). Once connected, you'll be presented with a shell prompt.
Essential Commands
Several fundamental commands are used for managing a MediaWiki server. These are not MediaWiki-specific, but are standard Linux/Unix commands vital for server maintenance.
- `pwd`: Prints the current working directory.
- `cd`: Changes the directory. Example: `cd /var/www/html/mediawiki`
- `ls`: Lists files and directories. `ls -l` provides a detailed listing.
- `mkdir`: Creates a new directory. Example: `mkdir backup`
- `rmdir`: Removes an empty directory. Example: `rmdir backup`
- `rm`: Removes files. *Use with extreme caution!* `rm -r` recursively deletes directories and their contents.
- `cp`: Copies files or directories. Example: `cp LocalSettings.php LocalSettings.php.bak`
- `mv`: Moves or renames files or directories. Example: `mv old_file.txt new_file.txt`
File Management
- `cat`: Displays the contents of a file. Example: `cat LocalSettings.php`
- `less`: Views a file one screen at a time. Press 'q' to exit. Example: `less LocalSettings.php`
- `head`: Displays the first few lines of a file. Example: `head -n 10 LocalSettings.php`
- `tail`: Displays the last few lines of a file. Useful for monitoring logs. Example: `tail -f /var/log/apache2/error.log` (for real-time log following)
- `find`: Searches for files within a directory hierarchy. Example: `find . -name "*.php"`
MediaWiki Specific CLI Tasks
While MediaWiki is primarily web-based, the CLI is essential for maintenance.
Maintenance Scripts
MediaWiki provides several maintenance scripts located in the `maintenance` directory within your MediaWiki installation. These scripts require you to be in the root of your MediaWiki installation to run correctly. You will also need to set the `MW_INSTALL_PATH` environment variable (see below).
Setting the Environment
Before running maintenance scripts, you often need to set the `MW_INSTALL_PATH` environment variable to point to your MediaWiki installation directory. For example:
```bash export MW_INSTALL_PATH=/var/www/html/mediawiki ```
This variable is used by the scripts to locate configuration files and other essential resources.
Common Maintenance Scripts
Here's a table detailing frequently used scripts:
Script Name | Description | Example Usage |
---|---|---|
`update.php` | Updates the MediaWiki database schema. Required after upgrading MediaWiki. | `php maintenance/update.php` |
`runCron.php` | Executes tasks that would normally be handled by the cron job. | `php maintenance/runCron.php` |
`rebuildindex.php` | Rebuilds the search index. Important after large content changes. | `php maintenance/rebuildindex.php` |
`refreshLinks.php` | Updates internal links throughout the wiki. | `php maintenance/refreshLinks.php` |
`archive.php` | Archives old revisions of pages. | `php maintenance/archive.php` |
Database Operations
You can use the `mysql` command-line client to directly interact with the MediaWiki database. You'll need the database username, password, and database name (configured in `LocalSettings.php`). (See Database Configuration for details.)
Here's an example:
```bash mysql -u <username> -p -D <databasename> -e "SELECT COUNT(*) FROM page;" ```
Replace `<username>` and `<databasename>` with your actual credentials. This query counts the number of pages in your wiki.
PHP Configuration
You can use the CLI to check your PHP configuration.
Command | Description | Example Output |
---|---|---|
`php -v` | Displays the PHP version. | `PHP 8.1.10 (cli) (built: Nov 20 2023 14:30:00) (NTS)` |
`php -i` | Displays detailed PHP information. | (Extensive output including loaded extensions, configuration settings, etc.) |
`php -m` | Lists loaded PHP modules. | `Core\nctype\ncurl\ndate\ndom\n...` |
Monitoring and Troubleshooting
The CLI is invaluable for monitoring server health and troubleshooting issues.
Log Files
Web server logs (e.g., Apache or Nginx) and PHP error logs are crucial for identifying problems. Use `tail -f` to monitor logs in real-time. (See Server Logs for log file locations.)
Process Management
- `ps`: Lists running processes. `ps aux | grep php` can find PHP processes.
- `top`: Displays a dynamic real-time view of running processes.
- `kill`: Terminates a process. *Use with caution!* `kill -9 <process_id>` forcefully terminates a process.
Permissions
Ensure that the MediaWiki files and directories have the correct permissions for the web server user to access. Incorrect permissions can cause errors. Use `chmod` and `chown` to adjust permissions. (See File Permissions for details.)
Command | Description | Example |
---|---|---|
`chmod` | Changes file permissions. | `chmod 755 extensions/` |
`chown` | Changes file ownership. | `chown www-data:www-data extensions/` |
`ls -l` | Lists files with detailed permissions. | `-rwxr-xr-x 1 www-data www-data 4096 Nov 20 10:00 extensions/` |
Further Resources
- Installation Guide
- Database Configuration
- Server Logs
- File Permissions
- Cron Jobs
- Troubleshooting
- Advanced Configuration
- Security Best Practices
- System Requirements
- Upgrading MediaWiki
- Web Server Configuration
- PHP Configuration
- Caching
- Load Balancing
- Database Maintenance
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.* ⚠️