Website Development Services

Webdot

WordPress on Heroku | A Brief Beginner’s Guide

WordPress on Heroku

Deploying a WordPress application on Heroku is typically a smart choice. Heroku’s setup is simple, and the platform offers reliability, security, and scalability. However, to deploy a WordPress application on Heroku, you’ll need to understand a few basics.

Don’t worry! We’ll get you up and running with the very basics in this blog.

WordPress on Heroku

What is WordPress

WordPress immediately comes to mind as a popular blogging platform. It was launched as a blogging platform, but it quickly evolved into a content management system (CMS) and, eventually, a packed website creation platform.

It’s open-source software that anybody can use to construct every type of website they prefer. WordPress offers a large feature set that serves every available case. In addition, it has a robust plugin architecture and a template system.

What is Heroku

Heroku, on the other hand, is a package-based cloud platform with a lot of features. It is a platform for modernized web & app deployment, management, and scaling. This supports a wide range of programming languages, including PHP, Java, Python, Ruby, and others.

Developers use this platform to create optimized APIs easily, operate databases, IoT, networking, and administer management. Heroku is very flexible and provides the quickest route to market for app and web developers.

WordPress on Heroku | The Ultimate Beginners’ Guide

You can easily deploy your web application on Heroku by following some steps. You can find the steps here https://www.appcloud101.com/archives/5102 and make it available on the internet after building a web application or site on WordPress. You’ll receive a link in the format of yourapp.herokuapp.com from Heroku.

You have to learn about some fundamental issues and basic tools for deploying a WordPress application on Heroku. So let’s dive deeper to know the basic resources and frequently faced problems of users.

WordPress on Heroku

Github Repository

Heroku deploys any application through Github. So, you have to create a git repository.

When you’ve finished downloading WordPress, unzip the file into your Git repository. The action after this would be, set up everything and accept the terms. Whenever you push a change to Github, it will also push it to Heroku.

Heroku Setup

Next, you’ve to visit https://www.heroku.com/ to join the Heroku platform.

After you’ve signed up, go to your dashboard and create a new application and give the application a suitable name. Select GitHub as your deployment source as you have created a git repository.

Follow http://www.appcloud101.com/archives/4112 to the Heroku cheat sheet which contains all necessary Heroku commands.

MySQL

Find the ClearDB MySQL addon in the Data Storage area and click it. When you’ve arrived at that addon’s site, press Install ClearDB MySQL. Then you have to input the name of your application so that you can install the application.

MySQL is free and open-source software. It’s a SQL (Structured Query Language)-based relational database management system. This software has an integrated workflow management system and high performance, exactly what WordPress needs.

WordPress doesn’t operate without a MySQL database. In WordPress, a database contains all of the pages, data, and other staff. So, it’s dependent on the database. MySQL is the best option here because it’s flexible with PHP, Linux, and Apache servers.

Here are the steps for creating a MySQL database for WordPress:https://www.wpwhitesecurity.com/creating-mysql-wordpress-database/

ClearDB

For add-ons, ClearDB is the best option here. ClearDB is a cloud-based, high-performance database-as-a-service for MySQL-based applications. So, it is an ideal choice for speeding up the application.

Here is complete guidance for connecting to ClearDB from Heroku using python https://w2.cleardb.net/developers/resources/connect-python/#1.2

Go to Heroku’s Resources page and select ClearDB – MySQL. This should take you to the ClearDB page for your database. However, this is only possible if the database is installed.

In the Community Edition tab, you can see your database. After selecting the database, go to the system information tab to get the login information (username & password).

With their 5MB Ignite plan, Heroku users can use ClearDB on Heroku for free.

MySQL Workbench

Install MySQL Workbench and access your local database. MySQL Workbench uses several GUI graphical user interfaces.

Select the Local instance and get access to the entire local database.

MySQL Workbench will provide you with server configuration tools, SQL development, backup, and many other features which will be helpful for your WordPress application. You can use MySQL Workbench on Linux, Windows, and macOS X. So, it’s flexible with all operating systems.

