Skip to content

Instantly share code, notes, and snippets.

@centminmod
Last active July 24, 2021 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save centminmod/55cf4a0dfa91bb4ee28959677ab9547e to your computer and use it in GitHub Desktop.
Save centminmod/55cf4a0dfa91bb4ee28959677ab9547e to your computer and use it in GitHub Desktop.
first time vanilla 2.5.1 forums + centmin mod 123.09beta01 nginx 1.13.10 + php-fpm 7.1.15 + mariadb 10.1.31 + csf firewall + centos 7.4 on 2GB OpenVZ 2cpu E5-1650v3 VPS

Centmin Mod 123.09beta01 install

yum -y update; curl -O https://centminmod.com/betainstaller71.sh && chmod 0700 betainstaller71.sh && bash betainstaller71.sh

Setup Nginx vhost

Using Centmin Mod nv command method of creating Nginx vhost site and addons/mysqladmin_shell to create MySQL database, db user and db password would would also be saved to /etc/centminmod/${vhostname}-dbinfo.ini i.e. /etc/centminmod/vanilla.domain.com-dbinfo.ini.

Creating site domain Nginx vhost called vanilla.domain.com assigned to variable vhostname=vanilla.domain.com

# defining variables
vhostname=vanilla.domain.com
echo "$(curl -4s ipinfo.io/ip) $vhostname" >> /etc/hosts
DBNAME="van2$(pwgen -1cnys 4)"
DBUSER="van2$(pwgen -1cnys 9)"
DBPASS=$(pwgen -1cnys 21)

# create mysql database
echo "/usr/local/src/centminmod/addons/mysqladmin_shell.sh createuserdb $DBNAME $DBUSER $DBPASS" | tee /etc/centminmod/${vhostname}-dbinfo.ini
/usr/local/src/centminmod/addons/mysqladmin_shell.sh createuserdb $DBNAME $DBUSER $DBPASS

example output you get from addons/mysqladmin_shell.sh command and within saved log at /etc/centminmod/${vhostname}-dbinfo.ini i.e. /etc/centminmod/vanilla.domain.com-dbinfo.ini.

echo "/usr/local/src/centminmod/addons/mysqladmin_shell.sh createuserdb $DBNAME $DBUSER $DBPASS"
/usr/local/src/centminmod/addons/mysqladmin_shell.sh createuserdb van22Hsf van2eSXq6XCHb Qpvo5lbPEZQRmKngCgXue

self-signed SSL vhost

nv -d $vhostname -s y -u "ftpu$(pwgen -1cnys 31)"

or letsencrypt SSL vhost

echo "LETSENCRYPT_DETECT='y'" >> /etc/centminmod/custom_config.inc
nv -d $vhostname -s lelive -u "ftpu$(pwgen -1cnys 31)"

