Memcached is a free and open-source distributed memory caching system that can speed up web applications by reducing database load. It is widely used by popular websites such as Facebook, Twitter, Wikipedia, and YouTube. In this article, we will show you how to install Memcached on Windows 10 and Xampp, a free and easy-to-use web server solution that includes Apache, MySQL, PHP, and Perl.
Step 1: Download Memcached for Windows
The official website of Memcached does not provide a Windows binary, but you can download it from a third-party source such as this GitHub repository. Choose the version that matches your system architecture (32-bit or 64-bit) and download the zip file. Extract the file to a directory of your choice, such as C:\\memcached. You should see a file named memcached.exe in the extracted folder.
Step 2: Install Memcached as a Windows Service
To run Memcached as a Windows service, you need to open a command prompt as an administrator. You can do this by pressing the Windows key + X and selecting Command Prompt (Admin) from the menu. Alternatively, you can right-click on the Start button and select Command Prompt (Admin) from the menu.
In the command prompt, navigate to the directory where you extracted Memcached, such as C:\\memcached. Then type the following command to install Memcached as a service:
memcached.exe -d install
You should see a message saying \"Service successfully installed\". To start the service, type:
memcached.exe -d start
You should see a message saying \"Service successfully started\". To stop the service, type:
memcached.exe -d stop
You can also use the Services app in Windows to manage the Memcached service. To open it, press the Windows key + R and type services.msc in the Run dialog box. Then press Enter or click OK. You should see a list of services on your computer. Find Memcached Server in the list and right-click on it. You can then start, stop, restart, or configure the service from the context menu.
Step 3: Enable Memcache Extension for PHP
To use Memcached in your PHP applications, you need to enable the Memcache extension for PHP. Note that Memcache and Memcached are not the same thing. Memcache is a PHP extension that allows you to communicate with Memcached servers. Memcached is the actual caching system that runs as a service.
To enable the Memcache extension for PHP, you need to download the appropriate dll file from this website. Choose the version that matches your PHP version and thread safety (TS or NTS). You can check your PHP version and thread safety by opening a web browser and typing http://localhost/phpinfo.php in the address bar. You should see a page with information about your PHP configuration. Look for the PHP Version and Thread Safety sections.
For example, if your PHP version is 8.0.13 and thread safety is enabled (TS), you should download php_memcache-188.8.131.52-8.0-ts-vc15-x86.zip for 32-bit systems or php_memcache-184.108.40.206-8.0-ts-vc15-x64.zip for 64-bit systems.
After downloading the zip file, extract it to a temporary folder. You should see a file named php_memcache.dll in the extracted folder. Copy this file to your PHP extension directory, which is usually C:\\xampp\\php\\ext.
Next, open your php.ini file, which is usually located in C:\\xampp\\php. Find the line that says ;extension=memcache and remove the semicolon (;) at the beginning of the line to uncomment it. If you don't see this line, you can add it at the end of the file.