Optimize WordPress for Speed

wordpress speed up

I used WordPress for 10 years, so I'd like to share some experience about the operational part. You can find a lot of articles about the installation, but much fewer articles about how to optimize it on the server-side. Let's see!

Note: you need to verify every new setting in the target file before adding them. If the setting is already set (duplicated), the last one will be active. Press CTRL + W to find string while using nano :)

 

MariaDB SQL Performance tuning:

nano /etc/security/limits.conf

mysql soft nofile 65535

mysql hard nofile 65535

 

nano /etc/mysql/mariadb.conf.d/50-server.cnf

max_allowed_packet = 256M

max_connections = 500

query_cache_type = 1

query_cache_limit = 256K

query_cache_min_res_unit = 2k

query_cache_size = 80M



Optimize PHP Performance:

nano /etc/php/8.0/fpm/php-fpm.conf

log_level = warning

 

Disable unnecessary PHP modules

Verify your PHP version by run php -v before running these commands, and replace it with your installed version!

sudo phpdismod ctype ffi shmop sysvmsg sysvsem sysvshm xmlreader

systemctl reload php7.3-fpm

Verify your site after this step! My WordPress install works for years without these modules, but maybe others will not.

 

Apache - Security settings

nano /etc/apache2/apache2.conf

#Generate fewer Apache log (you will never check them, I'm sure)

LogLevel warn access_compat:crit

# Do not show your Apache version on the web

ServerSignature Off

ServerTokens Prod

# Disable ETags - Security reason

<IfModule mod_headers.c>

        Header unset ETag

</IfModule>

FileETag None

# Disable weak protocolls

SSLProtocol     all -SSLv3 -TLSv1 -TLSv1.1

 

Enable HTTP/2 - Reduce loading times

sudo apt install php7.3-fpm

sudo a2dismod php7.3

sudo a2enconf php7.3-fpm

sudo a2enmod proxy_fcgi

sudo a2dismod mpm_prefork

sudo a2enmod mpm_event

sudo a2enmod ssl http2

sudo systemctl restart apache2

 

Verify HTTP/2 here: http2.pro

 

 

Get free $100 credit on DigitalOcean if you Sign Up through this link. Great possibility to try VPS (Virtual Personal Server) technology for free.

Comments