Upload Vanilla 2.5.1 files to /home/nginx/domains/${vhostname/zips directory and commands below will extra zip, copy files to web root /home/nginx/domains/${vhostname}/public where $vhostname defined above at vhostname=vanilla.domain.com

cd "/home/nginx/domains/${vhostname}"
cp -a public public.orig
mkdir -p "/home/nginx/domains/${vhostname}/zips"
cd "/home/nginx/domains/${vhostname}/zips"
unzip vanilla-core-2-5-1.zip
chown -R nginx:nginx vanilla-2.5.1
cd vanilla-2.5.1
\cp -Rpf * "/home/nginx/domains/${vhostname}/public"
ls -lah "/home/nginx/domains/${vhostname}/public"
cd "/home/nginx/domains/${vhostname}/public"
chmod 0777 cache conf uploads
chown -R nginx:nginx "/home/nginx/domains/${vhostname}/public"

In web browser go to domain i.e. http://vanilla.domain.com to setup Vanilla using database info derived from /etc/centminmod/${vhostname}-dbinfo.ini i.e. /etc/centminmod/vanilla.domain.com-dbinfo.ini making sure to check do not require .htaccess and after setup in SSH run command:

vhostname=vanilla.domain.com
cd "/home/nginx/domains/${vhostname}/public"
chown -R nginx:nginx "/home/nginx/domains/${vhostname}/public"
echo -e "\n\$Configuration['Garden']['RewriteUrls'] = true;" >> conf/config.php

Nginx rewrite rules

make copy of default php.conf include and use php_vanilla.conf that instead

cp -a /usr/local/nginx/conf/php.conf /usr/local/nginx/conf/php_vanilla.conf
#include /usr/local/nginx/conf/php.conf;
include /usr/local/nginx/conf/php_vanilla.conf;

Nginx rewrite rules to add to non-HTTPS vhost config /usr/local/nginx/conf/conf.d/vanilla.domain.com.conf and/or HTTPS vhost config /usr/local/nginx/conf/conf.d/vanilla.domain.com.ssl.conf

    location ~* "/\.git" { deny all; return 403; }
    location ~* "^/build/" { deny all; return 403; }
    location ~* "^/cache/" { deny all; return 403; }
    location ~* "^/cgi-bin/" { deny all; return 403; }
    location ~* "^/uploads/import/" { deny all; return 403; }
    location ~* "^/conf/" { deny all; return 403; }
    location ~* "^/tests/" { deny all; return 403; }
    location ~* "^/vendor/" { deny all; return 403; }
    
    location / {
             try_files $uri @site;
    }
    location @site {
             rewrite ^ /index.php?p=$uri&$args last;
    }

  include /usr/local/nginx/conf/pre-staticfiles-local-vanilla.domain.com.conf;
  include /usr/local/nginx/conf/pre-staticfiles-global.conf;
  include /usr/local/nginx/conf/staticfiles.conf;
  #include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/php_vanilla.conf;
  
  include /usr/local/nginx/conf/drop.conf;
#  #include /usr/local/nginx/conf/errorpage.conf;
  include /usr/local/nginx/conf/vts_server.conf;

PHP-FPM 7.1.15 benchmarks no cache

ab -n 5000 -k -H "Accept-Encoding: gzip,deflate" -c 25 http://vanilla.domain.com/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vanilla.domain.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx
Server Hostname:        vanilla.domain.com
Server Port:            80

Document Path:          /
Document Length:        2511 bytes

Concurrency Level:      25
Time taken for tests:   38.394 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      14050000 bytes
HTML transferred:       12555000 bytes
Requests per second:    130.23 [#/sec] (mean)
Time per request:       191.972 [ms] (mean)
Time per request:       7.679 [ms] (mean, across all concurrent requests)
Transfer rate:          357.36 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0      11
Processing:    16  191  44.6    189     461
Waiting:       16  191  44.6    189     461
Total:         17  192  44.6    189     462

Percentage of the requests served within a certain time (ms)
  50%    189
  66%    204
  75%    214
  80%    221
  90%    243
  95%    268
  98%    303
  99%    332
 100%    462 (longest request)

retested on different server - Upcloud $20/month 2 cpu, Intel Xeon E5-2687W v4 3.0Ghz

ab -n 5000 -k -H "Accept-Encoding: gzip,deflate" -c 25 http://vanilla.domain.com/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vanilla.domain.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx
Server Hostname:        vanilla.domain.com
Server Port:            80

Document Path:          /
Document Length:        2511 bytes

Concurrency Level:      25
Time taken for tests:   34.912 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      14050000 bytes
HTML transferred:       12555000 bytes
Requests per second:    143.22 [#/sec] (mean)
Time per request:       174.561 [ms] (mean)
Time per request:       6.982 [ms] (mean, across all concurrent requests)
Transfer rate:          393.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:    17  174  23.2    175     323
Waiting:       17  174  23.2    175     323
Total:         18  174  23.2    175     323

Percentage of the requests served within a certain time (ms)
  50%    175
  66%    184
  75%    189
  80%    192
  90%    201
  95%    209
  98%    220
  99%    229
 100%    323 (longest request)

PHP-FPM 7.1.15 + fastcgi_cache enabled

Create /tmp/fastcgicache directory

mkdir -p /tmp/fastcgicache
chown nginx:nginx /tmp/fastcgicache
chmod 0777 /tmp/fastcgicache
  • change 45.32.xxx.xxx to your ISP IP address
  • place in /usr/local/nginx/conf/nginx.conf within http{} context
### Start FastCGI Cache ################
map $http_user_agent $fastcgi_mobile {
    default                                         0;
    ~*android|ip(hone|od)|windows\s+(?:ce|phone)    1;
    ~*symbian|sonyericsson|samsung|lg|blackberry    1;
    ~*mobile                                        1;
    "~*Opera\ Mini"                                 1;
    "~*Tablet"                                      1;
    "~*Kindle"                                      1;
}
map $http_cookie $fastcginocachecookie {
     default                        0;
    ~Vanilla-Vv                     1;   
}
map $request_uri $fastcginocacheuri {
    default                 0;
    ~^/dashboard            1;         
    ~^/ngx_pagespeed_beacon 1;
    ~^/register             1;
    ~^/login                1;
    ~^/validate-field       1;
    ~^/captcha              1;
    ~^/lost-password        1;
    ~^/two-step             1;
    ~^/customer             1;
    ~^/cart/                1;
    ~^/checkout/            1;
    ~^/add-to-cart=         1;
    ~^/wp-admin/            1;
    ~^/my-account/          1;
}
map $remote_addr $fastcgi_debug {
  default 0;
  45.32.xxx.xxx 1;
}
fastcgi_cache_path  /tmp/fastcgicache levels=1:2 keys_zone=fastcgicache:200m inactive=30m max_size=200m loader_files=1000 loader_threshold=2000;
### End FastCGI Cache ################

make copy of default php.conf include and use that instead

cp -a /usr/local/nginx/conf/php.conf /usr/local/nginx/conf/phpcache_vanilla.conf
#include /usr/local/nginx/conf/php_vanilla.conf;
include /usr/local/nginx/conf/phpcache_vanilla.conf;

place in /usr/local/nginx/conf/phpcache_vanilla.conf

### fastcgi_cache start ###
fastcgi_cache_methods GET;
fastcgi_cache_key       $scheme$request_method$host$request_uri$fastcgi_mobile;
#fastcgi_cache_key       $scheme$request_method$host$request_uri;
fastcgi_cache_lock      on;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_ignore_headers  Cache-Control Expires Set-Cookie;
fastcgi_cache           fastcgicache;
fastcgi_no_cache        $fastcginocachecookie $fastcginocacheuri $fastcgi_mobile;
fastcgi_cache_bypass    $fastcginocachecookie $fastcginocacheuri $fastcgi_mobile;
fastcgi_cache_valid     200 3m;
fastcgi_cache_valid     301 302 4m;
fastcgi_cache_valid     303 304 4m;
fastcgi_cache_valid     404 5m;
add_header X-Processing-Time $request_time always;
add_header X-Request-ID      $request_id always;
if ($fastcgi_debug) {
 add_header X-Cache-Status    $upstream_cache_status;
}
fastcgi_hide_header X-Garden-Version;
### fastcgi_cache end ###

so cache TTLS above for fastcgi_cache_valid is set to HTTP Status codes

  • 200 for 3 mins
  • 301 and 302 for 4 mins
  • 303 and 304 for 4 mins
  • 404 for 5 mins

fastcgi cached benchmarks

ab -n 5000 -k -H "Accept-Encoding: gzip,deflate" -c 25 http://vanilla.domain.com/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vanilla.domain.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx
Server Hostname:        vanilla.domain.com
Server Port:            80

Document Path:          /
Document Length:        2534 bytes

Concurrency Level:      25
Time taken for tests:   1.444 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      14475004 bytes
HTML transferred:       12670000 bytes
Requests per second:    3463.13 [#/sec] (mean)
Time per request:       7.219 [ms] (mean)
Time per request:       0.289 [ms] (mean, across all concurrent requests)
Transfer rate:          9790.78 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    3   1.9      3      15
Processing:     0    4   1.9      3      46
Waiting:        0    3   1.7      2      45
Total:          2    7   3.2      6      46

Percentage of the requests served within a certain time (ms)
  50%      6
  66%      7
  75%      8
  80%      9
  90%     12
  95%     13
  98%     16
  99%     19
 100%     46 (longest request)

retested on different server - Upcloud $20/month 2 cpu, Intel Xeon E5-2687W v4 3.0Ghz

ab -n 5000 -k -H "Accept-Encoding: gzip,deflate" -c 25 http://vanilla.domain.com/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vanilla.domain.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx
Server Hostname:        vanilla.domain.com
Server Port:            80

Document Path:          /
Document Length:        2511 bytes

Concurrency Level:      25
Time taken for tests:   0.811 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      14255000 bytes
HTML transferred:       12555000 bytes
Requests per second:    6161.86 [#/sec] (mean)
Time per request:       4.057 [ms] (mean)
Time per request:       0.162 [ms] (mean, across all concurrent requests)
Transfer rate:          17155.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   0.6      2       4
Processing:     0    2   0.7      2       6
Waiting:        0    2   0.7      2       6
Total:          1    4   0.9      4       8

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      5
  80%      5
  90%      5
  95%      6
  98%      6
  99%      7
 100%      8 (longest request)

PHP-FPM 7.1.15 + fastcgi_cache + memcached backend

add to conf/config.php

$Configuration['Cache']['Enabled'] = true;
$Configuration['Cache']['Method'] = 'memcached';
$Configuration['memcached']['Store'] = 'localhost:11211';
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_COMPRESSION] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_DISTRIBUTION] = Memcached::DISTRIBUTION_CONSISTENT;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_LIBKETAMA_COMPATIBLE] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_NO_BLOCK] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_TCP_NODELAY] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_CONNECT_TIMEOUT] = 1000;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_SERVER_FAILURE_LIMIT] = 2;

