Power your PHP Blog with ButterCMS and deploy on Cloudways
Tags: headlesscms, php, hosting, blogging
Published: 2020-08-12 19:39:17

<div class="section__blog-post">

<div class="section__content">

<div class="section__content-aside">

#### Table of contents

</div>

<div class="section__content-main">

*   [Why Cloudways?](#why cloudways?)
*   [Deployment Process](#deploymentprocess)
*   [Test Connection](#testconnection)
*   [Conclusion ](#conclusion)

</div>

</div>

# <span style="font-weight: 400;">Why Cloudways?</span>

[<span style="font-weight: 400;">Cloudways</span>](https://www.cloudways.com/en/) <span style="font-weight: 400;">is a managed cloud hosting platform offering the choice of the top cloud infrastructure providers (Google Cloud, Digital Ocean, AWS, VULTR, and Linode) through an intuitive user interface that allows you to focus mainly on achieving your business goals while you manage your applications as per your business needs and requirements. The result - complete peace of mind for you.</span>

<span style="font-weight: 400;">Cloudways offers a wide range of features which makes it an obvious choice for many businesses. Here is a quick list of the Cloudways Platform:</span>

*   <span style="font-weight: 400;">Expert 24/7/365 Support </span>
*   <span style="font-weight: 400;">Multi-Layered Security </span>
*   <span style="font-weight: 400;">Smooth Team Collaboration</span>
*   <span style="font-weight: 400;">Control over server and application management</span>
*   <span style="font-weight: 400;">Performance-enhancing Add-Ons</span>
*   <span style="font-weight: 400;">Real-Time Monitoring</span>

# <span style="font-weight: 400;">ButterCMS Deployment Process</span>

<span style="font-weight: 400;">[ButterCMS](https://buttercms.com/) can be deployed on a wide range of technology stacks such as React, Angular, Gatsby, Ruby, RoR, Node.js, Express.js, Python, ASP.NET, Flask, Django, PHP, Flutter, and Gridsome. It's a lightweight [headless CMS](https://buttercms.com/blog/what-is-headless-cms) that allows you to disconnect your front end with your backend. You can review the integration</span> [<span style="font-weight: 400;">documentation</span>](https://buttercms.com/docs/) <span style="font-weight: 400;">for more details.</span>

<span style="font-weight: 400;">For this guide, I am using the</span> [<span style="font-weight: 400;">Cloudways PHP stack</span>](https://www.cloudways.com/en/php-hosting.php)<span style="font-weight: 400;">. Simply</span> [<span style="font-weight: 400;">sign up for a free 3-day trial</span>](https://platform.cloudways.com/signup) <span style="font-weight: 400;">to test this implementation guide.</span>

<span style="font-weight: 400;"></span>

## Choose Server Specifications

<span style="font-weight: 400;">After signing up, you will be directed to the server launch page where you can launch a managed cloud server and an application by clicking the Launch button at the end of a simple form. During the process, you can:</span>

*   <span style="font-weight: 400;">Choose the Custom PHP applications from the dropdown menu</span>
*   <span style="font-weight: 400;">Enter the application, server and the project’s name</span>
*   <span style="font-weight: 400;">Select the Cloud infrastructure provider</span>
*   <span style="font-weight: 400;">Select the server specifications</span>
*   <span style="font-weight: 400;">Select the server location</span>

<span style="font-weight: 400;">It takes a quick 5-7 minutes to set up the server with your specified configuration and app.</span>

![undefined](https://cdn.buttercms.com/nD2bAZcmRtWF7GTxnGks)

<span style="font-weight: 400;"> </span>

## Deploy ButterCMS Files on the Server

<span style="font-weight: 400;">I will use the Cloudways’ SSH Terminal to deploy the ButterCMS on the server. </span>

![undefined](https://cdn.buttercms.com/iQxZQTgRXqFOo3ZHL3Rw)

<span style="font-weight: 400;">Visit the Server Management. Next:</span>

1.  <span style="font-weight: 400;">Launch the SSH Terminal </span>
2.  <span style="font-weight: 400;">Use the provided credentials to access the server through SSH</span>

<span style="font-weight: 400;">![undefined](https://cdn.buttercms.com/S9ZyZadmQvqpixsX5BYS)</span>

<span style="font-weight: 400;">Now go to the application’s</span> **public_html** <span style="font-weight: 400;">folder. Use the</span> **ls** <span style="font-weight: 400;">command to navigate through the folders and files.</span>

<span style="font-weight: 400;">Use the following command to initiate ButterCMS deployment on the server.</span>

<span style="font-weight: 400;">composer require buttercms/buttercms-php</span>

![undefined](https://cdn.buttercms.com/c9dDEXxBQwiIIC9yT5tk)

<span style="font-weight: 400;">And that’s it. You’ve successfully deployed ButterCMS on the Server on the PHP application. </span>

**Tip:** <span style="font-weight: 400;">You can use a similar deployment process for almost any PHP powered application on a Cloudways managed cloud server by using the SSH Terminal.</span>

# <span>[Discover how ButterCMS works with your php app](https://buttercms.com/php-cms/)</span>

# <span style="font-weight: 400;"></span>

# <span style="font-weight: 400;">Test Connection</span>

<span style="font-weight: 400;">Now, let’s try and check the connection.</span>

<span style="font-weight: 400;">For this, I assume that you’ve already signed up with ButterCMS and in the dashboard section, you can access the API Token. </span>

## Pull a Sample Blog Post

<span style="font-weight: 400;">Using FileZilla, I established a connection with the Cloudways’ server to access the backend files and folders. I created a home.php file to pull a blog from the ButterCMS platform.</span>

<span style="font-weight: 400;">![undefined](https://cdn.buttercms.com/2ZGs5zfGTBW1KxiASADq)</span>

<span style="font-weight: 400;">The home.php file contains the following code:</span>

    <?php
     require 'vendor/autoload.php'; // initiate and established the connection 
     $apiToken = '12a6f976db677e6c10453cce70c61a948b0b00a6'; // API token declaration
     use ButterCMS\ButterCMS;

     try{
       $client = new ButterCMS($apiToken);
       $page = "1";
       $result = $client->fetchPosts([
        'page' => $page,
        'page_size' => 10
       ]);

       // Get the first post 
       $posts = $result->getPosts();
       $post = $posts[0]; 

       echo $post->getTitle(); //gets the Title of the blog 
       echo $post->getBody(); // gets the body of the blog 
     } 

    // similarly you can pull more attributes of the blog like the author, publishing date, etc.

    // You don't need to use try-catch functions, we used it to get the errors if there are any.
     catch(Exception $e){
      echo "Error";
      echo $e;
     }
    ?>

<span style="font-weight: 400;">Visit Application Management > Access Details and click the application URL. In my case, the URL is</span> [<span style="font-weight: 400;">http://phpstack-447249-1400865.cloudwaysapps.com/home.php</span>](http://phpstack-447249-1400865.cloudwaysapps.com/home.php)<span style="font-weight: 400;"> </span>

![undefined](https://cdn.buttercms.com/EPzZhW9uS46cr52ueZoX)  

<span style="font-weight: 400;">If you need to pull a specific page or all the posts and pages created by ButterCMS, visit the</span> [<span style="font-weight: 400;">GitHub</span>](https://github.com/buttercms/buttercms-php) <span style="font-weight: 400;">repo for more details.</span>

# <span>[Discover how ButterCMS works with your php app](https://buttercms.com/php-cms/)</span>

# <span style="font-weight: 400;">Conclusion</span>

<span style="font-weight: 400;">ButterCMS makes it easy to post and publish blogs, testimonials, and landing pages without putting a hefty load on the server. This is what makes headless ButterCMS stand out from the conventional CMS options.</span>

<span style="font-weight: 400;">Deploying a blog powered by ButterCMS takes less than five minutes of your time and helps you get started quickly. With the state-of-the-art hosting features and amazing page load time, Cloudways is the obvious choice for ButterCMS projects. </span>

<span style="font-weight: 400;">I hope this guide proved helpful. If you have any questions, reach out to us through Live Chat or Email. </span>

<span style="font-weight: 400;">In case you need to learn and explore more about ButterCMS, visit the official</span> [<span style="font-weight: 400;">knowledge base</span>](https://buttercms.com/kb/)<span style="font-weight: 400;">.</span>

<span style="font-weight: 400;"></span>


</div>

</form>

</div>

</div>

</div>

</div>