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.


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.

for file in `find . -name "*.js"`
echo "Compressing $file …"
yui-compressor --type js -o $file $file

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:


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:

for file in `find . -name "*.jpg"`
echo "Compressing $file …"
jpegoptim $file

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.


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.

1 Points

2 thoughts on “Drastically Increase WordPress Server Performance and Speed (no plugins!) – Complete WordPress Hardening Guide – Part 3”

  1. sam says:

    hi very good tutorial
    l to have if you dare to do it with redis-server sessions and redisearch

  2. Like!! I blog quite often and I genuinely thank you for your information. The article has truly peaked my interest.

Leave a Reply

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