How to Install CDN on PHP-Based Applications?

How to Install CDN on PHP-Based Applications?

Install AccuWeb.Cloud’s Premium CDN (Content Delivery Network) to transform your website into a high-speed gateway connecting users worldwide. Our expansive network, powered by cutting-edge technology, accelerates website performance significantly. With coverage across 130+ points on 6 continents, our robust infrastructure ensures seamless global accessibility for your website.

If you use AccuWeb.Cloud’s services, you get the same outstanding performance no matter where your website visitors are. And the best part is you won’t get surprise bills based on your users’ location.

Connecting this super-fast highway (CDN) to your website is easy when using AccuWeb.Cloud’s PaaS (Platform as a Service). This guide will show you how to do it with the Premium CDN service, ensuring your website’s content is fast for users worldwide. The instructions are based on the Magento Hosting package, where the e-commerce platform can be installed with just one click and hosted on AccuWeb.Cloud’s PaaS.

Install CDN Add-On

Step 1. Go to your AccuWeb.Cloud dashboard, find the HTTP/3 Premium CDN Add-On in the Marketplace and click Install.

Install HTTP/3 Premium CDN

Step 2. In the window that appears, pick the environment (like WordPress Standalone Kit) where you want CDN, choose the nodes layer you prefer, and click Install.

Choose Environment and Nodes

Step 3. Once the installation is done, a popup will show up with the CDN URL in this format:


${env.envName}-${suffix}.cdn.jelastic.net

Here, ${suffix} is a code name created for your AccuWeb hosting provider when you add the CDN.

CDN Successfully Installed

Step 4. In the first hour or so, you might see a 404 error because it takes a bit of time for the new setup to spread across the CDN network.

404 - Not Found

Setting Up Your Environment

Right now, only the LiteSpeed Web Server supports the HTTP/3 protocol. This modern protocol is still being worked on for the NGINX web server. To make sure your CDN works its best in your setup, this guide focuses on setting up a WordPress Application based on the LiteSpeed Web Server.

To make WordPress assets work well with CDN and prepare your environment for live use, follow these steps:

Step 1. Install WordPress using the LiteSpeed Web Server.

Step 2. Give the LiteSpeed Web Server a public IP address to use the high-speed HTTP/3 protocol without going through a Shared Load Balancer.

Step 3. Connect your domain using an A record. For example, let’s use “accuwebtraining.com.”

Step 4. Set up the Let’s Encrypt SSL Add-On with your custom domain. If your setup uses Built-in SSL, you can turn it OFF in the dashboard.

Step 5. Lastly, make the website’s static content available through the CDN by changing the base URL to the one generated during CDN installation. For WordPress:

Step 6. Open the WordPress admin panel using the link and credentials from the email you got after installation.

WordPress Login Panel

Step 7. Activate the LiteSpeed Cache plugin for your WordPress site.

Activate LightSpeed Cache Plugin

Step 8. Go to LiteSpeed Cache, then the CDN menu.

Go to LightSpeed Cache CDN Menu

Step 9. Paste the CDN URL from the installation email or success window.

Paste the CDN URL

Step 10. Then, enter the website’s Original URL (the domain you connected, in this format: “//accuwordpress.us-accuweb.cloud/”) in the Original URL field. Then, click on the Save Changes button.

Enter Original URL of Website

Connect Your Domain to CDN

After you’ve added the CDN service, it gives you a special domain for your setup, like ${env.envName}-${suffix}.cdn.edgeport.net, as we discussed. But you can also use your custom domain, such as cdn.magento.customdomain.com. Here’s how you do it:

Step 1.Click on the Add-Ons button for your application server. Find the CDN Add-On and click on Configure.

Configure CDN

Step 2. Put your custom domain(s) in the Custom CNAME field. You can list several domains by separating them with a space or semicolon (;). Then, follow the instructions to connect your custom domain using a CNAME record.

Add Custom CNAME

Once you’ve done this, your website’s static content will be accessible through your custom domain.

High Availability Option

In the settings for the CDN Add-On mentioned earlier, you can also pick a method to make sure your setup is highly available.

Round Robin (RR): This spreads requests evenly among all the available nodes.

Primary Failover (PF): All requests go to the first node. If it’s not available, the requests go to the next one, and so on.

High Availability Option

When you add or remove nodes in the application server layer, the platform automatically updates the list of available nodes in the CDN service. This means you don’t have to do anything manually when scaling up or down.

Purge, Purge All, and Uninstall

Step 1. To clean up the stored static files at the CDN points, we can use two actions: Purge or Purge All. When we use these actions, the CDN removes the existing files and downloads fresh copies from the main server.

Purge, Purge All, and Uninstall

Step 2. Purge gets rid of specific files in a chosen location.

Enter Purge Path

On the other hand, Purge All removes all static files at the CDN points. It just asks the user to confirm that they are clearing the cache. Renewing the cache is quicker than when the static files were first spread across the CDN after installing the Add-On.

Conclusion

In conclusion, installing a CDN (Content Delivery Network) on PHP-based applications can greatly enhance their performance. You can efficiently set up a CDN for your application by following the steps. This will help deliver content faster to users, improving overall speed and user experience. Don’t forget to test and monitor the performance after installation to ensure everything works smoothly.