DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Set Up Memcached for MediaWiki on a VPS Securely

A practical, security-first guide to installing Memcached for MediaWiki on a VPS, configuring the PHP client and LocalSettings.php, and verifying single- or multi-server deployments.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Memcached from your VPS distribution, keep it on loopback when it runs beside MediaWiki, install a PHP client for the same PHP runtime as the web server, and point MediaWiki’s main cache at 127.0.0.1:11211. The essential settings are $wgMainCacheType = CACHE_MEMCACHED; and $wgMemCachedServers = [ '127.0.0.1:11211' ];. Memcached has no authentication, so a private bind address and firewall rules are mandatory. For a small, single-server wiki, APCu can be a simpler main-cache choice; Memcached becomes more useful when several application servers need one shared object cache.

Decide whether Memcached is the right cache

Memcached is an in-memory object store. MediaWiki can place expensive-to-create objects in it so later requests do not repeat the same work or query the database as often. It is especially common on large installations and on deployments with multiple web servers, where a shared cache prevents each application server from maintaining a completely separate copy.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

It is not a replacement for a PHP bytecode cache, a database, or a backup. A practical cache stack for many installations is PHP bytecode caching, APCu for data local to each server, and Memcached for the main shared cache. A small wiki running entirely on one VPS may get a simpler result by using APCu as its main cache instead of adding a network daemon.

Question APCu Memcached
Where is data stored? Inside the local PHP process space on one server. In a separate Memcached daemon, reachable through a local or private network address.
Best fit Small, single-server wikis that need a low-complexity local cache. Large or multi-web-server wikis that benefit from a shared object cache.
Network exposure Normally local to the PHP host. Must be bound to loopback or a private interface and protected by a firewall.
PHP requirement APCu extension for the PHP runtime. MediaWiki’s pure-PHP client or the PECL memcached extension, plus PHP sockets support for network communication.
Operational work Enable the extension and configure MediaWiki. Install, start, secure, monitor, and maintain a separate daemon as well as the PHP client.

Choose Memcached when shared cache scope or separation from the web process matters. Choose APCu when one VPS hosts the entire wiki and minimizing moving parts is more valuable. You can still run APCu for local data while using Memcached for MediaWiki’s main cache.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Check the VPS and MediaWiki prerequisites

Before installing anything, confirm that the host and the web application meet these conditions:

  • A supported Linux distribution with access to its package manager.
  • Shell access with permission to install packages and manage services.
  • A working MediaWiki installation and a known PHP version.
  • A firewall that can restrict Memcached traffic.
  • Enough RAM for the daemon without forcing the operating system or database into swapping.

Identify the PHP binary used by the web service rather than assuming it is the same binary invoked by an interactive shell. Check the command-line version with php -v, then determine the PHP-FPM pool or Apache module serving MediaWiki. A client installed for one PHP version is invisible to a different web runtime until it is installed and enabled there too.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MediaWiki supports both a pure-PHP Memcached client and the PECL PHP memcached extension. The extension can offer SASL authorization and connection pooling, while the pure-PHP client avoids compiling a native module. Whichever client you select, ensure that the runtime has PHP sockets support when it must communicate with a daemon over TCP or a Unix socket.

Install the Memcached daemon and PHP client

Use distribution packages where possible

Package names differ by distribution release and PHP version. On Debian or Ubuntu, the normal pattern is to install the distribution’s Memcached daemon package and the PHP client package matching the PHP version used by the web server. A typical package-manager sequence is:

sudo apt update
sudo apt install memcached php-memcached

Treat that command as a package-name example, not a universal rule. On a release that ships versioned PHP packages, select the corresponding versioned client package instead. If you choose the pure-PHP client, install the package or library recommended for the exact MediaWiki release rather than enabling an unrelated extension.

Restart the web runtime after enabling an extension

Installing a PHP extension does not always reload an already-running PHP-FPM pool or Apache process. Restart the service that serves MediaWiki after enabling the client. Use the service name for the installed PHP version; do not restart a different version and assume the module is active. A command-line check such as php -m is useful, but the decisive check is the PHP runtime used by web requests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Confirm the daemon package and service

Distribution packages normally create a service definition. Check its status with the distribution’s service manager, and record whether the package starts automatically after a reboot. If the package does not provide the desired defaults, configure the service explicitly rather than launching an unmanaged background process that disappears on restart.

Bind Memcached to a private address

Same-VPS installation

When MediaWiki and Memcached share one VPS, loopback is the safest default. The MediaWiki documentation gives this illustrative command:

