Author Topic: Wordpress - High-Performance instructions  (Read 54429 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Wordpress - High-Performance instructions
« on: December 02, 2018, 02:18:13 PM »
Wordpress - High-Performance instructions
Currently, this is available only for CentOS 7 version 0.9.8.741+, soon will be available also for CentOS 6.

Video Instructions
https://www.youtube.com/watch?v=5PeACKK4Mq4

- make sure you have installed php-fpm 7.0, 7.1 or 7.2...you can choose any version.
- rebuild your webservers with Nginx & Varnish & Apache.

Now we will explain here two types of websites, one is webshop or website with order forms and frequent changes and the other is a company website that doesn't make updates frequently but has a high traffic.

1. webshop (or website with frequent changes).
2. company website (which has no frequent changes but has a high traffic).

1. webshop (or website with frequent changes)
* for this kind of website we recommend that the varnish is disabled or has a custom config, please note that by default varnish is always disabled so you will not need to do anything specific here as varnish needs to be additionally enabled even if you run webservers with setup Nginx & Varnish & Apache.

- default php-fpm configuration for version 7.0, 7.1 or 7.2 will be ok.
- nginx should be enabled and if you have built servers as Nginx & Varnish & Apache then you are ok.
- Make sure that in left menu WebServers Settings -> WebServers Domain Conf config for your domain for apache is set to nginx -> apache -> php-fpm and PHP-FPM version is set to 7.0, 7.1 or 7.2.
- if you run WordPress you should install in WordPress cache plugin like "W3 Total Cache".
and you are ready to go, with this kind of setup your site will be able to handle up to 15x more traffic with much higher speed.


2. company website (which has no frequent changes but has a high traffic)
* for this kind of website we recommend that varnish is enabled, please note that by default varnish is always disabled so you will need to additionally enabled it even if you run webservers with setup Nginx & Varnish & Apache.

- default php-fpm configuration for version 7.0, 7.1 or 7.2 will be ok.
- nginx&varnish should be enabled and if you have built servers as Nginx & Varnish & Apache then you are ok.
- Make sure that in left menu WebServers Settings -> WebServers Domain Conf config for your domain for apache is set to nginx -> varnish -> apache -> php-fpm and PHP-FPM version is set to 7.0, 7.1 or 7.2. This will activate Varnish and php-fpm.
- if you run WordPress you should install in WordPress cache plugin like "W3 Total Cache".
and you are ready to go, with this kind of setup your site will be able to handle up to 30x more traffic with much higher speed.

YouTube instructions:
https://www.youtube.com/watch?v=5PeACKK4Mq4

** Please note that php 7 is recommended here as it's much faster than php 5.

--
More detailed info about new cwp webservers
http://forum.centos-webpanel.com/high-performance/cwp-webservers-detailed-info/

Custom Templates
http://wiki.centos-webpanel.com/webservers-vhost-templates
« Last Edit: January 16, 2019, 11:12:25 PM by Administrator »
AntiDDoS Protection (web + mail)
http://centos-webpanel.com/website-ddos-protection-proxy

Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp


Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor


Do you need Fast and FREE Support included for your CWP linux server?
http://centos-webpanel.com/noc-partner-list
Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
***
Re: Wordpress - High-Performance instructions
« Reply #1 on: December 02, 2018, 02:54:52 PM »
Fantastic update. Waiting for an update for Centos 6.

Offline
**
Re: Wordpress - High-Performance instructions
« Reply #2 on: December 02, 2018, 04:13:08 PM »
Nice but would be better if complete instructions were give as in how to activate Varnish?

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #3 on: December 02, 2018, 04:21:43 PM »
Nice but would be better if complete instructions were give as in how to activate Varnish?

- Make sure that in left menu WebServers Settings -> WebServers Domain Conf config for your domain for apache is set to nginx -> varnish -> apache -> php-fpm and PHP-FPM version is set to 7.0, 7.1 or 7.2. This will activate Varnish and php-fpm.
AntiDDoS Protection (web + mail)
http://centos-webpanel.com/website-ddos-protection-proxy

Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp


Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor


Do you need Fast and FREE Support included for your CWP linux server?
http://centos-webpanel.com/noc-partner-list
Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #4 on: December 03, 2018, 12:02:27 AM »
If you switch to PHP-FMP, can you still have different PHP versions per directory, use htaccess to specify the version and have a php.ini per directory?
« Last Edit: December 03, 2018, 12:06:48 AM by jeffshead »

Offline
**
Re: Wordpress - High-Performance instructions
« Reply #5 on: December 03, 2018, 03:52:39 PM »
If you switch to PHP-FMP, can you still have different PHP versions per directory, use htaccess to specify the version and have a php.ini per directory?

Add the following to .htaccess and change the version to which version you want to run

Code: [Select]
AddHandler application/x-httpd-php72 .php

Assuming you're  using Apache

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #6 on: December 03, 2018, 09:47:09 PM »
php-fpm is per domain
php-cgi is per folder

you can combine all this however you want
Note php-cgi is using php.ini while php-fpm is using .user.ini for configuration inside users home folder.
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Offline
**
Re: Wordpress - High-Performance instructions Varnish Config file
« Reply #7 on: December 04, 2018, 05:07:31 PM »
Heres a copy of my working  /etc/varnish/default.vcl

Code: [Select]
vcl 4.0;
backend default { .host = "Server_IP goes here"; .port = "8181";}
include "/etc/varnish/conf.d/vhosts.conf";
import directors;
import std;
acl purge {
    "localhost";
"127.0.0.1";
}


sub vcl_recv {



# Only a single backend
        set req.backend_hint= default;

        # Setting http headers for backend
        set req.http.X-Forwarded-For = client.ip;
    set req.http.X-Forwarded-Proto = "https";

    # Unset headers that might cause us to cache duplicate infos
    unset req.http.Accept-Language;
    unset req.http.User-Agent;

# The purge...no idea if this works
if (req.method == "PURGE") {
    if (!client.ip ~ purge) {
      return(synth(405,"Not allowed."));
    }
    return (purge);
  }
  if ( std.port(server.ip) == 6080) {

set req.http.x-redir = "https://" + req.http.host + req.url;
                return (synth(750, "Moved permanently"));
        }


  # drop cookies and params from static assets
  if (req.url ~ "\.(gif|jpg|jpeg|swf|ttf|css|js|flv|mp3|mp4|pdf|ico|png)(\?.*|)$") {
    unset req.http.cookie;
    set req.url = regsub(req.url, "\?.*$", "");
  }

# drop tracking params
  if (req.url ~ "\?(utm_(campaign|medium|source|term)|adParams|client|cx|eid|fbid|feed|ref(id|src)?|v(er|iew))=") {
    set req.url = regsub(req.url, "\?.*$", "");
  }

# pass wp-admin urls
    if (req.url ~ "(wp-login|wp-admin)" || req.url ~ "preview=true" || req.url ~ "xmlrpc.php") {
    return (pass);
  }

# pass wp-admin cookies
  if (req.http.cookie) {
    if (req.http.cookie ~ "(wordpress_|wp-settings-)") {
      return(pass);
    } else {
      unset req.http.cookie;
    }
  }
 }



sub vcl_backend_response {
    # retry a few times if backend is down
    if (beresp.status == 503 && bereq.retries < 3 ) {
       return(retry);
 }

    if (bereq.http.Cookie ~ "(UserID|_session)") {
# if we get a session cookie...caching is a no-go
        set beresp.http.X-Cacheable = "NO:Got Session";
        set beresp.uncacheable = true;
        return (deliver);

    } elsif (beresp.ttl <= 0s) {
        # Varnish determined the object was not cacheable
        set beresp.http.X-Cacheable = "NO:Not Cacheable";

    } elsif (beresp.http.set-cookie) {
        # You don't wish to cache content for logged in users
        set beresp.http.X-Cacheable = "NO:Set-Cookie";
        set beresp.uncacheable = true;
        return (deliver);

    } elsif (beresp.http.Cache-Control ~ "private") {
        # You are respecting the Cache-Control=private header from the backend
        set beresp.http.X-Cacheable = "NO:Cache-Control=private";
        set beresp.uncacheable = true;
        return (deliver);

    } else {
        # Varnish determined the object was cacheable
        set beresp.http.X-Cacheable = "YES";

        # Remove Expires from backend, it's not long enough
  unset beresp.http.expires;

        # Set the clients TTL on this object
        set beresp.http.cache-control = "max-age=900";

        # Set how long Varnish will keep it
        set beresp.ttl = 1w;

        # marker for vcl_deliver to reset Age:
        set beresp.http.magicmarker = "1";
    }

# unset cookies from backendresponse
if (!(bereq.url ~ "(wp-login|wp-admin)"))  {
set beresp.http.X-UnsetCookies = "TRUE";
    unset beresp.http.set-cookie;
    set beresp.ttl = 1h;
}

# long ttl for assets
  if (bereq.url ~ "\.(gif|jpg|jpeg|swf|ttf|css|js|flv|mp3|mp4|pdf|ico|png)(\?.*|)$") {
    set beresp.ttl = 365d;

}
 set beresp.grace = 1w;

}

sub vcl_hash {
   if ( req.http.X-Forwarded-Proto ) {
    hash_data( req.http.X-Forwarded-Proto );
}
}

sub vcl_backend_error {
      # display custom error page if backend down
      if (beresp.status == 503 && bereq.retries == 3) {
          synthetic(std.fileread("/etc/varnish/error503.html"));
          return(deliver);
       }
 }

sub vcl_synth {
    # redirect for http
    if (resp.status == 750) {
        set resp.status = 301;
        set resp.http.Location = req.http.x-redir;
        return(deliver);
    }
# display custom error page if backend down
    if (resp.status == 503) {
        synthetic(std.fileread("/etc/varnish/error503.html"));
        return(deliver);
     }
}


sub vcl_deliver {
    # oh noes backend is down
    if (resp.status == 503) {
        return(restart);
    }
    if (resp.http.magicmarker) {
       # Remove the magic marker
        unset resp.http.magicmarker;

       # By definition we have a fresh object
       set resp.http.age = "0";
     }
   if (obj.hits > 0) {
     set resp.http.X-Cache = "HIT";
   } else {
     set resp.http.X-Cache = "MISS";
   }
   set resp.http.Access-Control-Allow-Origin = "*";
}
sub vcl_hit {
  if (req.method == "PURGE") {
    return(synth(200,"OK"));
  }
}

sub vcl_miss {
  if (req.method == "PURGE") {
    return(synth(404,"Not cached"));
  }
}

Offline
***
Re: Wordpress - High-Performance instructions
« Reply #8 on: December 14, 2018, 10:00:40 AM »
Nice but would be better if complete instructions were give as in how to activate Varnish?

- Make sure that in left menu WebServers Settings -> WebServers Domain Conf config for your domain for apache is set to nginx -> varnish -> apache -> php-fpm and PHP-FPM version is set to 7.0, 7.1 or 7.2. This will activate Varnish and php-fpm.

Hi,

"....varnish needs to be additionally enabled even if you run webservers with setup Nginx & Varnish & Apache...."

How to activate or deactivate Varnish?!?

Venty

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #9 on: December 25, 2018, 05:02:22 PM »
I did exactly this steps but I faced with this error
Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

error_log
[proxy:error] [pid 2077:tid 140129255540480] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /opt/alt/php-fpm72/usr/var/sockets/gold.sock (*) failed
[proxy_fcgi:error] [pid 2077:tid 140129255540480] [client 94.96.12.70:52996] AH01079: failed to make connection to backend: httpd-UDS, referer:

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #10 on: January 06, 2019, 03:30:44 AM »
Hello!
First of all thanks for the update and for the great job.

But the following is missing:

  • To be able to activate the Brotli extension for file compression which is much better GZIP. https://centos.pkgs.org/7/remi-x86_64/php72-php-brotli-0.6.1-1.el7.remi.x86_64.rpm.html
  • To be able to edit from each account (List Accounts) or since the same configuration of Manager Web Server the Vhosts, PHP.ini, Nginx,Varnish, Extensions, DNS and this all centralized in a same place for an account/domain/webserver.
  • Also when accessing by SSH to a domain where the PHP version is 7.2 I tried to run PHP Composer, but I had problems updating packages because the global version of CLI was 5.6, is it possible to configure it for the same version of PHP?




« Last Edit: January 06, 2019, 03:33:24 AM by rabo »

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #11 on: January 12, 2019, 06:59:10 PM »
I did it again on a new fresh cwp server but I still have error 503 service unavailable

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #12 on: February 05, 2019, 02:31:44 AM »
Same sundigital's issue for me, I have disabled PHP-FPM in my server. Waiting for a solution.
« Last Edit: February 05, 2019, 02:33:56 AM by francisco »

Offline
*
Re: Wordpress - High-Performance instructions
« Reply #13 on: March 02, 2019, 04:40:56 AM »
My CWP Pro also after activate the Varnish for per domain,and the website will 503 varnish failed.
The website is using Latest Wordpress Version.

Offline
**
Re: Wordpress - High-Performance instructions
« Reply #14 on: March 02, 2019, 04:30:01 PM »
Are you using SSL? I had to delete the certs and reinstall them after I setup the Webservers Domain Conf.

I'm running Nginx>Varnish>Apache > php-fpm > ClassicPress (Fork of WordPress) with no problems.