CentOS

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

This article provides a guide to configuring a CentOS server to host a MediaWiki 1.40 installation. It is aimed at newcomers to server administration and assumes basic Linux command-line familiarity. We will cover initial server setup, necessary software installation, and basic security considerations. This guide focuses on CentOS 7, as it remains a widely used and supported distribution. While newer versions exist, the core principles apply with minor adjustments.

1. Initial Server Setup

Before installing MediaWiki, a properly configured CentOS server is essential. This includes setting a hostname, configuring networking, and ensuring the system is up-to-date.

1.1 Hostname Configuration

Setting a descriptive hostname makes server identification easier.

1. Edit the `/etc/hostname` file using a text editor like `vi` or `nano`:

   ```
   sudo vi /etc/hostname
   ```

2. Replace the current hostname with your desired hostname (e.g., `mediawiki-server`). 3. Edit the `/etc/hosts` file:

   ```
   sudo vi /etc/hosts
   ```

4. Ensure the following line is present (replace `mediawiki-server` with your chosen hostname and `your_server_ip` with the server’s actual IP address):

   ```
   your_server_ip  mediawiki-server
   ```

5. Reboot the server to apply the changes:

   ```
   sudo reboot
   ```

1.2 System Updates

Keeping your system updated is crucial for security and stability.

``` sudo yum update -y ```

2. Software Installation

MediaWiki requires several software components. We will install these using the `yum` package manager.

2.1 Web Server (Apache)

Apache is a popular web server that will serve the MediaWiki files.

``` sudo yum install httpd -y sudo systemctl start httpd sudo systemctl enable httpd ```

Test Apache by accessing your server’s IP address in a web browser. You should see the Apache test page. For more information on Apache, see [Apache HTTP Server documentation](https://httpd.apache.org/docs/).

2.2 Database Server (MariaDB)

MariaDB is a robust and widely used relational database management system. MediaWiki stores its data in a database.

``` sudo yum install mariadb-server mariadb -y sudo systemctl start mariadb sudo systemctl enable mariadb ```

Secure your MariaDB installation:

``` sudo mysql_secure_installation ```

Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove the test database. See the [MariaDB Knowledge Base](https://mariadb.com/kb/) for further details.

2.3 PHP and Required Extensions

PHP is the scripting language MediaWiki is written in. Specific PHP extensions are required for MediaWiki to function correctly.

``` sudo yum install php php-mysql php-gd php-mbstring php-xml php-intl php-zip php-bcmath php-curl -y ```

Restart Apache after installing PHP extensions:

``` sudo systemctl restart httpd ```

Here's a table summarizing the required PHP extensions:

Extension Description
php-mysql Enables PHP to connect to MySQL/MariaDB databases.
php-gd Provides image processing capabilities.
php-mbstring Supports multi-byte string functions.
php-xml Enables PHP to parse XML documents.
php-intl Provides internationalization support.
php-zip Allows PHP to work with ZIP archives.
php-bcmath Offers arbitrary precision mathematics.
php-curl Enables PHP to make HTTP requests.

3. MediaWiki Installation

Now that the prerequisites are met, we can install MediaWiki.

3.1 Downloading MediaWiki

Download the latest stable version of MediaWiki from the [official MediaWiki download page](https://www.mediawiki.org/wiki/Download). Use `wget` to download the file directly to your server:

``` wget https://releases.wikimedia.org/mediawiki/1.40/mediawiki-1.40.0.tar.gz ```

3.2 Extracting and Configuring

1. Extract the downloaded archive:

  ```
  tar -xzf mediawiki-1.40.0.tar.gz
  ```

2. Move the extracted directory to the Apache web root (typically `/var/www/html/`):

  ```
  sudo mv mediawiki-1.40.0 /var/www/html/mediawiki
  ```

3. Change ownership of the MediaWiki directory to the Apache user (usually `apache`):

   ```
   sudo chown -R apache:apache /var/www/html/mediawiki
   ```

4. Navigate to the MediaWiki directory in your web browser (e.g., `http://your_server_ip/mediawiki`). This will start the MediaWiki installation script.

3.3 Database Configuration

Follow the on-screen instructions provided by the MediaWiki installation script. You'll need to provide the following information:

  • Database type: MariaDB
  • Database name: Choose a name for your MediaWiki database (e.g., `mediawiki_db`)
  • Database username: The MariaDB username you created during the `mysql_secure_installation` process.
  • Database password: The password for the database user.
  • Database server: Usually `localhost`.

3.4 Finishing the Installation

Complete the remaining steps of the installation script, including setting up your administrator account and configuring the site title and URL.

4. Security Considerations

Securing your MediaWiki installation is vital.

4.1 Firewall Configuration

Enable a firewall to restrict access to your server. `firewalld` is commonly used on CentOS.

``` sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload ```

4.2 `LocalSettings.php` Security

The `LocalSettings.php` file contains sensitive configuration information. Ensure it is not publicly accessible. It should already be outside the web root, but verify this. Also, consider setting `$wgSecretKey` to a strong, randomly generated string.

4.3 Regular Backups

Implement a regular backup strategy for your MediaWiki database and files. This is critical for disaster recovery. Consider using tools like `mysqldump` for database backups.

Here's a table summarizing recommended security practices:

Security Measure Description
Firewall Restricts network access to essential ports.
`LocalSettings.php` Protection Ensures sensitive configuration data is not publicly accessible.
Strong Passwords Use strong passwords for all user accounts and database access.
Regular Backups Provides a recovery point in case of data loss or server failure.
Keep Software Updated Regularly update the OS, web server, PHP, and MediaWiki to patch security vulnerabilities.

5. Performance Tuning

Optimizing performance can improve the user experience.

5.1 PHP Configuration

Adjust PHP settings in the `php.ini` file (usually located in `/etc/php.ini`) to optimize performance. Consider increasing `memory_limit` and `max_execution_time` if your wiki handles large files or complex operations.

5.2 Database Optimization

Regularly optimize the MariaDB database using the `OPTIMIZE TABLE` command. This can improve query performance.

Here’s a table of common PHP configuration settings to consider:

Setting Description Recommended Value (Example)
memory_limit Maximum amount of memory a script may consume. 256M
max_execution_time Maximum time a script may run. 30
upload_max_filesize Maximum allowed size for uploaded files. 50M
post_max_size Maximum size of POST data allowed. 50M

This guide provides a foundational setup for running a MediaWiki instance on CentOS. Further customization and optimization may be required based on specific needs and traffic levels. Refer to the [MediaWiki documentation](https://www.mediawiki.org/wiki/Manual:Configuration_settings) for advanced configuration options. See also [CentOS documentation](https://www.centos.org/documentation/). Related topics include [Server Security](Server Security), [Database Administration](Database Administration), and [Web Server Configuration](Web Server Configuration). Also, review [Troubleshooting Common Issues](Troubleshooting Common Issues). Finally, explore [Performance Optimization Techniques](Performance Optimization Techniques).


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.* ⚠️