memcached -d -l 127.0.0.1 -p 11211 -m 64

It starts a daemon on loopback port 11211 with a 64 MB memory limit. The 64 MB value is only an example; it is not a sizing recommendation for every wiki. Choose a limit that leaves sufficient memory for the operating system, PHP workers, the database, and filesystem caches.

Do not replace 127.0.0.1 with the VPS’s public address. A public bind makes the daemon reachable from the internet unless every protocol and source range is blocked correctly. Configure the distribution’s service manager with the private bind address and memory limit so the settings survive a reboot, then enable and start that service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate cache node

If Memcached runs on another host, bind it to an address on a private network shared by the cache node and the MediaWiki application servers. Permit connections only from the application hosts. The cache node must not listen on a public interface simply because the web servers need to reach it; routing and firewall rules should provide that reachability through the private network.

Verify the listener before configuring MediaWiki

On the cache host, inspect listening sockets with a tool such as:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
ss -ltnup | grep 11211

Check that the address shown is the intended loopback or private address, not a wildcard or public interface. If UDP is enabled by the package, apply the same source restrictions to UDP as to TCP. A port that is private by routing but unrestricted by host firewall policy is still an unnecessary attack surface.

Configure MediaWiki’s main cache

Edit LocalSettings.php after MediaWiki’s generated settings. The minimal same-VPS configuration is:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
$wgMainCacheType = CACHE_MEMCACHED;
$wgMemCachedServers = [ '127.0.0.1:11211' ];

The server list is an array even when it contains one entry. Keep the address and port synchronized with the daemon’s actual listener. If the PHP client cannot connect, MediaWiki will report cache connection errors even though the PHP syntax is valid.

Optional parser and message caches

MediaWiki’s manual also documents optional settings for parser and message caches:

$wgParserCacheType = CACHE_MEMCACHED;
$wgMessageCacheType = CACHE_MEMCACHED;

Enable these only after the main object cache works and you understand the memory available to the daemon. They increase the set of data placed in Memcached; they do not repair an incorrectly bound service or an unavailable PHP client.

Session-related settings require version checking

Session configuration is version-sensitive. The $wgSessionsInObjectCache setting was removed in MediaWiki 1.33 and later, so do not paste an old session recipe into a current installation. Check the configuration reference for the exact MediaWiki release before enabling any session-related cache behavior. Sessions also deserve stricter availability testing than ordinary object reads because a lost session can interrupt logins, edits, or administrative actions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Use a private server list for multiple nodes

For a separate cache tier, replace the loopback address with each private cache address:

$wgMemCachedServers = [
    '10.0.0.21:11211',
    '10.0.0.22:11211'
];

Additional entries allow MediaWiki to use more than one server. Weighted subarrays are supported when cache nodes have different memory capacities; follow the syntax documented for your MediaWiki version rather than inventing a weight format. MediaWiki also supports Unix sockets with the documented unix:///path form. Newer versions have specific rules about whether a trailing port may be included with a Unix-socket address, so verify that detail against the configuration reference for the installed release.

Apply the Memcached security checklist

Memcached has no built-in authentication. Anyone who can reach its listening port may be able to read, write, or evict cached objects. Treat network isolation as the security boundary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Bind a same-VPS daemon to 127.0.0.1.
  • Bind a multi-node daemon only to a private interface or private network address.
  • Block inbound TCP and UDP access from the public internet.
  • Allow the port only from the MediaWiki web or application hosts.
  • Do not place credentials, session secrets, or other sensitive values in a cache that an untrusted host can reach.
  • Recheck firewall rules after changing addresses, migrating hosts, or adding a second application server.

If SELinux is enforcing policy, Apache may need the httpd_can_network_memcache boolean enabled before it can connect to a remote Memcached service. Change that policy deliberately and document it with the rest of the host configuration; do not disable SELinux merely to make a connection succeed.

Verify the installation end to end

Check the service and address

  1. Confirm the Memcached service is active in the distribution’s service manager.
  2. Inspect listening sockets and verify the address and port are private.
  3. From each MediaWiki host, test reachability to the private address through the host firewall and network policy.
  4. Ensure no public firewall rule exposes port 11211.

Check the PHP web runtime

Inspect the modules loaded by the PHP runtime that serves web requests. A command-line result from php -m is not sufficient if Apache or PHP-FPM uses another binary or pool. Confirm that the selected Memcached client and sockets support are visible to that runtime, then restart the web service after changes.

Check MediaWiki

