FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Topics
On this page
-
- Getting Started
- Git and File-System Layout (non-default setup)
- Version Constraints
- Managing Themes and Plugins (for entire WordPress site)
- Updating Themes and Plugins (for entire WordPress site)
- Adding Composer Support to Your Own Themes and Plugins (for developers)
- Using Composer to Manage Own Theme/Plugin Dependencies (for developers)
-
- Assigning Multiple IP Addresses to Single LAN Card
- Disable IPv6 on Ubuntu 12.04
- dsh – distributed shell
- fdupes – find & replace duplicate files with hardlinks
- GPG Keys Cheatsheet
- Increase "Open Files Limit"
- kill all php, nginx, mysql or any kind of processes
- Passwordless Authentication for SSH
- Screen
- search replace in multiple files useing grep xargs sed
- Setup sftp
- sysctl.conf
- Timezone Sync
- Using Google Public DNS on Ubuntu Server
- Using openssl to match private key, cerificate and CSR
- Configure Postfix to Use Gmail SMTP on Ubuntu
- Logrotate Example for Custom Logs
- PHP 5.5, MySQL, Postfix, Nginx and WordPress on Ubuntu
- Serverdensity
- Upgrade Ubuntu 10.04 to 12.04
- Using find and sed to replace strings in multiple files
- Webmin
-
- .my.cnf – mysql user & password
- Analyse slow-query-log using Anemometer
- Improving MySQL Query Cache
- MySQL Query Profiling
- Reset MySQL root password
- tuning-primer.sh – an alternative for mysqltuner
- Using MariaDB 10
- Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS
- Change WordPress Domain Name
- Character Sets and Collations
- Enable innodb_file_per_table
- Enable Remote Access (Grant)
- Installing Percona Toolkit
- Using tmpfs for temporary folder creation
- YARPP and InnoDB
- Convert MyISAM to InnoDB
- Using tmpfs for mysqldump & mysqlimport
- Convert from INNODB to MYISAM
- Analyse slow-query-log using mysqldumpslow & pt-query-digest
- mysqlcheck with cron to optimize automatically
- Using MySQLTuner to Optimize MySQL configuration
-
-
- Directly connect to PHP-FPM
- Generating core-dump for php5-fpm
- GeoIP
- Having php5 and php7 on same system.
- Install Xdebug and configure it with webgrind
- Installation of PHP Code Review Tools
- memcache
- PHP's Zend Opcache Config & Web Viewer
- Setting Sqlite support with PHP
- Using HHVM with PHP-FPM Fallback
- Using Redis for PHP Sessions on Ubuntu Server
- Installing PhpMyAdmin Quickly
- Moving PHP's session storage to tmpfs
- Install Xdebug and configure it with Netbeans
- Nginx – Enable PHP-FPM Status Page
- PHP-FPM: Socket vs TCP/IP and sysctl tweaking
- APC Cache Optimization & Monitoring Using Web Interface
- Checking if PHP/WordPress can send mails
- Debugging PHP Scripts Using slow_log and more
- Increase file upload size limit in PHP-Nginx
- Increase PHP script execution time with Nginx
-
- Performance Optimization
- Remove Query string of css/js files
- Setup ElasticSearch with ElasticPress
- Using Redis for WordPress Object-Cache
- WooCommerce Window Shopping Caching Technique
- Moving WordPress To New Server (Faster)
- Better wp-cron using linux's crontab
- 404 error- Page not Found!!!
- Debugging WordPress with Nginx
Installation
Config
Increase Max Memory memcache can use
Move PHP's session storage to memcache
Changes in w3-total-cache plugin
Web-based Stats Viewer for Memcache
memcache
Since we moved to PHP 5.5 and it’s built in zend opcache, we decided to stop using APC.
Since zend opcache filled opcaching need only, we needed something for data-cache. There is one APC fork trying to extract data-caching code on Github. But we wanted something stable and mature so we choose to go with memcache.
I always hated presence of php5-memcache and php5-memcached – two solutions for similar needs. I read this and this and many more threads but could reach a conclusion.
Actually for our trivial needs both extensions should work fine. But we (forced) to choose php5-memcache as w3-total-cache doesn’t support only this!
Installation
apt-get install memcached php5-memcache
service php5-fpm restart
Config
Increase Max Memory memcache can use
By default, its 64MB. You may need more.
- Open
/etc/memcached.conf - Look for value
-m 64 - Change it to
-m 1024 - Restart memcached
service memcached restart
Move PHP’s session storage to memcache
Open /etc/php5/mods-available/memcache.ini
Add following lines:
session.save_handler = memcache
session.save_path = "tcp://localhost:11211"
Extra: Since memcached can works in multiserver mode, you can share session across server. Google for more info on this. I will post our config when we will write one! 😉
Changes in w3-total-cache plugin
In w3-total-cache plugin you need to choose memcache as backend for object-cache and database-cache.
Web-based Stats Viewer for Memcache
There are many but we choose phpmemcacheadmin
cd /var/www/example.com/htdocs/
mkdir mem && cd mem
wget http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz
tar -xvzf phpMemcachedAdmin-1.2.2-r262.tar.gz
chmod +r *
chmod 0777 Config/Memcache.php
Installation of PHP Code Review Tools
PREVIOUS
PHP's Zend Opcache Config & Web Viewer
NEXT
Comments
-
RavanH
Hi, as soon as I set
session.save_handler = memcache(and restart php5) I get PHP Internal Server Errors all around… I cannot for the life of me figure out why ;(
Can anyone share some tips on debugging this?-
There are many things which can possibly go wrong. Please check error log for site.
-
-
I’m using also php5.5 with the zend optimiser. I’ve got issues each time I save the settings in W3TC. I think the setting page is cached by the zend optimiser (not by nginx) so the only way to see the changes is to force a browser refresh. Weird. Any way to force the zend optimiser to check the cache for each request? (like apc stat 0)
-
You may need following as described in http://rtcamp.com/wordpress-nginx/tutorials/php/zend-opcache/
opcache.revalidate_freq=0 opcache.consistency_checks=1-
Oups, missed these 2 lines. Thank you Rahul!
-
-
-
Alex
So, i use php 5.3…and want use memcached also
when i uncomment memcache.inisession.save_handler = memcache
session.save_path = “tcp://127.0.0.1:11211”my WP not work, blank page
memcached server is starting of course…and config to -l 127.0.0.1:11211-
You can leave session related 2 lines commented.
Some bad plugins do not work with memcache-based sessions.
-
-
Have you considered the pros and cons of redis vs memcache?
-
Yes. It seems redis is faster but did not proper support for redis in wordpress & nginx world. So for now using memcache.
Also difference is too small to matter for WordPress/content sites.
-
-
ari
Just to add that if installing all this you need to do service php5-fpm restart so w3-total cache will recognize the install
-
Thanks for comment. 🙂
I missed that. I have updated article so php will detect memcache module.
-
-
SID
Hello!
When i’m trying connect to memcache-server using connect – all work very good. But when i trying use addServer – I all time see error timeout connect to server.
Can you help?-
Sorry. I never developed any memcache related codes. We use memcache for WordPress sites through w3-total-cache plugin.
May be you can post it on – http://stackoverflow.com/
-
-
Jeffrey
Hi, really like your posts about wordpress and nginx setup
how can I make sure I’m using memcache right?I install the phpmemcacheadmin, but all the status is 0 ??
tks
-
Run
service memcached status
You should see:* memcached is runningAlso, make sure you have configured WordPress/W3-Total-Cache plugin to use database-cache/object-cache.
-
Features
- Server Setup & Management
- Site Creation & Management
- Create WP Cloud Sites
- Speed & Caching
- Firewall Protection
- Backups & Recovery
- Logs & Monitoring
- Deployments & Developer Tools
- Team Access & User Permissions
Useful Links
Product
Other Products
Subscribe for curated product updates, tips, and announcements.
"*" indicates required fields
Phone
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.