PHP-FPM fastcgi_cache + memcached

ab -n 5000 -k -H "Accept-Encoding: gzip,deflate" -c 25 http://vanilla.domain.com/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vanilla.domain.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx
Server Hostname:        vanilla.domain.com
Server Port:            80

Document Path:          /
Document Length:        2617 bytes

Concurrency Level:      25
Time taken for tests:   0.912 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      14785000 bytes
HTML transferred:       13085000 bytes
Requests per second:    5482.35 [#/sec] (mean)
Time per request:       4.560 [ms] (mean)
Time per request:       0.182 [ms] (mean, across all concurrent requests)
Transfer rate:          15831.35 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   0.7      2       6
Processing:     0    2   0.7      2       7
Waiting:        0    2   0.7      2       6
Total:          1    5   1.0      4       9

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      5
  75%      5
  80%      5
  90%      6
  95%      6
  98%      8
  99%      8
 100%      9 (longest request)

retested on different server - Upcloud $20/month 2 cpu, Intel Xeon E5-2687W v4 3.0Ghz

run 1

ab -n 5000 -k -H "Accept-Encoding: gzip,deflate" -c 25 http://vanilla.domain.com/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vanilla.domain.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx
Server Hostname:        vanilla.domain.com
Server Port:            80

Document Path:          /
Document Length:        2514 bytes

Concurrency Level:      25
Time taken for tests:   0.807 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      14270000 bytes
HTML transferred:       12570000 bytes
Requests per second:    6194.64 [#/sec] (mean)
Time per request:       4.036 [ms] (mean)
Time per request:       0.161 [ms] (mean, across all concurrent requests)
Transfer rate:          17265.15 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   0.6      2       4
Processing:     0    2   0.7      2       6
Waiting:        0    2   0.7      2       5
Total:          1    4   0.8      4       9

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      4
  80%      5
  90%      5
  95%      5
  98%      6
  99%      6
 100%      9 (longest request)

run 2

ab -n 5000 -k -H "Accept-Encoding: gzip,deflate" -c 25 http://vanilla.domain.com/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vanilla.domain.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx
Server Hostname:        vanilla.domain.com
Server Port:            80

Document Path:          /
Document Length:        2509 bytes

Concurrency Level:      25
Time taken for tests:   0.787 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      14245000 bytes
HTML transferred:       12545000 bytes
Requests per second:    6352.35 [#/sec] (mean)
Time per request:       3.936 [ms] (mean)
Time per request:       0.157 [ms] (mean, across all concurrent requests)
Transfer rate:          17673.68 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   0.5      2       4
Processing:     0    2   0.7      2       7
Waiting:        0    2   0.7      2       5
Total:          0    4   0.8      4       7

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      4
  80%      5
  90%      5
  95%      5
  98%      6
  99%      6
 100%      7 (longest request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment