All About Our WordPress-Optimized LEMP
Posted by on 28 August 2013 12:37 PM
The A Small Orange WordPress Optimized LEMP stack is built upon Nginx version 1.4.x, PHP versions 5.4 or 5.5 (template dependent) with PHP-FPM and MySQL 5.5. The installation has been tuned with appropriate configuration files to achieve a high degree of performance within A Small Orange's Cloud VPS and Dedicated server platforms.
WARNING The LEMP stack VPS is designed as a standalone web server, and does not include a DNS hosting server due to security considerations, as well as performance reasons. A local caching DNS service is provided instead for performance optimization, but this can't be used to host domain names. To direct traffic to your LEMP stack VPS you will need to host domain services through one of the following options:
The configuration files for the LEMP stack consist of global configurations as they relate to system Firewall, PHP and MySQL, followed by more specific configurations, virtual host/user dependent, related to PHP-FPM and Nginx.
Virtual Host / User Configurations:
We have configured a default system user for you, which also contains your default and fully up-to-date WordPress installation. The login credentials for the default system user and the default WordPress installation are provided to you as a welcome message when you log in to your server over SSH. The welcome message is only viewable to the root user upon login and will expire after 14 days. Please ensure you copy the welcome message with the default credentials to a safe location.
Default Username: wordp1
The WordPress Optimized LEMP environment is default configured with SSH-based SFTP service (port 22) enabled and FTP (port 21) service disabled. The majority of modern FTP applications fully support the use of SFTP based uploads and we strongly recommend that you utilize only the SFTP to conduct your uploads. The SFTP service is a fully encrypted transport protocol and ensures your data and authentication credentials are never transmitted in plain text over the Internet.
If you should require FTP access, this can be conveniently enabled as follows:
The use of W3 Total Cache can provide an array of additional features to improve performance of your WordPress installation. We do not recommend the use of W3 Total Cache features Page Cache, Minify or Browser Cache, as these tasks are adequately handled by the default Nginx configuration and Nginx MicroCache.
We do recommend the use of MemCached with W3 Total Cache for Object Cache and Database Cache. The use of these caching features with Memcached can accelerate performance and improve scaling of larger WordPress installations.
The use of remote CDN services and Cloudflare with W3 Total Cache can provide additional orders of scale to your WordPress installation but care needs to be taken when enabling these services as they require additional configuration outside the control of the LEMP environment.
Note: there may be no tangible performance benefit when some or all of these features are used on small or default WordPress installations.
To use W3 Total Cache with Page Cache file (disk basic) caching, specialized rules for nginx must be enabled as follows:
Note: this is not required if you only intend to use Object Cache and Database Cache through memcached. You should never enable two caching plugins, such as W3 Total Cache and WP Super Cache, as doing so can have adverse performance implications.
The use of WP Super Cache can provide an array of additional features to improve performance of your WordPress installation. This plugin is safe to use in conjunction with Nginx MicroCache.
Recommended settings under the Advanced tab for WP Super Cache to ensure compatibility are as follows:
To use WP Super Cache you must first enable specialized rules for nginx as follows:
Note: you should never enable two caching plugins, such as W3 Total Cache and WP Super Cache as doing so can have adverse performance implications.
The Nginx installation utilizes a technique of caching commonly referred to as microcaching. A microcache is a caching pool with a small on-disk size and a very short expiration lifetime on cached content, intended to offer better orders of scale for concurrent accesses in a short period of time to dynamic content.
In a typical deployment, where no caching is leveraged, every request serviced by a server for dynamic PHP content requires processing that request through PHP and performing any dependent MySQL queries with it. This can be very resource-intensive for pages that may be receiving high levels of concurrent visitors and is not efficient, especially if the page is not likely to change in a short period of time.
The configuration of the WordPress Optimized LEMP installation has Microcaching default enabled with a maximum cache lifetime of 30 seconds for any cached pages. In addition, specialized rules are in place to ensure POST content is never cached and that WordPress administrators, logged in users or those who have recently left comments on a page, are not cached.
The Microcache feature can be disabled as follows:
As an interpreted language, PHP files are first compiled in memory and then served to customer requests. An Opcode Cacher allows the compiled data for frequently accessed PHP files to be stored in shared memory and all subsequent requests to those PHP files are served from the precompiled copy located in shared memory. This allows requests for PHP content to be completed quicker, using lower amounts of server resources and to achieve higher orders of scale in improving the efficiency of concurrent requests.
The WordPress Optimized LEMP stack comes configured with Zend OpCache (Zend Optimizer+) for PHP version 5.4 and 5.5. The debut of Zend OpCache has marked a milestone for opcode caching in that it is the first ever opcode cache to be included and shipped with PHP. The development and testing of Zend OpCache has been over a year in the making by Zend Inc. and the PHP.net development team and as such it is viewed as a highly stable, production-ready opcode cache system in an ecosystem where opcode caching is often viewed as problematic.
To modify the Zend OpCache configuration (not recommended), open and edit the following file:
The use of PHP APC Cache is not recommended with A Small Orange WordPress Optimized LEMP stack and the use of it may cause unpredictable behavior and an overall reduction in system performance and reliability.
If you wish to use PHP APC Cache as an object storage solution for W3 Total Cache we encourage you to instead use MemCached which offers better orders of scale, performance and reliability.
The memcached server is a general-purpose distributed memory caching system, used to store key based data objects. The typical use of memcached is for result set storage to improve performance of complex applications where frequent requests to data can be serviced from memcached instead of backend database systems.
A default installation of memcached is provided for you with your WordPress Optimized LEMP environment along with supporting extensions enabled by default in PHP. The memcached service is not started by default as it is not a service used by all customers and would consume memory needlessly.
If you wish to enable memcached, for use with supporting software, please follow the following instructions.
The memcached configuration file, for increasing or decreasing the memory allocation size of memcached can be found at /etc/sysconfig/memcached. The default values are as follows:
Listen Address: 127.0.0.1
We have configured your server with a default caching name server to store DNS query results locally for a period of time. The use of a DNS cache improves the efficiency of DNS systems as requests can be satisfied much faster from the local cache after an initial query. The end result is an increase in performance of any applications that rely on DNS resolution, such as complex web applications.
The DNS caching service installed on your server is called 'dnsmasq' and is enabled by default on boot. The service is restricted to local access (127.0.0.1) to ensure the security of your server. The public recursive resolvers that your server uses are a group of 4 global resolvers provided by Leve3 Communications and Google DNS. The choice of public resolvers is one made with the utmost care for your systems security, reliability and performance. The resolvers operated by Level3 and Google are an advanced, anycast, DNS infrastructure that is known for being among the most reliable and secure public recursive resolvers available.