Server optimieren
15.09.2020
Support Wissensdatenbank
Optimiere deinen eigenen Plesk Server für bessere und schnellere Ladezeiten.
GZIP bei Nginx aktivieren
- Logge dich mit root über SSH mit PuTTY oder einem anderen SSH Programm auf deinen Server ein.
- Erstelle folgende Konfigurationsdatei:/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;
##
- Führe folgenden Befehl aus:
#
service nginx restart - Prüfe auf folgender Webseite ob GZIP funktioniert:https://sitechecker.pro/de/gzip-test/Tipp: Verwende einen Link zu einer XML oder Javascript Datei.
HTTP2 aktivieren
- Logge dich in die Webadministration unter https://admin.firestorm.ch ein.
- Öffne dein Paket und logge dich in Plesk ein.
- Klicke nun oben rechts auf das Icon neben der Glocke
- Klicke nun auf Performance und aktiviere HTTP/2
Cache optimieren
- Öffne die Datei
/etc/apache2/apache2.conf
- Füge folgenden Inhalt am Ende der Datei hinzu:
<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>
<FilesMatch "(^\.|xmlrpc\.php|(liesmich|readme)\.*)">
Require all denied
</FilesMatch>
- Speichere die Datei
- Starte Apache neu:
systemctl service apache2 restart
MySQL optimieren
- Führe den Befehl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
aus - Führe den Befehl
./mysqltuner.pl
aus
Jetzt sollte so eine Nachricht erscheinen,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.Diese Nachricht bedeutet, dass der MySQLTuner noch Optimierungsmöglichkeiten gefunden hat. Setze die unter “Variables to adjust” vorgeschlagenen Änderungen in der Datei “/etc/mysql/my.cnf” unter dem Abschnitt “[mysqld]” ein.
- Editiere die Datei “/etc/mysql/my.cnf” unter mysqld gemäss der empfangenen Rückmeldung. In unserem Fall setzen wir die Werte wie folgt:
[mysqld]join_buffer_size = 5Minnodb_buffer_pool_size = 256M# * Fine Tuning#key_buffer_size = 16Mmax_allowed_packet = 16Mthread_stack = 192Kthread_cache_size = 8# This replaces the startup script and checks MyISAM tables if needed# the first time they are touchedmyisam-recover-options = BACKUP#max_connections = 100#table_cache = 64#thread_concurrency = 10## * Query Cache Configuration#query_cache_limit = 1Mquery_cache_size = 16M[mysqld] join_buffer_size = 5M innodb_buffer_pool_size = 256M # * Fine Tuning # key_buffer_size = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched myisam-recover-options = BACKUP #max_connections = 100 #table_cache = 64 #thread_concurrency = 10 # # * Query Cache Configuration # query_cache_limit = 1M query_cache_size = 16M
[mysqld] join_buffer_size = 5M innodb_buffer_pool_size = 256M # * Fine Tuning # key_buffer_size = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched myisam-recover-options = BACKUP #max_connections = 100 #table_cache = 64 #thread_concurrency = 10 # # * Query Cache Configuration # query_cache_limit = 1M query_cache_size = 16M
- Führe den Befehl
./mysqltuner.pl
so lange aus, bis kein Optimierungsbedarf mehr besteht. - Warte ein paar Tage ab und wiederhole den Befehl von MySQLTuner erneut. Je länger MySQL arbeitet umso genauer kann der MySQLTuner Tipps geben.