Skip to content

Instantly share code, notes, and snippets.

@croxton
Last active September 5, 2021 23:34
Show Gist options
  • Select an option

  • Save croxton/d2294e9413ed3c4ebde1 to your computer and use it in GitHub Desktop.

Select an option

Save croxton/d2294e9413ed3c4ebde1 to your computer and use it in GitHub Desktop.

Revisions

  1. croxton revised this gist Jan 22, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -149,7 +149,7 @@ PHP 5.5 has opcode caching built in, but it is disabled by default. Edit `/usr/l
    zend_extension=opcache.so
    [opcache]
    opcache.enable=1
    opcache.enable_cli=1
    opcache.enable_cli=0
    opcache.memory_consumption=128
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=4000
  2. croxton revised this gist Sep 10, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ If you want to handle 100+ concurrent users with the same modest hardware see th

    ### PHP 5.5.13

    Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/Apache/ModRuid) we're using DSO as the PHP handler. My load testing shows it's faster and more stable than the only other sensible option on cPanel (FCGI), but YMMV. When cPanel finally adds PHP-FPM to EasyApache, use that (do NOT be tempted to go the DIY route). Tick the `Silence Deprecated Patch` if you are running EE < 2.8, since a few things throw deprecated notices in PHP 5.5.
    Since we're using [mod_ruid2](https://documentation.cpanel.net/display/EA/Apache+Module:+ModRuid2) we're using DSO as the PHP handler. My load testing shows it's faster and more stable than the only other sensible option on cPanel (FCGI), but YMMV. When cPanel finally adds PHP-FPM to EasyApache, use that (do NOT be tempted to go the DIY route). Tick the `Silence Deprecated Patch` if you are running EE < 2.8, since a few things throw deprecated notices in PHP 5.5.

    * Bcmath
    * CGI
  3. croxton revised this gist Jan 8, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -112,7 +112,7 @@ Edit `/etc/my.cnf`
    query-cache-type = 1
    query-cache-size = 80M
    query-cache-limit = 256K
    query-cache-min-res-unit = 2K
    query-cache-min-res-unit = 2048
    max-connections = 500
    thread-cache-size = 50
    open-files-limit = 65535
  4. croxton revised this gist Jan 8, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -112,7 +112,7 @@ Edit `/etc/my.cnf`
    query-cache-type = 1
    query-cache-size = 80M
    query-cache-limit = 256K
    query-cache-min-res-unit = 2k
    query-cache-min-res-unit = 2K
    max-connections = 500
    thread-cache-size = 50
    open-files-limit = 65535
  5. croxton revised this gist Jan 8, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -112,7 +112,7 @@ Edit `/etc/my.cnf`
    query-cache-type = 1
    query-cache-size = 80M
    query-cache-limit = 256K
    query-cache-min-res-unit = 2k
    query-cache-min-res-unit = 2k
    max-connections = 500
    thread-cache-size = 50
    open-files-limit = 65535
  6. croxton revised this gist Jan 8, 2015. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -110,8 +110,9 @@ Edit `/etc/my.cnf`
    tmp-table-size = 64M
    max-heap-table-size = 64M
    query-cache-type = 1
    query-cache-size = 128M
    query-cache-limit = 2M
    query-cache-size = 80M
    query-cache-limit = 256K
    query-cache-min-res-unit = 2k
    max-connections = 500
    thread-cache-size = 50
    open-files-limit = 65535
  7. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    "Medium traffic" = able to handle around 50 concurrent users on average and burst up to 100 without causing your server to thrash.
    "Medium traffic" = able to handle around 50 concurrent users on average.

    If you want to handle 100+ concurrent users with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.

  8. croxton revised this gist Jan 6, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    "Medium traffic" = able to handle around 50 concurrent users on average and burst up to 100-150 without causing your server to thrash.
    "Medium traffic" = able to handle around 50 concurrent users on average and burst up to 100 without causing your server to thrash.

    If you want to handle 500+ concurrent users with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.
    If you want to handle 100+ concurrent users with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.

    ### VPS

  9. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A

    ### My.cnf config for MySQL 5.6

    The following configuration is optimised for running EE websites *with a mix of MySIAM and InnoDB tables*. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it). Note that setting `performance_schema = 0` is esential for production sites, as this can use significant amounts of memory.
    The following configuration is optimised for running EE websites **with a mix of MySIAM and InnoDB tables**. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it). Note that setting `performance_schema = 0` is esential for production sites, as this can use significant amounts of memory.

    Edit `/etc/my.cnf`

  10. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A

    ### My.cnf config for MySQL 5.6

    The following configuration is optimised for running EE websites with a mix of MySIAM and InnoDB tables. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it). Note that setting `performance_schema = 0` is esential for production sites, as this can use significant amounts of memory.
    The following configuration is optimised for running EE websites *with a mix of MySIAM and InnoDB tables*. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it). Note that setting `performance_schema = 0` is esential for production sites, as this can use significant amounts of memory.

    Edit `/etc/my.cnf`

  11. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -63,7 +63,7 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A
    - should be same as min spare servers

    **Server Limit** 65
    - Assuming MySQL uses between 0.5 - 1GB, Linux and other services are using around 0.4GB, so you have between 2.6GB-3.1GB to allocate to Apache. If your httpd processes typically use around 40MB per process (normal for EE) then being conservative: 65x40MB = 2600MB (~2.54GB)
    - Assuming MySQL uses between 0.5 - 1GB (as it will if you use the config below), Linux and other services are using around 0.4GB, so you have between 2.6GB-3.1GB to allocate to Apache. If your httpd processes typically use around 40MB per process (normal for EE) then being conservative: 65x40MB = 2600MB (~2.54GB)

    - Don't rely on the Template Debugger to tell you how much a typical Apache process uses - run `top` in your terminal while your site is under load.

  12. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -63,7 +63,7 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A
    - should be same as min spare servers

    **Server Limit** 65
    - Assuming MySQL uses between 0.5 - 1GB, Linux and other services are using around 0.4GB, so you have between 2.6GB-3.1GB to allocate to Apache. If your httpd processes typically use around 40Mb per process (normal for EE) then being conservative: 65x40Mb = 2600Mb (~2.54GB)
    - Assuming MySQL uses between 0.5 - 1GB, Linux and other services are using around 0.4GB, so you have between 2.6GB-3.1GB to allocate to Apache. If your httpd processes typically use around 40MB per process (normal for EE) then being conservative: 65x40MB = 2600MB (~2.54GB)

    - Don't rely on the Template Debugger to tell you how much a typical Apache process uses - run `top` in your terminal while your site is under load.

  13. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -63,7 +63,7 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A
    - should be same as min spare servers

    **Server Limit** 65
    - Assuming MySQL uses between 0.5 - 1Gb, Linux and other services are using around 0.4Gb, so you have between 2.6Gb-3.1Gb to allocate to Apache. If your httpd processes typically use around 40Mb per process (normal for EE) then being conservative: 65x40Mb = 2600Mb.
    - Assuming MySQL uses between 0.5 - 1GB, Linux and other services are using around 0.4GB, so you have between 2.6GB-3.1GB to allocate to Apache. If your httpd processes typically use around 40Mb per process (normal for EE) then being conservative: 65x40Mb = 2600Mb (~2.54GB)

    - Don't rely on the Template Debugger to tell you how much a typical Apache process uses - run `top` in your terminal while your site is under load.

  14. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -175,7 +175,7 @@ When you're done login to WHM and find the new Varnish control panel.

    On the advanced configuration page:

    * Set Cache time to Live to 600 seconds.
    * Set Cache time to Live to 600 seconds (go higher if you have a lot of content that doesn't change frequently).
    * Set Memory Cache to 250M (can go up to 2G, depends on how big site is and how much is cached).
    * Add these URLs using the 'URL opt-out' field: `admin\.php` and `ACT=`. (Add any other URLs you want to exclude from caching, e.g. 'system' if you still have that in your webroot).

  15. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -175,7 +175,7 @@ When you're done login to WHM and find the new Varnish control panel.

    On the advanced configuration page:

    * Set Cache time to Live to 60 seconds (go higher if you dare or have heavy traffic).
    * Set Cache time to Live to 600 seconds.
    * Set Memory Cache to 250M (can go up to 2G, depends on how big site is and how much is cached).
    * Add these URLs using the 'URL opt-out' field: `admin\.php` and `ACT=`. (Add any other URLs you want to exclude from caching, e.g. 'system' if you still have that in your webroot).

  16. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A

    ### My.cnf config for MySQL 5.6

    The following configuration is optimised for running EE websites with a mix of MySIAM and InnoDB tables. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it).
    The following configuration is optimised for running EE websites with a mix of MySIAM and InnoDB tables. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it). Note that setting `performance_schema = 0` is esential for production sites, as this can use significant amounts of memory.

    Edit `/etc/my.cnf`

  17. croxton revised this gist Jan 6, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -77,6 +77,7 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A
    **Keep-Alive** Off

    - You may want to turn on Keep Alives, but if you do use low limits:

    **Keep-Alive Timeout** 1
    **Max Keep-Alive Requests** 50

  18. croxton revised this gist Jan 6, 2015. 1 changed file with 11 additions and 8 deletions.
    19 changes: 11 additions & 8 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -62,26 +62,29 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A
    **Start Servers** 3
    - should be same as min spare servers

    **Server Limit** 75
    - No more than 75% of available ram. If your webpages typically uses 40Mb per process then 75x40Mb = 3000Mb of ram used. Don't rely on the Template Debugger to tell you how much a typical Apache process uses - run `top` in your terminal while your site is under load.
    **Server Limit** 65
    - Assuming MySQL uses between 0.5 - 1Gb, Linux and other services are using around 0.4Gb, so you have between 2.6Gb-3.1Gb to allocate to Apache. If your httpd processes typically use around 40Mb per process (normal for EE) then being conservative: 65x40Mb = 2600Mb.

    - Don't rely on the Template Debugger to tell you how much a typical Apache process uses - run `top` in your terminal while your site is under load.

    **Max Request Workers** 75
    **Max Request Workers** 65
    - Same as server limit

    **Max Connections Per Child** 3750
    **Max Connections Per Child** 3250
    - Should be at between 10x - 50x the max request workers.
    - Higher means more chance of memory leaks from poorly coded PHP scripts (bad) but fewer new processes (good), so experiment.

    **Keep-Alive** On
    **Keep-Alive** Off

    - You may want to turn on Keep Alives, but if you do use low limits:
    **Keep-Alive Timeout** 1
    **Max Keep-Alive Requests** 50
    **Max Keep-Alive Requests** 50

    - You may want to turn off Keep Alives if Apache regularly uses up the server's limits, you use CDNs for your assets, or run a reverse-proxy like [Nginx Admin](http://www.nginxcp.com/) for static files.
    - See: http://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html
    - Also: http://www.reddit.com/r/webdev/comments/1bs4t0/3_small_tweaks_to_make_apache_fly/

    **Time Out** 120


    ### My.cnf config for MySQL 5.6

    The following configuration is optimised for running EE websites with a mix of MySIAM and InnoDB tables. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it).
  19. croxton revised this gist Jan 5, 2015. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -62,14 +62,14 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A
    **Start Servers** 3
    - should be same as min spare servers

    **Server Limit** 100
    - No more than 75% of available ram. If your webpages typically uses 30Mb per process then 100x30Mb = 3000Mb of ram used. Don't rely on the Template Debugger to tell you how much a typical Apache process uses - run `top` in your terminal while your site is under load.
    **Server Limit** 75
    - No more than 75% of available ram. If your webpages typically uses 40Mb per process then 75x40Mb = 3000Mb of ram used. Don't rely on the Template Debugger to tell you how much a typical Apache process uses - run `top` in your terminal while your site is under load.

    **Max Request Workers** 100
    **Max Request Workers** 75
    - Same as server limit

    **Max Connections Per Child** 5000
    - Should be at between 10x - 50x the max clients.
    **Max Connections Per Child** 3750
    - Should be at between 10x - 50x the max request workers.
    - Higher means more chance of memory leaks from poorly coded PHP scripts (bad) but fewer new processes (good), so experiment.

    **Keep-Alive** On
  20. croxton revised this gist Jan 5, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -100,6 +100,7 @@ Edit `/etc/my.cnf`
    innodb = FORCE
    innodb-strict-mode = 1
    myisam-recover = FORCE,BACKUP
    performance_schema = 0
    # CACHES AND LIMITS #
    tmp-table-size = 64M
  21. croxton revised this gist Jan 5, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -102,10 +102,10 @@ Edit `/etc/my.cnf`
    myisam-recover = FORCE,BACKUP
    # CACHES AND LIMITS #
    tmp-table-size = 48M
    max-heap-table-size = 48M
    tmp-table-size = 64M
    max-heap-table-size = 64M
    query-cache-type = 1
    query-cache-size = 64M
    query-cache-size = 128M
    query-cache-limit = 2M
    max-connections = 500
    thread-cache-size = 50
    @@ -123,7 +123,7 @@ Edit `/etc/my.cnf`
    innodb-buffer-pool-size = 512M

    # MyISAM #
    key-buffer-size = 512M
    key-buffer-size = 256M

    # LOGGING #
    log-error = /var/lib/mysql/mysql-error.log
  22. croxton revised this gist Jun 20, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -82,11 +82,11 @@ Since we're using [mod_ruid2](http://docs.cpanel.net/twiki/bin/view/EasyApache/A
    **Time Out** 120


    ### MySQL config
    ### My.cnf config for MySQL 5.6

    Edit `/etc/my.cnf`
    The following configuration is optimised for running EE websites with a mix of MySIAM and InnoDB tables. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it).

    Optimised for running EE websites with a mix of MySIAM and InnoDB tables. Uncomment sql-mode if you want to run MySQL in strict mode (some add-ons won't like it).
    Edit `/etc/my.cnf`

    [mysqld]

  23. croxton revised this gist Jun 20, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -120,10 +120,10 @@ Optimised for running EE websites with a mix of MySIAM and InnoDB tables. Uncomm
    innodb_additional_mem_pool_size = 20M
    innodb-flush-log-at-trx-commit = 2
    innodb-file-per-table = 1
    innodb-buffer-pool-size = 2G
    innodb-buffer-pool-size = 512M

    # MyISAM #
    key-buffer-size = 64M
    key-buffer-size = 512M

    # LOGGING #
    log-error = /var/lib/mysql/mysql-error.log
  24. croxton revised this gist Jun 9, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    "Medium traffic" = able to handle around 50 concurrent users on average and burst up to 100-150 without causing your server to thrash.

    If you want to handle far, far more traffic with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.
    If you want to handle 500+ concurrent users with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.

    ### VPS

  25. croxton revised this gist Jun 5, 2014. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -174,7 +174,11 @@ On the advanced configuration page:
    * Set Memory Cache to 250M (can go up to 2G, depends on how big site is and how much is cached).
    * Add these URLs using the 'URL opt-out' field: `admin\.php` and `ACT=`. (Add any other URLs you want to exclude from caching, e.g. 'system' if you still have that in your webroot).

    Now you need to customize `/etc/varnish/default.vcl`. The code below is adapted from Unixy's config and [this article](http://ellislab.com/blog/entry/making-sites-fly-with-varnish) by Kevin Cupp. It enables the Mustash Varnish plugin or Kevin's own Purge extension to purge the Varnish cache when cache-breaking rules are triggered. Note also that Purging is only enabled for one domain (replace `example.com` with your domain). Refer to the article if you want to make further changes to the vcl config such as enabling Edge Side Includes.
    Now you need to customize `/etc/varnish/default.vcl`. The code below is adapted from Unixy's config and [this article](http://ellislab.com/blog/entry/making-sites-fly-with-varnish) by Kevin Cupp. It enables the Mustash Varnish plugin or Kevin's Purge extension to purge the Varnish cache when cache-breaking rules are triggered. With Mustash, Varnish cache-breaking is granular: when Stash full page caches are cleared in the CP or cache-breaking is triggered by rules, the corresponding Varnish cache object will be cleared.

    Refer to the article if you want to make further changes to the vcl config such as enabling Edge Side Includes.

    Note: If you have set a custom `cookie_prefix` in your site config, change `exp_sessionid` to `your_prefix_sessionid`.

    Restart Varnish (from WHM control panel) after editing `default.vcl`.

    @@ -388,7 +392,7 @@ Restart Varnish (from WHM control panel) after editing `default.vcl`.
    set resp.http.X-Cache = "MISS";
    }
    # test
    # cache object url
    set resp.http.X-Url = req.url;

    }
  26. croxton revised this gist Jun 5, 2014. 1 changed file with 20 additions and 6 deletions.
    26 changes: 20 additions & 6 deletions cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -182,8 +182,6 @@ Restart Varnish (from WHM control panel) after editing `default.vcl`.
    # Copyright (c) UNIXY - http://www.unixy.net #
    # The leading truly fully managed server provider #
    ###################################################

    # Adapted for ExpressionEngine

    include "/etc/varnish/cpanel.backend.vcl";

    @@ -263,16 +261,22 @@ Restart Varnish (from WHM control panel) after editing `default.vcl`.

    # Purge
    if (req.request == "PURGE") {
    if (!client.ip ~ acl127_0_0_1) {error 405 "Not permitted";}
    return (lookup);
    if (!client.ip ~ acl127_0_0_1) {error 405 "Not permitted";}
    return (lookup);
    }

    # EE purge (via Mustash Varnish plugin)
    # Clear the cache for an entire domain
    if (req.request == "EE_PURGE") {
    ban("req.http.host ~ example.com && req.url ~ ^/.*$");
    ban("req.url ~ ^/.*$ && req.http.host == "+req.http.host);
    error 200 "Purged";
    }

    # Clear any cached object that matches the exact req.url
    if (req.request == "EE_PURGE_URL") {
    ban("req.url == "+req.url+" && req.http.host == "+req.http.host);
    error 200 "Purged";
    }

    ## Default request checks
    if (req.request != "GET" &&
    req.request != "HEAD" &&
    @@ -284,10 +288,16 @@ Restart Varnish (from WHM control panel) after editing `default.vcl`.
    return (pipe);
    }

    # Don't cache dynamic content
    if (req.request != "GET" && req.request != "HEAD") {
    return (pass);
    }

    # Don't cache content for logged in users
    if (req.http.Cookie ~ "exp_sessionid") {
    return (pass);
    }

    ## Modified from default to allow caching if cookies are set, but not http auth
    if (req.http.Authorization) {
    return (pass);
    @@ -377,6 +387,9 @@ Restart Varnish (from WHM control panel) after editing `default.vcl`.
    else {
    set resp.http.X-Cache = "MISS";
    }
    # test
    set resp.http.X-Url = req.url;

    }

    @@ -434,3 +447,4 @@ Restart Varnish (from WHM control panel) after editing `default.vcl`.




  27. croxton revised this gist Jun 4, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    "Medium traffic" = able to handle around 50 concurrent users on average and burst up to 100-150 without causing your server to thrash.

    If you want to handle far more with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.
    If you want to handle far, far more traffic with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.

    ### VPS

  28. croxton revised this gist Jun 4, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    "Medium traffic" = able to handle around 50 concurrent users on average and burst up to 100-150 without causing your server to thrash.

    If you want to handle far more with this modest hardware see the Varnish section below.
    If you want to handle far more with the same modest hardware see the [Varnish](https://gist.github.com/croxton/d2294e9413ed3c4ebde1#varnish) section below.

    ### VPS

  29. croxton revised this gist Jun 4, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -168,7 +168,7 @@ Once you have downloaded the zip from Unixy, upload it to /usr/src. Then SSH int

    When you're done login to WHM and find the new Varnish control panel.

    On the advanaced configuration page:
    On the advanced configuration page:

    * Set Cache time to Live to 60 seconds (go higher if you dare or have heavy traffic).
    * Set Memory Cache to 250M (can go up to 2G, depends on how big site is and how much is cached).
    @@ -178,6 +178,13 @@ Now you need to customize `/etc/varnish/default.vcl`. The code below is adapted

    Restart Varnish (from WHM control panel) after editing `default.vcl`.

    ###################################################
    # Copyright (c) UNIXY - http://www.unixy.net #
    # The leading truly fully managed server provider #
    ###################################################

    # Adapted for ExpressionEngine

    include "/etc/varnish/cpanel.backend.vcl";

    include "/etc/varnish/backends.vcl";
  30. croxton revised this gist Jun 4, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion cpanel_vps_eecms_config.md
    Original file line number Diff line number Diff line change
    @@ -174,7 +174,9 @@ On the advanaced configuration page:
    * Set Memory Cache to 250M (can go up to 2G, depends on how big site is and how much is cached).
    * Add these URLs using the 'URL opt-out' field: `admin\.php` and `ACT=`. (Add any other URLs you want to exclude from caching, e.g. 'system' if you still have that in your webroot).

    Now you need to customize `/etc/varnish/default.vcl`. The code below is adapted from Unixy's config and [this womderful article](http://ellislab.com/blog/entry/making-sites-fly-with-varnish) by Kevin Cupp. It enables the Mustash Varnish plugin to purge the Varnish cache when cache-breaking rules are triggered. Note also that Purging is only enabled for one domain (replace `example.com` with your domain).
    Now you need to customize `/etc/varnish/default.vcl`. The code below is adapted from Unixy's config and [this article](http://ellislab.com/blog/entry/making-sites-fly-with-varnish) by Kevin Cupp. It enables the Mustash Varnish plugin or Kevin's own Purge extension to purge the Varnish cache when cache-breaking rules are triggered. Note also that Purging is only enabled for one domain (replace `example.com` with your domain). Refer to the article if you want to make further changes to the vcl config such as enabling Edge Side Includes.

    Restart Varnish (from WHM control panel) after editing `default.vcl`.

    include "/etc/varnish/cpanel.backend.vcl";