Drastically Increase WordPress Server Performance and Speed (no plugins!) – Complete WordPress Hardening Guide – Part 3

Probably the biggest issue with WordPress is how heavy and slow it can be. If you have been around WordPress for any length of time, you have heard everyone say you can increase server performance and speed using plugins. While that is possible to an extent, much of the time it just creates more load and cause more issues.

We are going to do everything at the server level, which is exactly what should be done if you are going to do this right. We have a locked down installation, let’s make it extremely fast!

3.1 – Enable Nginx Compression to Increase WordPress server performance and speed.

Let’s enable compression, by turning it on in the nginx configuration file

Enable Compression

sudo nano /etc/nginx/nginx.conf

Uncomment the following lines:

If you have extra CPU on your host, you can turn up the compression level up level 9. I am running level 8 on my server.

4026ffe1-b68a-47a1-af25-b1ac87fbfba5-image.png

3.2 Use YUI- Compressor to compress java script files

Thanks to Patrick Robinson for being a good resource to create this section and help me with the image compression as well 🙂

Install yui-compressor

sudo apt install yui-compressor

Create a script

Now we need to create a script so we can run this against all javascript files in the /var/www/html

sudo nano /var/www/html/compress_js.sh

Now paste following contents into the file you just created. We are using find to search for javascript files, then running yui-compressor --type js against them.

#!/bin/sh
for file in `find . -name "*.js"`
do
echo "Compressing $file …"
yui-compressor --type js -o $file $file
done

Backup the theme and plugins Directories

These directories contain js files. If we compress and break something, we want to make sure we have a backup

cp -rf /var/www/html/wp-content/plugins /var/www/html/wp-content/plugins-bak

cp -rf /var/www/html/wp-content/themes /var/www/html/wp-content/themes-bak

Time to run the javascript compress script

sudo sh /var/www/html/compress_js.sh

This should really increase wordpress server performance , but it will take a while to run this for the first time.

You will see a similar output:

f4be8ad6-a337-4c4d-ad59-a5e5c7c880cb-image.png

3.3 Use JPEG-Optim to compress jpg files

This process is very similar to the above process. We only slightly changed our script.

Install Jpeg-Optim

sudo apt install jpegotptim

Create script

sudo nano /var/www/html/compress_jpg.sh

Add the following to the new script:

#!/bin/sh
for file in `find . -name "*.jpg"`
do
echo "Compressing $file …"
jpegoptim $file
done

Run jpeg-optim script

sudo sh /var/www/html/compress_jpg.sh

Jpeg-optim will only compress files it can make smaller. If you see any negative numbers, that means the files will be skipped.

1aeda93c-5eb2-4b5e-89d4-e857f2ea0ef3-image.png

Check out the other parts of this guid here

For Baseline hardening and configuration please see Part 1 of this guide.

For Installing LEMP with Nginx Security and Intrusion Prevention see Part 2 of this guide.

0 Points


Leave a Reply

Your email address will not be published. Required fields are marked *