Join the community today
Register Now

Optimize website with CMM

Discussion in 'Install & Upgrades or Pre-Install Questions' started by korbes, Jul 26, 2019.

  1. korbes

    korbes New Member

    4
    0
    1
    Jul 26, 2019
    Ratings:
    +0
    Local Time:
    4:14 AM
    1.17.2
    10.4
    Hello,

    after playing around with Centminmod for the last week on different test VPSes I feel like its time to switch over fulltime and transfer my sites/forums/etc from other stacks to CMM.

    I still struggle a litte bit with what setup/settings I should use, since its a little bit overwhelming that you can set so many options in the custom_config.inc.

    My current CMM install script looks like this (Thanks to @eva2000):

    Code (Text):
    #!/bin/bash
    # create initial persistent config file to override centmin.sh defaults
    # https://centminmod.com/upgrade.html#persistent
    mkdir -p /etc/centminmod
    touch /etc/centminmod/custom_config.inc
    
    # SET_DEFAULT_MYSQLCHARSET='utf8mb4' to override MariaDB MySQL
    # default characterset and collation from default utf8 to utf8mb4
    # https://community.centminmod.com/threads/17949/
    echo "SET_DEFAULT_MYSQLCHARSET='utf8mb4'" >> /etc/centminmod/custom_config.inc
    
    # enable nginx backlog override https://community.centminmod.com/threads/17620/
    echo "AUTOHARDTUNE_NGINXBACKLOG='y'" >> /etc/centminmod/custom_config.inc
    
    # enable zstd compressed logrotation for nginx & php-fpm https://community.centminmod.com/threads/16374/
    echo "ZSTD_LOGROTATE_NGINX='y'" >> /etc/centminmod/custom_config.inc
    echo "ZSTD_LOGROTATE_PHPFPM='y'" >> /etc/centminmod/custom_config.inc
    
    # enable nginx zero downtime on the fly nginx binary upgrades https://community.centminmod.com/threads/8000/
    #echo "NGINX_ZERODT='y'" >> /etc/centminmod/custom_config.inc
    
    # enable brotli compression https://community.centminmod.com/threads/10688/
    echo "NGINX_LIBBROTLI='y'" >> /etc/centminmod/custom_config.inc
    echo "NGXDYNAMIC_BROTLI='y'" >> /etc/centminmod/custom_config.inc
    
    # boost PHP 7 performance by enabling Profile Guided Optimisation flag
    # https://centminmod.com/perf/
    echo "PHP_PGO='y'" >> /etc/centminmod/custom_config.inc
    
    # php compression extensions https://community.centminmod.com/posts/70777/
    echo "PHP_BROTLI='y'" >> /etc/centminmod/custom_config.inc
    echo "PHP_LZFOUR='y'" >> /etc/centminmod/custom_config.inc
    echo "PHP_LZF='y'" >> /etc/centminmod/custom_config.inc
    echo "PHP_ZSTD='y'" >> /etc/centminmod/custom_config.inc
    
    # install centmin mod latest beta with php-fpm 7.2 default
    # https://community.centminmod.com/threads/centmin-mod-09-beta-branch-testing.4128/
    yum -y update; curl -O https://centminmod.com/betainstaller72.sh && chmod 0700 betainstaller72.sh && bash betainstaller72.sh
    
    # enable letsencrypt ssl certificate + dual RSA+ECDSA ssl certs https://centminmod.com/acmetool/
    echo "LETSENCRYPT_DETECT='y'" >> /etc/centminmod/custom_config.inc
    echo "DUALCERTS='y'" >> /etc/centminmod/custom_config.inc
    
    # install and configure auditd https://community.centminmod.com/posts/37680/
    echo "AUDITD_ENABLE='y'" >> /etc/centminmod/custom_config.inc
    /usr/local/src/centminmod/tools/auditd.sh setup
    
    # setup extended CSF Firewall blocklists https://community.centminmod.com/posts/50060/
    /usr/local/src/centminmod/tools/csf-advancetweaks.sh
    
    # enable CSF Firewall native fail2ban like support
    # https://community.centminmod.com/posts/62343/
    csf --profile backup backup-b4-customregex
    cp -a /usr/local/csf/bin/regex.custom.pm /usr/local/csf/bin/regex.custom.pm.bak
    egrep 'CUSTOM1_LOG|CUSTOM2_LOG|CUSTOM3_LOG|CUSTOM4_LOG' /etc/csf/csf.conf
    sed -i "s|CUSTOM1_LOG = .*|CUSTOM1_LOG = \"/home/nginx/domains/\*/log/access.log\"|" /etc/csf/csf.conf
    sed -i "s|CUSTOM2_LOG = .*|CUSTOM2_LOG = \"/home/nginx/domains/\*/log/error.log\"|" /etc/csf/csf.conf
    sed -i "s|CUSTOM3_LOG = .*|CUSTOM3_LOG = \"/var/log/nginx/localhost.access.log\"|" /etc/csf/csf.conf
    sed -i "s|CUSTOM4_LOG = .*|CUSTOM4_LOG = \"/var/log/nginx/localhost.error.log\"|" /etc/csf/csf.conf
    egrep 'CUSTOM1_LOG|CUSTOM2_LOG|CUSTOM3_LOG|CUSTOM4_LOG' /etc/csf/csf.conf
    wget -O /usr/local/csf/bin/regex.custom.pm https://gist.github.com/centminmod/f5551b92b8aba768c3b4db84c57e756d/raw/regex.custom.pm
    csf -ra
    
    
    
    ##### Additional tools
    echo "Install ncdu............."
    yum -y install ncdu
    echo "Install iotop............"
    yum -y install iotop
    echo "Install htop............."
    yum -y install htop
    echo "Installing ngxtop........"
    pip install ngxtop
    
    
    # Creating tools dir
    mkdir /root/tools
    cd /root/tools/
    
    ### Addons
    #--- mysqladmin_shell addon
    wget -O mysqladmin_shell.sh https://github.com/centminmod/centminmod/raw/123.09beta01/addons/mysqladmin_shell.sh
    echo
    chmod +x mysqladmin_shell.sh
    #--- Make it global executable
    cp mysqladmin_shell.sh /usr/bin/mysqladmin_shell
    chmod +x /usr/bin/mysqladmin_shell
    
    #--- Centminmod Image optimization
    cd /root/tools
    git clone --depth=1 https://github.com/centminmod/optimise-images
    
    
    if [[ -f ~/.nanorc ]]; then
      cp -a ~/.nanorc{,.bak}
      #--- Install .nanorc
      git clone https://github.com/scopatz/nanorc.git ~/.nano
      echo
      spinner
      echo
      cat ~/.nano/nanorc >>~/.nanorc
    fi
    
    echo "Changing prompt..."
    #--- Commenting current prompt
    sed -i 's/^export PS1="/# export PS1="/g' ~/.bashrc
    #--- Appeding new prompt to ~/.bashrc
    cat <<'EOF' >>~/.bashrc
    # Custom Prompt
    export PS1="[\[email protected]\H]-[\w] \\$: "
    EOF
    
    echo "Done!"
    
    



    But I'm not sure if I need the Wordpress Plugin "Autoptimize" with "Autoptimize-Gzip" while I use Brotli.

    My current setup is a DigitalOcean VPS running Ubuntu 18.04 with Webinoly and the following specs:

    Code (Text):
    processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 6
    model           : 79
    model name      : Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
    stepping        : 1
    microcode       : 0x1
    cpu MHz         : 2200.030
    cache size      : 30720 KB
    physical id     : 0
    siblings        : 1
    core id         : 0
    cpu cores       : 1
    apicid          : 0
    initial apicid  : 0
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 13
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt md_clear
    bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds
    bogomips        : 4400.06
    clflush size    : 64
    cache_alignment : 64
    address sizes   : 40 bits physical, 48 bits virtual
    power management:
    


    This is the Webpagetest result:

    https://imgur.com/eicKZ27

    And here is the same website with Centminmod (with the above install script and flags) on a DigitalOcean VPS, with the following specs:

    Code (Text):
    processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 6
    model           : 85
    model name      : Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
    stepping        : 4
    microcode       : 0x1
    cpu MHz         : 2294.608
    cache size      : 25344 KB
    physical id     : 0
    siblings        : 1
    core id         : 0
    cpu cores       : 1
    apicid          : 0
    initial apicid  : 0
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 13
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 pku ospke md_clear spec_ctrl
    bogomips        : 4589.21
    clflush size    : 64
    cache_alignment : 64
    address sizes   : 40 bits physical, 48 bits virtual
    power management:
    


    And here is the Webpagetest result:

    https://imgur.com/AxA67L9

    Now the question is: Do I need Autoptimize and Autoptimize-Gzip, while having Brotli?

    I have installed the website like this:

    Menu Option: 22
    Selected Option 2 for Caching (Redis)

    Then I uploaded a backup of the current site (Mysqldump and a tar.gz of the whole vhost folder), changed the wp-config.php and settings on wp-admin for cache and Autoptimize accordingly and ran the test.

    Thats it basically.

    You guys have any tips? Suggestions? Recommendations?

    I've read articles about WP-Rocket or WP Fastest Cache, but I dont' know if they are worth to buy.

    Best regards.
     
  2. eva2000

    eva2000 Administrator Staff Member

    42,268
    9,550
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,708
    Local Time:
    1:14 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    each of those settings has a forum thread/post link outlining more details and background for the specific setting so worth a read :)

    Autoptimize 2.5 supports both gzip and brotli pre-compressed css/js files as does Autoptimize Gzip so with them both css/js Autoptimized have corresponding precompressed gzip and brotli files. Brotli support happens via these settings
    Code (Text):
    # enable brotli compression https://community.centminmod.com/threads/10688/
    echo "NGINX_LIBBROTLI='y'" >> /etc/centminmod/custom_config.inc
    echo "NGXDYNAMIC_BROTLI='y'" >> /etc/centminmod/custom_config.inc
    
    # php compression extensions https://community.centminmod.com/posts/70777/
    echo "PHP_BROTLI='y'" >> /etc/centminmod/custom_config.inc
    

    which enable nginx brotli module to conditionally serve brotli compressed files to supporting web browsers and PHP_BROTLI='y' enables PHP to support brotli compression which is how Autoptimize/Autoptimze Gzip plugins create brotli pre-compressed css/js files.
     
  3. korbes

    korbes New Member

    4
    0
    1
    Jul 26, 2019
    Ratings:
    +0
    Local Time:
    4:14 AM
    1.17.2
    10.4
    Perfect, thank you!

    So its worth to test it with and without brotli I guess.

    I assume I can change the brotli flags in the custom_config.inc to "n" and then re-compile PHP and Nginx to have it without brotli to test the performance, right?
     
  4. eva2000

    eva2000 Administrator Staff Member

    42,268
    9,550
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,708
    Local Time:
    1:14 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    yes that should be the case
     
    • Like Like x 1