Optimize your server
17.09.2020
Support Wissensdatenbank
Optimize your own Plesk server for better and faster load times.
Activate GZIP on NGINX
- Log on to your server with root via SSH with PuTTY or another SSH program.
- Create the following configuration file:
/etc/nginx/conf.d/gzip.conf##
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/rss+xml text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;
##
- Execute the following command:
#
service nginx restart - Check on the following website if GZIP works:
https://sitechecker.pro/de/gzip-test/Tip: Use a link to an XML or Javascript file.
Activate HTTP/2
- Log in to the web administration at https://admin.firestorm.ch.
- Open your package and log in to Plesk.
- Now click on the icon next to the bell in the upper right corner
- Click on Performance and activate HTTP/2
Optimize cache
- Open the file
/etc/apache2/apache2.conf
- Insert the following content at the end of the file:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>
#<IfModule mod_headers.c>
#Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
#</IfModule>
<FilesMatch "(^\.|xmlrpc\.php|(liesmich|readme)\.*)">
Require all denied
</FilesMatch>
- Save the file
- Restart Apache:
systemctl service apache2 restart
Optimize MySQL
- Execute this command:
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
- Execute this command:
./mysqltuner.pl
This message should appear on your screen:Control warning line(s) into /var/log/mysql/error.log file
…Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
(specially the conclusions at the bottom of the page).
Temporary table size is already large - reduce result set size
Reduce your SELECT DISTINCT queries without LIMIT clauses
Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL
Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB
Variables to adjust:
join_buffer_size (> 1.0M, or always use indexes with JOINs)
innodb_buffer_pool_size (>= 188.1M) if possible.This message means, that MySQLTuner found opportunities to optimize the server. Insert the under “Variables to adjust” suggested changes in the file “/etc/mysql/my.cnf” in the section “[mysqld]”.
- Edit the file “/etc/mysql/my.cnf” under mysqld according to the received feedback. In our case we set the values as follows:
[mysqld]join_buffer_size
= 5Minnodb_buffer_pool_size
= 256M - Execute the command
./mysqltuner.pl
until there is no more need for optimization. - Wait a few days and repeat the command from MySQLTuner again. The longer MySQL works the more accurate the MySQLTuner can give you tips.