DevOps

I Built a WordPress Site on a Linux VPS… Then Made It FAST

I will show you how to build and deploy a wordpress website on your Linux VPS(Virtual Private Server). I will connect the domain and install the SSL. I will be using InMotion Hosting VPS throughout this tutorial and deploy the website on their server. I will also be performing speed tests on the website and figure out the issues in performance and then use W3 Total Cache Pro to improve performance score for our website for both mobile and desktop. We will be using Google’s PageSpeed Insights for performance testing. W3 total cache pro is a wordpress plugin that will help us optimize images on our website with essentially one click and hence enhance the performance on our website. So, let’s begin and I will show you how I did everything step by step!

1- Creating a Server Snapshot

First off, I’ll create a server snapshot for the sole reason of protecting the server state. In case you have other websites there, it’s a good practice to create a snapshot so you can always go back in case of an issue. However, please note that this is not a replacement for backups.

I clicked on “Server Snapshots” in  the InMotion Hosting’s account management panel aka AMP.

InMotion Hosting dashboard showing the Server Snapshots option highlighted.

I scrolled down on the new screen and clicked on the “Create Snapshot” button. I named it “NEW_SNAPSHOT” and saved it.

InMotion Hosting Server Snapshots page showing a free snapshot and the Create Snapshot button.

You can see that the server snapshot has been taken successfully. I can revert the server whenever I want to this state by clicking the “revert” button and confirming it.

InMotion Hosting Server Snapshots page displaying the Revert Snapshot confirmation dialog with a warning about overwriting current server data.

2- Adding a Domain

Within AMP, I clicked on “CWP User Panel”.

 

InMotion Hosting VPS dashboard showing the CWP User Panel option highlighted for accessing the server control panel.

A new window was opened which is the user panel and here I’ll click on the domain tab in the left side menu. The domain menu is empty as there are no domains added here yet. 

CWP Control Web Panel showing the Domains section and Add a New Domain button for creating an addon domain.

Please note that you can register your domain from InMotion Hosting’s AMP, You also get a free domain credit which you can use to buy. I used that domain credit later to register a domain.

InMotion Hosting domain search showing teamlinuxhint.com available for registration with a free domain credit.

However, for this article, I am using one of my own external domains which is hosted on GoDaddy. I will go to GoDaddy and add an A record, give it a name and add the server’s IP as the value of A record. This means that now the subdomain I just created essentially points to my server.

DNS settings showing how to create an A record for the wpdemo subdomain with an IP address and 30-minute TTL.

I went back to my CWP and clicked on add domain. I added my subdomain, it will automatically specify the directory’s path and then I clicked and checked the option “Add SSL certificate”. Finally I clicked on Save.

CWP Control Web Panel showing how to add a new domain, configure its directory path, enable an SSL certificate, and save the settings.

Now I need to verify if the domain is pointing to the server. For that matter, I went to the browser and typed in my domain and I got this result where default CWP page loads. This means that the domain and server side setup both are properly configured and they are working.

CWP CentOS Web Panel HTTP test page displayed after setting up the wpdemo.nxdigitals.com subdomain, confirming the web server is working.

3- Installing WordPress

In CWP, on the left side bar, I went to “Script Installers” and clicked on “Softaculous”. I clicked on Install WordPress to open up the wordpress installer and start a fresh installation.

CWP Control Web Panel showing the newly added domain wpdemo.nxdigitals.com and the Softaculous script installer highlighted in the sidebar.

Softaculous WordPress installation popup showing featured plugins and the Install WordPress button highlighted.

Softaculous preloads some of the basic wordpress setup. When choosing the URL, I kept the directory empty so the website is loaded directly on the domain and not on a specific path. Inside the “Site Settings”  section, I entered the Site Name, Site Description, Admin Username and Admin Password along with my own email address. 

Softaculous WordPress installation settings showing HTTPS protocol, selected domain, installation directory, and WordPress version 7.1.

Softaculous WordPress installation form showing site name, site description, admin username, password strength, and admin email settings.

Softaculous had plugins selected automatically so I’d not select them, I’d uncheck them all because I want a clean site so I can do a performance test. I don’t want unnecessary clutter or plugins to affect the performance.

Softaculous WordPress installation page showing optional plugins for security, backups, SEO, caching, forms, and website management.

In the Advanced Options, I have disabled the automated backups because I don’t want Softaculous to be creating backups, I can handle that myself on my server. 

Softaculous WordPress advanced installation options showing database settings, automatic updates, backup configuration, and the Install button.

Finally, I clicked on Install and shortly after that wordpress was successfully installed.

Softaculous WordPress installation success page confirming WordPress was installed successfully and displaying the website and admin URLs.

4- Building the Actual Website

With wordpress installed, my URL resolves to this website which is like a basic website/template. 

Newly installed WordPress website at wpdemo.nxdigitals.com displaying the default homepage with the Hello world! blog post.

I logged into my website’s wordpress panel which you can also login to by going to https://yoursite.com/wp-admin and here enter the username and password which was selected during the wordpress installation. After logging into the website, I saw the wordpress dashboard and from here I clicked on Pages and then clicked on Add Page.

WordPress admin dashboard showing the Pages menu expanded with the Add Page option highlighted to create a new page.

WordPress offers quite a few patterns that you can choose to build your website pages, I selected one from many.

WordPress block editor showing starter page patterns with the Tell Your Story layout highlighted for creating a new page.

After that I edited it and made changes in the copy and images to make the page look completely different. Now it looks like a DevOps service website by LinuxHint.

