First congratulations for the release of Ghost 0.4.2 this week!
As the title indicates, this post was not about what to install Ghost on OpenShift, it's about what to upgrade it.
Installing Ghost on OpenShift was quite easy with the QuickStart script while upgrading it was not so straight forward. It really took me some time to figure out how to upgrade it in the OpenShift.
Yes, the OpenShift, the best practice to upgrade Ghost on OpenShift, and which is the git.
The Git
OpenShift utilize git for source code management. Upgrading Ghost means updating its source code.
To upgrade Ghost in the OpenShift-the-need to the source code from OpenShift Server, update it with the latest G Host source, then push it back to OpenShift server. If you were familiar with Git, you may already know how to do it properly. If you ' re not, here is the details.
You could want to get yourself familiar with git by reading this simple guide first.
Step 1:pull The source code from OpenShift server to local machine
For Linux users, simply type the following command to checkout the repository.
ssh://your-openshift-repo-url
You can get the URL for the repository from the OpenShift application console.
If you already has the repository cloned, you can run to git pull
update your local tree.
Step 2:update The working directory with the latest Ghost source
Download the latest version of Ghost, extract the files directly to the directory of the Your local tree. By doing this, all existing files would be is up to date and all new files would be added. For Linux users, simply type the following command.
path-to-your-git-repo
Step 3:edit Package.json
We need to change the line
"main": "./core/index"
To
"main": "index.js"
In Package.json.
This step was a must, otherwise it won ' t work on OpenShift.
Step 4:stage All Changes
Run the following command to do all changes staged.
git add .
If you is not a confident, you can run to git add -i
review all changes.
Step 5:commit The changes
After all these changes we ' ve made, we must commits them to the head tree by the following command.
git commit -m ‘upgrade to ghost 0.4.2‘
Step 6:push it back to OpenShift
Here comes the final step, just run
git push
Upon running this command, OpenShift'll take care of everything else and redeploy the application. After the command finishes, your new Ghost is ready to go.
Conclusion
Although OpenShift provides SSH access by which your can make changes directly on remote server, git should always be your First consideration.
Whenever want to make changes for your application, it's better to work on your local tree and then push back to Open Shift. That's the work flow suggested by OpenShift.
For example if want to install a new theme for Ghost, extract the theme files to the proper directory in your local TR EE, then do a git add, git commit and git push. That's the best practice.
How to UPGRADE GHOST on OPENSHIFT