Cloudflare Account

Having a Cloudflare account is an advantage in this case. Your website is safer, faster, and more available thanks to CloudFlare’s network. In addition, Cloudflare provides a free SSL certificate. This will ensure your website visitors will have an encrypted connection.

Cloudflare is a global network. Cloudflare aims to make everything you do online safe, trustable, and private. Create a Cloudflare account if you don’t already have one. Cloudflare will give you information on how to update your nameservers. In addition, it will keep your web apps, and APIs secured.

Have a look at Cloudflare setup: https://www.wilselby.com/2016/09/wordpress-heroku-website-integration-cloudflare/

Heroku Config

Config vars on Heroku are meant to be secure for storing confidential data. All configuration variables are encrypted and kept safely. Your app is restarted, and a new edition is built whenever you set or delete a config var using any approach.

You can configure the vars of your app by using the commands of Heroku CLI.

This will guide you to the complete process of configuration and config vars on Heroku: https://devcenter.heroku.com/articles/config-vars

Inserting Images 

We rewrite our uploads folder every time we make edits to our WordPress files and push our code. As a result, images previously posted within the WordPress dashboard can be changed by modifying the codes.

To avoid any difficulties in uploading images, install  WP Offload Media Lite and register an  AWS account.

WordPress Version

We may require multiple versions of WordPress to address various concerns. Sometimes you’ll need the most recent version of WordPress, but other times you’ll need the older version to function with the plugins or addons you’re using.

You have to upgrade or downgrade your WordPress version to your needs.

Upgrading

You can update WordPress from Composer.json. Otherwise, you can run brew install composer from the terminal. In johnpbloch/WordPress, change the version number to the most recent WordPress version number. Use the terminal to execute the composer update. Remember to push your updates.

You’ll find the necessary steps here: https://www.hostinger.com/tutorials/how-to-update-wordpress

Downgrading

If you find that the most recent version of WordPress you’re running is not compatible with the Heroku configuration. Then you have to go back to a previous version of WordPress. You can downgrade the WordPress version viaComposer.json

You can follow https://increasily.com/how-to-downgrade-wordpress/

Auto Updates

  To keep the plugins and themes, auto-updated follow:

  1. Select WordPress tools
  2. Select Automatic Updates
  3. Click
  • Update WordPress
  • Update Themes
  • Update Plugins

URL Issues

In WordPress, your application URL uses “http.” But in Heroku, you will find “https” instead of “http’ in your application URL. Find this URL by:

  • Heroku Dashboard
  • Settings
  • Domains & Certificate Section

You have to change the “https” to “http.”

Plugins & Themes

From your WordPress dashboard, you can find options for themes and plugins. You can see plugins & Theme folders. Choose plugins and themes here. Remember to update the code according to the changes. Push the updated code into GitHub.

New themes and plugins are always available on WordPress Packagist at WordPress.org.

Check https://www.wilselby.com/2016/09/wordpress-heroku-updating-website-content-themes-plugins/ for the manual updating process of themes and plugins.

Sleeping Problem

If you are using Heroku’s free plan, your application will face a problem called sleeping. If your app remains inactive for 30 minutes, it will go to sleep mode. As a result, the next visitor will have to wait extra time to visit your application which is quite disturbing.

Now every app has a status symbol to show its current status. So, if the app sleeps, it can be quickly awakened.

  • Awake and will never go to sleep
  • Awake, but will go to sleep after 1 hour of inactivity
  • Asleep
  • Not running because it has been scaled down or has no code. You have to select the first option.

To prevent this problem, create an account on Cron-job.org, which is free. You can set the schedule here.

Wrapping Up

Deploying a WordPress application on Heroku is an excellent option if you take care of a few concerns. Pay proper attention to the given guidelines and issues explained in this article, and you are good to go.

I hope this blog helped you with the basics of WordPress application deployment on Heroku.