Load the wiki after saving LocalSettings.php and inspect its status information or debug output for cache connection errors. Test an anonymous page, a logged-in page, and an administrative page so that both ordinary object reads and authenticated requests are exercised. Keep debug output protected from public visitors; connection details can reveal internal addresses.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

A successful page load alone does not prove that every optional cache is working. Verify the main cache first, then add parser, message, or session-related settings one at a time so a regression can be attributed to a specific change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

Connection refused or timeout

  • Check that the daemon is running and listening on the address configured in $wgMemCachedServers.
  • Compare the configured port with the service’s actual port; 11211 is conventional, not mandatory.
  • Check host and network firewalls on both sides.
  • For a remote node, verify that the application host can route to the private address.
  • Confirm that the daemon is not bound only to loopback when the application is on another host.

The extension appears in CLI but not on web requests

This usually indicates different PHP runtimes. Identify the PHP-FPM pool or Apache module serving the wiki, install the client for that version, and restart that service. Test again through the web runtime rather than relying on the shell’s module list.

MediaWiki reports an unknown cache constant or class

Check the MediaWiki version and the cache-client configuration syntax. Ensure that LocalSettings.php contains the cache settings after the generated configuration and that no older session recipe was copied into a release that removed it. A syntax error elsewhere in the file can prevent all later settings from loading, so inspect the PHP error log as well as MediaWiki’s status output.

Intermittent session loss

If sessions are stored in Memcached and edits or logins intermittently fail with a session-loss message, inspect hostname mappings on every Memcached server. Inconsistent hostnames or resolution can cause requests to address the cache cluster differently. Also verify that all application hosts use the same server list and private-network rules. Do not treat a session failure as an ordinary cache miss; resolve the connectivity and naming problem before enabling session caching again.

Cache evictions or unstable performance

Review the daemon’s memory limit against the amount of data assigned to it and the available VPS RAM. A tiny cache can evict useful objects constantly, while an oversized cache can push PHP or the database into memory pressure. Add optional parser or message caches only after the main cache is stable. Measure page-generation time, database load, and memory pressure under representative traffic rather than assuming that a larger cache always improves the result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Only one node works in a multi-server list

Check each address independently from every application host. Confirm that all cache nodes listen on the expected private interface, that the firewall allows the application sources, and that the PHP client accepts the exact server-list syntax used. If capacities differ, use the documented weighted-entry format; otherwise, an unweighted list may send more traffic to a smaller node than it can hold comfortably.

Understand performance and capacity limits

There is no universal MediaWiki speed-up percentage for Memcached on a VPS. Results depend on the wiki’s workload, PHP opcode caching, APCu use, database latency, cache size, page and object reuse, and whether one server or several are sharing the cache. The 64 MB value in the startup example is not a benchmark or a recommended default.

Establish a baseline before changing the cache: record representative page-generation times, database load, PHP memory usage, and error rates. Enable the main cache, repeat the same workload, and look for lower repeated database work without introducing evictions or memory pressure. Test logged-in and anonymous traffic separately because their cacheability differs. If the wiki is small and single-server, compare the operational simplicity of APCu with the added daemon and network boundary of Memcached.

Operate the cache safely after deployment

  • Keep the service definition, bind address, memory limit, firewall policy, and LocalSettings.php entry documented together.
  • After a reboot, verify that the daemon starts automatically and still listens only on the intended private address.
  • After PHP upgrades, confirm that the web runtime still loads the selected client and sockets support.
  • After adding application servers, update firewall allow-lists and test each host before enabling it for traffic.
  • When changing MediaWiki versions, review cache and session configuration against that release’s reference; do not assume old settings remain valid.
  • Monitor errors, memory pressure, and evictions rather than judging success from a single fast page.

Final deployment checklist

  1. Decide whether shared Memcached is justified or whether APCu is sufficient for this single-server wiki.
  2. Install the daemon and a PHP client matching the web server’s PHP version.
  3. Enable sockets support and restart the actual web runtime.
  4. Bind same-host deployments to 127.0.0.1, or bind multi-node deployments to a private interface.
  5. Make the service persistent through the VPS distribution’s service manager.
  6. Configure $wgMainCacheType and $wgMemCachedServers in LocalSettings.php.
  7. Add parser, message, or session-related settings only after validating the main cache and checking the installed MediaWiki version.
  8. Firewall TCP and UDP so only the required application hosts can reach Memcached.
  9. Verify the listener, PHP web module, MediaWiki status output, and representative logged-in and anonymous requests.
  10. Measure the workload and memory behavior before claiming a performance improvement.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.