Knowledgebase: WordPress
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:

  • Add a domain to a Shared Hosting account with us for pointing purposes

    OR

  • ​Use one of these DNS services: CloudDNSCloudFlareEntryDNS 


Configuration Files

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.

Global Configurations:

Firewall: /etc/apf/conf.apf
PHP: /etc/php.ini
PHP-FPM: /etc/php-fpm.conf
MySQL: /etc/my.cnf
Nginx: /usr/local/nginx/conf/nginx.conf

Virtual Host / User Configurations:

PHP-FPM: /etc/php-fpm.d/wordp1.conf
Nginx: /usr/local/nginx/vhost/wordp1.conf


Default User & File Uploads (SFTP & FTP)

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
Document Root: /home/wordp1/public_html

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:

  1. Log in to server as root over SSH

  2. Execute the '/etc/apf/extras/enableftp' script

    # /etc/apf/extras/enableftp


    FTP service has been enabled and port 21 opened in the firewall.

  3. Proceed to use your preferred FTP program and connect to your server with the FTP protocol on port 21 using the user login credentials provided to you in your root login welcome message

WordPress Plugins > W3 Total Cache

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.

  1. Open /usr/local/nginx/vhosts/wordp1.conf

  2. Find and uncomment line referencing 'w3tc.conf'.

    BEFORE:
              # uncomment for w3 totalcache plugin support
          # include /usr/local/nginx/global/w3tc.conf;
    AFTER:
             # uncomment for w3 totalcache plugin support
          # include /usr/local/nginx/global/w3tc.conf;

  3. Restart Nginx service
    '/etc/init.d/nginx restart'

WordPress Plugins > WP Super Cache

 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:

  • Cache hits to this website for quick access

  • Legacy page caching

  • Don’t cache pages for known users

  • Cache rebuild; serve a supercache file to anonymous users while a new file is being generated

  • Clear all cache files when a post or page is published or updated (not recommended for large WordPress installations)

  • Only refresh current page when comments made

  • Late init; Display cached files after WordPress has loaded

    Note: there may be no tangible performance benefit to using a Caching plugin such as WP Super Cache on small or default WordPress installations.

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. 

  1. Open '/usr/local/nginx/vhosts/wordp1.conf'

  2. Find and uncomment line referencing 'wpsc.conf'

    BEFORE:
              # uncomment for w3 totalcache plugin support
          # include /usr/local/nginx/global/wpsc.conf;
    AFTER:
              # uncomment for w3 totalcache plugin support
          # include /usr/local/nginx/global/wpsc.conf;

  3. Restart Nginx service
    '/etc/init.d/nginx restart'

Acceleration > Nginx Microcache

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:

  1. Open '/usr/local/nginx/vhosts/wordp1.conf'

  2. Find and comment out the line referencing 'microcache.conf 

    BEFORE:
                  # nginx/fastcgi based microcaching, recommended
             include /usr/local/nginx/global/microcache.conf;
    AFTER:
                  # nginx/fastcgi based microcaching, recommended
             # include /usr/local/nginx/global/microcache.conf;

  3. Restart Nginx service
    '/etc/init.d/nginx restart'

Acceleration > Zend OpCache (Zend Optimizer+)

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:

'/etc/php.d/opcache.ini'

Acceleration > PHP APC Cache

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.

Acceleration > Memcached

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.

  1. Log in as root to your server

  2. Start the memcached service with

    /etc/init.d/memcached
    # /etc/init.d/memcached start

  3. Mark the memcached service to be started on boot:

    # chkconfig --level 3 memcached start

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
Listen Port: 11211
Cache Size: 128MB

Acceleration > DNS Caching

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 Level3 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.

  • 8.8.4.4
  • 8.8.8.8
  • 4.2.2.1
  • 4.2.2.2

 

b
(10 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion
ERROR: This domain name (kb.asmallorange.com), does not match the domain name in the license key file help.asmallorange.com.

For assistance with your license, please contact the Kayako support team: https://support.kayako.com