Control Web Panel

WebPanel => Apache => High Performance => Topic started by: Administrator on December 02, 2018, 02:18:13 PM

Title: Wordpress - High-Performance instructions
Post by: Administrator 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
Title: Re: Wordpress - High-Performance instructions
Post by: Jamshed Datori on December 02, 2018, 02:54:52 PM
Fantastic update. Waiting for an update for Centos 6.
Title: Re: Wordpress - High-Performance instructions
Post by: GTMAN on December 02, 2018, 04:13:08 PM
Nice but would be better if complete instructions were give as in how to activate Varnish?
Title: Re: Wordpress - High-Performance instructions
Post by: Administrator 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.
Title: Re: Wordpress - High-Performance instructions
Post by: jeffshead 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?
Title: Re: Wordpress - High-Performance instructions
Post by: GTMAN 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
Title: Re: Wordpress - High-Performance instructions
Post by: studio4host 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.
Title: Re: Wordpress - High-Performance instructions Varnish Config file
Post by: GTMAN 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"));
  }
}
Title: Re: Wordpress - High-Performance instructions
Post by: venty 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
Title: Re: Wordpress - High-Performance instructions
Post by: sundigital 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:
Title: Re: Wordpress - High-Performance instructions
Post by: rabo 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:





Title: Re: Wordpress - High-Performance instructions
Post by: sundigital 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
Title: Re: Wordpress - High-Performance instructions
Post by: francisco 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.
Title: Re: Wordpress - High-Performance instructions
Post by: go626201 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.
Title: Re: Wordpress - High-Performance instructions
Post by: GTMAN 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.
Title: Re: Wordpress - High-Performance instructions
Post by: caffeine on April 01, 2019, 03:17:54 PM
hi, am here for a question about varnis and wordpress.. is Varnish default vhost template "wordpress" suggested for any kind of wordpress site?
thx
Title: Re: Wordpress - High-Performance instructions
Post by: GTMAN on April 01, 2019, 07:39:33 PM
Yes. Varnish will not handle requests with cookies and WordPress uses cookies so they have to be stripped. Thats done via the config file so pick the wordpress template.
Title: Re: Wordpress - High-Performance instructions
Post by: sundigital on April 17, 2019, 11:39:15 AM
after install Nginx & Varnish & Apache on my server and made custom configuration for domains all my wordpress site links changed to https!
It was on http, I didn't install ssl on this domain and didn't change anything on .htaccess or wp-config.php
when I change webserver to simple Apache problem solves.

what's wrong?
Title: Re: Wordpress - High-Performance instructions
Post by: filz51 on May 03, 2019, 05:56:30 PM
I have two image resources that should never be cached. Nice with Apache only but how to apply the caching rules with this setting?
When I switch to this server configuration Varnish and Nginx need a special configuration to bypass caching rules for these resources. What rules and where must they be added in the vHost-Configs for Varnish and Nginx for the resources with URLs https://example.com/webcam/new.jpg and https://example.com/resize/webcam-small.jpg?
Title: Re: Wordpress - High-Performance instructions
Post by: Automata on November 07, 2019, 03:32:21 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?

PROBLEM SOLVED

Hi, i discovered a great website https://www.mysterydata.com/ with a great administrator where you can find many guides for CWP and more, also by registering for free on the forum i found the solution to this problem thanks to the courtesy and extreme availability of the administrator.

SOLUTION:

https://forum.mysterydata.com/topic/2/cwp-brotli-not-work-and-nginx-not-start-after-upgrade-of-cwp-pro-from-v0-9-8-906-to-cwp-pro-v0-9-8-907-even-with-the-last-update-to-cwp-pro-v0-9-8-913/7

Good day and good work to all !
Title: Updateing from Centos 6 to 8 with CWP7PRO
Post by: gunmuse on March 30, 2021, 08:26:40 AM
So I how RogersRaiders.com and the 800k people who came through last month started me looking through the next few years.
Need to get better at mobile look yada,  Need to handle App's with same data. Yada. Need to start thinking about the next generation of graphics. Screeching halt on Centos 6  thus all the new stuff.

I loved my centos 6 setup I deployed a G6 server 10 years ago never replaced a ram stick, hard drive or had a hiccup and we used 40 gig SSD's LONG before there were server ready SSD's  Now we are new cutting edge for severs NVME drives  DDR 4 ram vs 2 plus all the software updates over a decade.
So WordPress for gaming community just kinda works.  I say kinda cause everything is an out of place piece and frankly the guys who build plugin's don't seem to use them in large traffic places So stuff is always not quiet a good fit.

Before i had apache not 3 diffferent versions of apache so add to my confusion where i have not had to worry about anything for 10 years cause it worked.

But in Wordpress now uploading JPEG's and the WP platform needs to convert them to latest Web Friendly formats.  Centos 6 couldn't do this because you couldn't use the GD library properly without downgrading php back to 5.6 from the 7.4 I was already using.

Quote
Requests to images are processed by your server bypassing Apache. When loading images, rules from the .htaccess file are not executed. Occasionally, this only applies to known file extensions: .jpg, .png, etc. and when e.g. .png2 extension is loaded, then the redirections from the .htaccess file work, because the server does not understand this format and does not treat it as image files. Check the redirects for .png file (for which the redirection does not work) and for .png2 file (for which the redirection works correctly).

Change the server settings to stop ignoring the rules from the .htaccess file. Please contact your server administrator.

Also try changing option "Image loading mode" to a different one. Issues about rewrites can often be resolved by setting this option to "Pass Thru". You can do this in plugin settings below. After changing settings, remember to flush cache if you use caching plugin or caching via hosting.

---

Error codes: bypassing_apache

Thats the message i am getting. I have been going through video's and tutorials but to be fair while I have learned a lot.  There is a BUNCH of assumption that new users KNOW where things are or What they are.  My brain is now dated. 

So server setup, WP setup, and Apache/php setup and oh for the freaking love of god has no one noticed we need global permission to email our own users anymore.
I am paying for the monthly support but frankly I shouldn't have to get to a stopping point and UNDERSTAND whats broke to explain it.  If I understood what was broke I would fix it.

For instance i know I can't connect to port 465 the WP software says i can't. But i know the port is open in CSF and the firewalld hardware is turned off.  So what crazy place did someone save the world from a spammer that just happens to put me out of business  until i gain new knowledge?

I wanted the teamspeak 3 server plugin so i can sell teamspeak servers but find out not supported because teamspeak may charge me a late fee for not paying my bill on time?  What does that have to do with the module being there and working me paying my bills is my problem not CWP's
Its apparent there is some make work foreplay in the cwp maybe someone can send me to someone who will help me get my company back working so tha ti can actually pay someone to do the upgrades.