Heroku Free PHP Hosting-512MB Ram,custom domains and WordPress on Heroku

Heroku is a cloud platform as a service(PAAS),and has been around since 2007.It is popular due to its support for variety of languages, including Ruby, Python, Java, Node.js, Scala and PHP. Heroku supports an ephemeral filesystem. This means that installing plugins or addons should be done and tested locally.

In this tutorial we will be hosting a WordPress blog on Heroku. It will require the same procedure as involved in setting up PHP application.Heroku will provide you with a URL of the form yourapp.herokuapp.com. You can bring your own domain name and attach it to this URL.

Heroku Free PHP Hosting-512MB Ram,custom domains and WordPress on Heroku

For more Free PHP Hosting,you will like:

  1. Openshift Free PHP, MySQLand phpMyAdmin Hosting-512MB RAM and 1GB disk
  2. SourceForge.net project web service-Free Web Hosting with PHP, MySQL,SFTP

How to Deploy WordPress on Heroku With Heroku-WordPress template

Sign up for a free Heroku account. Go to Website:https://www.heroku.com/,and sign up for free.

Heroku sign account

In the Dashboard,Click ’new’to create a new app.

Heroku Create app

Then Set App Name ,Runtime Selection (Your app can run in your choice of region in the Common Runtime).

Heroku app name

In Personal apps ,You can set Overview ,Resources ,Deploy ,Metrics ,Activity ,Access ,Settings .

Heroku App Dashboard

There are three Deployment methods to Deploy app on Heroku:Heroku Git (Use Heroku Toolbelt),GitHub (Connect to GitHub),Dropbox (Connect to Dropbox).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Deploy using Heroku Git 
Install the Heroku Toolbelt.Download and install the Heroku Toolbelt or learn more about the Heroku Command Line Interface. 
If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.
 
$ heroku login
 
Create a new Git repository
Initialize a git repository in a new or existing directory
 
$ cd my-project/
$ git init
$ heroku git:remote -a howsvps
 
Deploy your application
Commit your code to the repository and deploy it to Heroku using Git.
 
$ git add .
$ git commit -am "make it better"
$ git push heroku master
--------------------------------------------------------------------------------
 
Existing Git repository
For existing repositories, simply add the heroku remote
 
$ heroku git:remote -a howsvps

In Setting,You can change App’s Name,Config Variables .

Heroku config Variables

You could see app Info:Region \Stack \Framework \Git URL \Repo size \Slug size .

heroku app info

Deploy WordPress Build Pack With Heroku-WordPress template

  • 1. https://heroku.com/deploy?template=https://github.com/technomile/Heroku-WordPress
  • 2. https://heroku.com/deploy?template=https://github.com/ellefsen/wordpress-heroku-php/tree/master

Go to Heroku-WordPress and set app name.

heroku WordPress template

Config Variables ,You should set up AWS account.Keys marked with * require a value.

heroku config aws

Deploy WordPress on heroku successfully .

heroku deplay successfully

You should now be able to finish WordPress setup .

Heroku-WordPress Setup

Heroku-WordPress template Add-ons include:ClearDB MySQL(Ignite,Free ),SendGrid(Starter,Free ),MemCachier(Developer,Free ),Papertrail(Choklad,Free ),New Relic APM(Wayne,Free).

Heroku-WordPress template Add-ons

WordPress on Heroku.

Wordpress on Heroku

How to Deploy WordPress on Heroku With Heroku toolbelt

In this tutorial, I’ll be deploying WordPress, that we’ll deploy on Heroku using the toolbelt.

How to Deploy WordPress on Heroku With Heroku toolbelt

Set up Heroku Toolbelt.,PHP,Composer,Git

Before you continue, check that you have the prerequisites installed properly.Firstly you should install the Heroku Toolbelt,which provides you access to the Heroku Command Line Interface (CLI).

Set up Heroku Toolbelt.,PHP,Composer,Git

Heroku Toolbelt support for Mac OS X,windows,debian.On Windows, start the Command Prompt (cmd.exe) or Powershell to access the command shell.Using :heroku login to Connect to Heroku account.

1
2
3
4
5
heroku login
Enter your Heroku credentials.
Email: dz@example.com
Password:
...

Then type each command below and make sure it displays the version you have installed(How to LNMP:How to use OneinStack to deploy LEMP/LNMP/LAMP on VPS).

1
2
3
4
5
6
7
8
9
10
11
12
13
#php 
php -v
PHP 7.0.5 (cli) (built: Apr 26 2016 04:39:48) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
 
#composer
composer -V
Composer version 1.1-dev (135783299af0281db918c103cceb2b202ae154f2) 2016-07-27 13:14:01
 
#git 
git --version
git version 2.2.1

Deploy WordPress on Heroku Guide,Run the following from the terminal:

1
2
3
4
5
git clone git@github.com:bkvirendra/wordpress-heroku.git #Clone the repository as `wordpress-heroku`
cd wordpress-heroku
heroku create
heroku addons:add heroku-postgresql:dev  #add the database add-on to your app
heroku pg:promote HEROKU_POSTGRESQL_COLOR_NAME --app APP_NAME #promote the database attached to the app

Now edit the `wp-config.php` file and update the unique keys:

1
2
3
4
5
6
7
8
define('AUTH_KEY',        		 'put your unique phrase here');
define('SECURE_AUTH_KEY',  	'put your unique phrase here');
define('LOGGED_IN_KEY',    		'put your unique phrase here');
define('NONCE_KEY',        		'put your unique phrase here');
define('AUTH_SALT',        		'put your unique phrase here');
define('SECURE_AUTH_SALT', 	'put your unique phrase here');
define('LOGGED_IN_SALT',   	'put your unique phrase here');
define('NONCE_SALT',       		'put your unique phrase here');

Commit the files:

1
2
3
git add .
git commit -m “first wordpress commit”
git push heroku master

Conclusion

Images and files on Heroku are temporarily and deleted when your dyno is restarted.As a workaround you can subscribe to AWS storage and write a bit of code which saves media on AWS instead of Heroku when you upload the file.

Images and files on Heroku are temporarily

For instance, when you upload images or install plugins it will store them in the wp-content folder, but heroku is read only, so your data will be deleted every time the server reboots.

Setup AWS – S3 to store images on heroku.

Log In from AWS services dashboard select Identity & Access Management to create a user.Click on Users then click on Create New User in input type nameofapp click create to generate special keys and save the keys keep in safe place.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 {
    "Version": "2016-07-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::BUCKETNAME",
                "arn:aws:s3:::BUCKETNAME/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": "s3:ListAllMyBuckets",
            "Resource": "arn:aws:s3:::*"
        }
      ]
   }

Going to the app/settings config vars click edit and name and insert keys. example use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY this will be called from your wp-config.php file in your app so the variables should be named the same.

Setup Sendgrid to send emails from wordpress on heroku.

Your sengrid username password in app/settings config vars.Simply copy those sendgrid vars and navigate to Sendgrid in wordpress dashboard and paste them in the username password inputs there and save.

 
<

0 Comments

Leave a Comment

Login

Welcome! Login in to your account

Remember me Lost your password?

Lost Password