HestiaCP is an actively developed fork of popular VestaCP, whos development somewhat stalled in the last little while.
This guide in ispired by excelent post on the official HestiaCP forum by user desp:
How to optimize memory and speed?
Here are three easy steps:
1. Determine hosting/server provider speed
Use excelent YABS script to determine the speed of your hosting solution.
*Geekbench 6 update: since 27 Feb 2023 update YABS uses Geekbench 6 as default benchmark – we’ll use flag -5 to run version 5 so we can compare the results.
wget -qO- yabs.sh | bash -s -- -5
Or if you just want Geekbench score (skipping disk (fio) -f and network (iperf) -i tests):
wget -qO- yabs.sh | bash -s -- -5fi
Test will return something like this:
Geekbench 5 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 832
Multi Core | 867
Full Test | https://browser.geekbench.com/v5/cpu/<test_id_number>
Single core performance is the score we are interested in:
| 1000 or more | Great core performance, very good provider |
| 700 – 1000 | Normal performance, okay provider |
| 500 – 700 | Normal performance, can be better |
| 500 or less | Awful performance, avoid the provider |
Keep in mind, it’s the performance and page speed we’re after, if this is storage/backup optimized server with SAS (spinning) drives, lower numbers are completly accaptable.
Disk performance (IOPS):
fio Disk Speed Tests (Mixed R/W 50/50):
---------------------------------
Block Size | 4k (IOPS) | 64k (IOPS)
------ | --- ---- | ---- ----
Read | 22.76 MB/s (5.6k) | 173.71 MB/s (2.7k)
Write | 22.76 MB/s (5.6k) | 174.62 MB/s (2.7k)
Total | 45.52 MB/s (11.3k) | 348.33 MB/s (5.4k)
| |
Block Size | 512k (IOPS) | 1m (IOPS)
------ | --- ---- | ---- ----
Read | 170.55 MB/s (333) | 213.61 MB/s (208)
Write | 179.61 MB/s (350) | 227.84 MB/s (222)
Total | 350.16 MB/s (683) | 441.45 MB/s (430)
| 1000 or more | Great performance, SSD/NVMe with high IOPS |
RAM is not as important unless you’re running into heavy swapping.
Now that we established our KVM VPS / dedi server is fast enough, we can move on to the next step.
2. Lean HestiaCP install
Classic installation of hestiaCP will result in good enough general setup, that works for most, but it costs us performance. It uses Apache as webserver and Nginx only for caching proxy. Apache is slow.
So let’s trim of the fat and install only
Nginx + PHP + MySQL/MariaDB – without Apache.
Let’s use the handy Install string generator:
For example:
wget https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.sh
sudo bash hst-install.sh --apache no --phpfpm yes --multiphp no --vsftpd yes --proftpd no --named no --mysql yes --postgresql no --exim yes --dovecot no --sieve no --clamav no --spamassassin no --iptables yes --fail2ban yes --interactive yes
This will give us minimal installation, without BIND (DNS), and only EXIM as mailing solution and vsftpd.
3. Set WordPress template and caching
Login to control panel and your user.
Set tamplate
- Edit Web domain → Advanced Options → Web Template → WordPress
Set Fast CGI caching
For small presentation style sites with not a lot of changing content, Fast CGI can be more than enough.
- Enable Fast CGI Cache
- Set Cache duration → 5m, 10m
(if you have a lot of dynamic content, you can try microcache of 30s).
Or implement full Redis cache
For more complex websites or ecommerce sites, Redis is recommendet.
It is a bit more work and requires either that your hosting provider offers Redis or that you have root access to your VPS. If that’s the case, it takes about 5 minutes to implement.
Install Redis on your VPS (example for Ubuntu):
apt update
apt install redis-server
systemctl enable redis-server
Edit the Redis configuration /etc/redis/redis.conf and set the maximum memory size (adjust accordingly if your machine has more RAM and your load requires it) and memory policy:
maxmemory 256M
maxmemory-policy allkeys-lru
Save the changes and restart the Redis server to apply the new configuration:
systemctl restart redis-server
Install PHP Extension:
apt install php-redis
If you have multiple PHP-FPM versions installed, install them each individually (ie. for PHP 8.4):
apt install php8.4-redis
Enable the module (again example for PHP 8.4):
phpenmod -v 8.4 -s ALL redis
Now on to your WordPress website, open wp-config.php file and add the following code to authenticate the key (replace mysite with your unique string for this site, so Redis can keep the caches apart if you’re running more then one website on the same machine):
define('WP_CACHE_KEY_SALT', 'mysite');
define('WP_CACHE', true);
Next, install the Redis Object Cache plugin. It installs a PHP script that helps WordPress communicate with Redis.
After installing the plugin, you need to enable it by navigating to Setting > Redis and Enable Object Cache button. Status should show Connected. If not, ensure you have added the configuration to the wp-config.php file above.
That’s it on the HestiaCP side, now your website should be crazy fast. For further optimisations, look into optimizing WP plugins and theme code.
Thank you for writing this post!
Thanks for your help and for writing this post. It’s been great.
is it still work for newest hestiacp ..
Yes, it still works, currently tested on latest v1.8.8.
Hi, i’ve follow the tutorial. Thanks for this.
But if i want to use docker and containers how can i use these templates to forward to a specific port? I was using hestiacp with apache and used the nginx templates to point to container port in a sub domain.
server {
listen %ip%:%proxy_ssl_port% ssl http2;
server_name %domain_idn% %alias_idn%;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
ssl_stapling on;
ssl_stapling_verify on;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
location / {
proxy_set_header Connection ”;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_pass http://%ip%:8003;
location ~* ^.+\.(%proxy_extentions%)$ {
proxy_set_header Connection ”;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
root %sdocroot%/home/user/web/xxx.xxxx.xxx/public_html;
access_log /var/log/%web_system%/domains/%domain%.log combined;
access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location @fallback {
proxy_set_header Connection ”;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_pass http://%ip%:8003;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
}
You can copy the default templates and modify the new version to your need.
Further details can be found in the official docs:
https://hestiacp.com/docs/server-administration/web-templates.html