WordPress website displaying the Linux & DevOps Service page with a Build, Deploy, Optimize heading and Explore Tutorials button.

The website is saved and published but still isn’t my homepage so I went to “Settings” then I went to “Reading” and then “Homepage” I selected “Home” and clicked on “Save Changes”. This will load the main page of the website as this page I just designed.

WordPress Reading Settings showing how to set a static homepage, select the Home page, and save changes.

5- Speed Testing the Website Before Optimization

I went to speed test the fresh website on Google’s PageSpeed Insights. Here I entered the URL of my website and I got a 75 performance score for mobile with LCP of 5.3s and FCP 0.7s.

Google PageSpeed Insights mobile performance report showing a score of 75, First Contentful Paint of 1.3 seconds, and Largest Contentful Paint of 8.1 seconds.

For the desktop, I also got a 75 performance score with 5.7s LCP and 0.7s FCP.

Google PageSpeed Insights desktop performance report showing a score of 75, First Contentful Paint of 0.7 seconds, and Largest Contentful Paint of 5.7 seconds.

Keep these scores in mind as we are going to improve them next.

6- Optimizing the Website With W3 Pro Cache

I went to the wordpress dashboard and then I installed and activated the W3 Pro Cache plugin.

WordPress W3 Total Cache plugin details showing performance optimization features and the Install Now button.

Once it’s activated, I was able to see W3 Total Cache in the plugin section. Next I went to the “Performance” tab and then went on to “General Settings”.

WordPress dashboard showing the W3 Total Cache Performance menu expanded with General Settings highlighted.

I added my license key in the “License” field and this would unlock pro features and access for me.

W3 Total Cache General Settings page in WordPress showing the Licensing section and license key field for activating premium features.

In the “Basic Settings” section, I went to Page Cache and checked the option “Enable” and this option “Disk: Enhanced” was pre-selected and I kept it that way. Make sure to “Save Settings”. This helps the plugin serve cached images instead of reloading them each time.

W3 Total Cache Page Cache settings in WordPress showing page caching enabled with the Disk: Enhanced caching method selected.

In the “Browser Cache” segment, go ahead and Check “Enable” option. Make sure to “Save Settings”.

W3 Total Cache Browser Cache settings in WordPress showing browser caching enabled to improve website loading speed.

Now everything is set but the biggest issue that speed test identified was the image delivery, it was heavy and was taking time to load. We can fix that by converting the image to WebP or AVIF formats. I went to “Image Converter” and then clicked and checked on “Enable Image Converter Extension”. Now “Save Settings” and click on “Empty All Caches”.

W3 Total Cache Image Converter settings in WordPress showing the option to enable WebP and AVIF image optimization and save settings.

Now I went to “Total Cache Image Converter” and kept the options such as Output formats as it is:

W3 Total Cache Image Converter settings in WordPress showing lossy compression, automatic image conversion, and WebP and AVIF output formats enabled.

I click on “Convert All” and this would pass all the images through the W3 Total Cache Pro and deliver the resulting compressed images in the media library.

W3 Total Cache Image Converter in WordPress showing the Convert All button for converting existing media library images to WebP and AVIF formats.

I was able to see these images in the media library with 94%-97% reductions in the image size for each image which is huge and will increase performance by a ton.

WordPress Media Library showing W3 Total Cache Image Converter results with WebP and AVIF images reduced in file size by over 93%.

7- Testing the Image Delivery on the Website

I loaded the website and everything was working fine, however, I want to ensure that image delivery is in the new formats so I will open incognito mode in my browser and type the url of my website. I went to the Network tab in the inspect element bar(you can access it by pressing the “F12” key or by right clicking on the page and by clicking “Inspect”) and noticed that upon refresh, Nginx was still serving the old .png images.

Chrome DevTools Network tab showing PNG image requests, file sizes, and loading times for the LinuxHint DevOps demo website.

Apache never got a chance to apply W3 Total Cache Pro’s .htaccess rules. Here I contacted InMotion Hosting’s support team and they helped me trace the issue and they updated the Nginx virtual host configuration which resulted in the desired result. So when I refreshed my URL, the URL still ends with .png but the actual image which is delivered is in WebP format. 

Chrome DevTools Network headers showing a PNG image URL served as image/webp, confirming WebP image delivery.

8- Speed Testing the Website After Optimization

I went to Google’s page speed test and then I again put the URL in and I got 99 performance score for mobile with FCP 1s and LCP down to 2s which is a phenomenal improvement.

Google PageSpeed Insights mobile performance report showing a score of 99, Accessibility 100, Best Practices 100, and SEO 92 after WordPress optimization.

For desktop, the performance score also went up to 99 and FCP came down to 0.4s and LCP came down to 0.7s. Impressive improvements, thanks to W3 total cache plugin. 

Google PageSpeed Insights desktop performance report showing a score of 99, Accessibility 96, Best Practices 100, and SEO 92 after WordPress optimization.

Conclusion

Initially, I decided that I am going to host my wordpress website on a Linux VPS only but after looking at the performance score, I adjusted the direction of this topic and decided to improve the performance of my website with W3 Total Cache Pro plugin which did a phenomenal job and improved my website performance scores for both mobile and desktop by phenomenal margins. I used InMotion Hosting’s VPS and their plans are competitive and their service and support is also very quick and responsive in my experience. I also created a YouTube video doing all of this process and explained every step along the way. 

About the author

Bobby T.

Bobby T. is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.