How to host your game online FOR FREE!!

Hi there,


Today I'm going to be showing you how you can get your rpg maker mv game hosted online without losing any of that hard earned gold!


Before we start, there are some things you are going to need.

  1. Git. This is a tool we will use from the command line, to perform updates to the files we are storing online. You can download git from HERE.
    Once downloaded, simply run the exe and it will setup git on your system for you.
  2. An account at openshift. Openshift is a 'Platform-as-a-Service' (PaaS) that allows developers to quickly develop, host, and scale applications in a cloud environment. Their site is HERE.
    You can build many kinds of application on openshift, but today we will be focusing on node.js and express - a framework for building web applications using javascript.
  3. My barebones-express-ejs repository. Found HERE, direct download HERE. (I recommend direct download of the zip file for this tutorial
  4. A game to upload.
  5. [optional] node, which has npm, installed onto your system. This will allow you to run your game server locally for testing, but this isnt vital for this tutorial. You can get node from HERE if your interested.



Once you have git installed, your account confirmed, and the barebones repository we can start.


First we will head over to the openshift website, to their 'dev console' page (link). At the bottom of the page, there is a link to create a new (your first) application, click that.
image.png



We are then presented with a huge list of possible application types. Scroll down this list to find node.js and click it.


image.png



You will now be asked to configure some settings for your application, the only thing we need to alter is the public url. This will be the url we use to access the game from a web browser.


image.png



Once you have chosen an awesome url, scroll down the page and click 'create application'.


image.png



This usually takes a minute or two, so don't panic when the little loading spinner keeps on spinning around. 😀


After your application has been created, we need to download the git repository of our application to our local computer - so we can make changes, and then upload our new copy. To do this, go into the folder that you wish to store your application files, and open a command window. (you can do this on windows by holding shift and right clicking in the folder window, then selecting 'open command window here' - or similar)


When you have your command window opened, go back to the openshift website which should currently be displaying the 'next steps' page of the new application creation process. On this page we are given the link to the git repository we need to clone, it looks something like this:


image.png



Copy this piece of text, and in your command window right click your mouse to paste it in (ctrl+v doesnt paste in command window) and hit enter. (dont copy the line 'cd yourgamename/'). You should be asked if you wish to continue with cloning this repository, simply type 'yes' and hit enter again. Some text will start spamming informing you of the cloning progress and should only take a second to complete. After the files have been cloned into your computer, you can use the command 'cd yourgamename' to enter into the folder you just created (will be called 'yourgamename' by default).


Your command window should now look something like this:


image.png



Assuming everything has gone smoothly so far, we are ready to upload our game. To do this, we must modify the contents of the files we just downloaded, and then upload our new files to the git repository for our application (you know, the one we just cloned).


The modification of the files if VERY EASY. Simply go into the folder that application files are in, mines is called 'mycoolgame', and select everything except the '.openshift' folder, and then, hit delete.


image.png



Now, remember the repository we downloaded earlier? The barebones-express-ejs one? Find that zip file and extract all contents into the the folder we just deleted everything from so that it looks like this:


image.png



Once thats done we need to add our game files, so open up the 'source' folder. Within the source folder there are two other folders, 'client' and 'server'. We will venture into the client folder first.


image.png



These three folders within the client folder, are about to be replaced with our game files. First highlight and delete the images, javascripts, and stylesheets folders. Then, open up your game project folder, and highlight all folders within it and copy them in place of the folders we just deleted. Your client folder should now look something like this:


image.png



Next we will leave the client folder, and enter the server folder. Within the server folder, there is two files (config.js and main.js) and a views folder, which is what we want, so enter the views folder.


Inside the views folder, the is a single file - index.ejs. All that's left for us to do, is replace the contents of index.ejs with our games index.html file. Again, this is very easy. Just enter your game project folder and locate the index.html file. Open the file up in any text editor and select all contents and copy. Now enter the views folder, open the index.ejs file in a text editor, select all contents, delete, paste your index.html file contents in, and hit save.


Thats us, we have changed all files that are required, and our game is now ready to be uploaded.


At this point, if you installed node on your system you can run the following command from the command line to run your applications server locally.


npm install & npm start


This will allow you to go to the web address http://127.0.0.1:8080 and view your game in action.


If you have no interest in that (which there is really no need), enter the following three commands one after another into the command window:


git add .
git commit -m "changes"
git push




You should then see a stream of information about the uploading of your new files, and eventually - assuming everything went correctly - your application server will reboot. When this happens, its done. You have successfully got your game hosted online for free. Now all that's left to do is view your game.


To view your game, use the public url that you chose when first creating your application on the openshift website. It will be something like


http :// mycoolgame - userdomain.rhcloud.com/


And thats all there is to it. 🙂


There is likely other ways to obtain free online hosting, and probably easier ways, but this way works and doesn't cost anything!!


If this tutorial was useful to you in any way, feel free to leave a like or comment or such 😀

Edit:
Here is a simple working example of a game hosted this way:


http://mycoolgame-dekita.rhcloud.com/
Your command window should now look something like this:


image.png



Up until this step it says: 

Code:
Warning: Permanently added 'projectloc-cekobico.rhcloud.com,52.2.71.95' (RSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

...I'm quite unsure how to add public key


EDIT: Now I know xD


Ok, so currently uploading. Really slow,on 20.00 KiB/s, I guess that's free server for you lol


Later down the road, how do I update, say 1-2 files only, instead of pushing all contents all over again?
Yay! It worked! Had some trouble with setting up my SSH last night, but it all went smooth as smooth this morning. 😀 Thanks so much!
EDIT: Now I know xD


Ok, so currently uploading. Really slow,on 20.00 KiB/s, I guess that's free server for you lol


Later down the road, how do I update, say 1-2 files only, instead of pushing all contents all over again?



So I assume you got your key working then?  I forgot all about that step cause mines was already done from previous, ill have to go over that for others who need the help. 🙂


When you do a git add+commit+push git checks for files that have changed, or had their names changed, or moved, or such. Then it uploads only the new files. So the initial game upload would take a while, but subsequent 'patches' that you upload should be significantly faster. 😀


@wintyrbarnes Happy to hear you got it all working. 🙂
 
When I try to access my game, linked here, it says failed to upload Iconset. Pretty sure I had everything included....how do I check what files are inside the server and what files aren't? 
Everything within the 'client' folder is publicly available on your server. So you should have a path like this:


done1.png



Even if your game doesn't use the iconset, it is loaded at bootup, so its a required file and must be there - or the mv code must be edited to allow for it to not be there. 🙂


Just in case anyone is curious, here is a working game (its just a blank project i uploaded for example purposes)


http://mycoolgame-dekita.rhcloud.com/
Updating is a piece of cake, for anyone who was wondering--I had to fix a map last night and the whole thing took about 3 seconds once I was in the command prompt. 
Openshift still think I don't have Iconset.png in my server, no matter how many times I pushed that online :s 
openshift, and git, don't discriminate between files except for very special circumstances. 😀


I checked some files on your server, which do seem to be there - for example:
http://projectloc-cekobico.rhcloud.com/img/system/Balloon.png
http://projectloc-cekobico.rhcloud.com/img/system/Damage.png


http://projectloc-cekobico.rhcloud.com/img/system/Window.png


so you certainly do have the main files on your server in the correct folder.


What I would suggest - if the iconset is 100% confirmed to be in the client/img/system/ folder, delete it. Then... Reupload your project using the three commands:


git add .
git commit -m "iconset fixes"
git push


This will upload the altered files to your server - which doesn't include the iconset, so if any file is in the server repository it will be removed. Then, add the iconset to the system folder again (add it from your main game project) and then use the same three commands to upload your changes.


This will basically perform a delete and replace on the server.

Additionally, we can get a listing of all files within your img folder on the server (or any folder).. If you alter the file 'package.json' in the main folder to include a new line of text:


"dependencies": {
"ejs": "~2.4.2",
"express": "~4.14.0",
"serve-index": "^1.8.0"
},


the line "serve-index": "^1.8.0" is new, and a comma has been added after the express line (the comma is required).


Then, we go into the file 'main.js' and add this code:


/**
* Require serve index to view folders
*/
var serveIndex = require('serve-index');

/**
* Set handler for /img path of server:
* here we 'use' the serve index module to show
* directory listing of files in the folder we specify.
*/
app.use('/img', serveIndex(__dirname + '/../client/img'));


I added that code in between the '/' path handler and the '/helloworld' handler.


Then, you will be able to go you yourwebsite.com/img and it will show a listing of all files in the specified folder. like this:


http://mycoolgame-dekita.rhcloud.com/img/system/


Let me know how you get on 🙂
Did your method for the iconset fix, didn't work.


Thought something was wrong with my App, so I deleted it and created a new one. 


Same problem arises. It won't read my iconset.


I stared at the error for too long in desperation...


and then it crosses me. 


I named my iconset file as "Iconset.png" instead of "IconSet.png"


Damn. 


Now I can get it to get past checking for IconSet with no problems, except now it starting to detect images with wrong caps (currently, "command_homePage.png" lol, originally named with small p). Now on to checking one by one of my files with wrong naming...
That actually makes sense. im sure openshift uses a linux architecture for hosting, which is stricter when looking over filename's. (ie - windows doesnt care if you use caps or lowercase, linux does). 😀


I'm happy that you have managed to figure out what the issue was though. 🙂
Ah I see. 


Well, that took a while for me to realize it xD 


Btw, just for safety and security measure, is it possible for me to set my app to disallow accessing my files using direct links like you did here:

Unfortunately not, cause then the game client cant access them.


It could be possible however to add a required parameter to the files... Gimme a little bit, im quite busy today but I'll see what I can do. 🙂


Ehh yea, too many files within mv would need altered to accommodate such a thing i think. Its well known that mv has no protection when uploading your games online, all online games are vulnerable to such things, the difference with mv is that your file structure is known - unless you change how all files are handled in your game.
Ah I see, I thought this is something possible within the framework. 


Anyway, problem solved, got my games up and running. 


Thanks for the tutorial!
No problem. 🙂
First of all, thank you for sharing this! and second, I'm not a techy person... unfortunately...


Anyways, I got lost at this part...


Capture.PNG



What exactly will I do? Which will I click next? Please help?


Capture1.PNG


Do you have a Youtube Tutorial for this? Again, thanks for sharing this.
First of all, thank you for sharing this! and second, I'm not a techy person... unfortunately...


Anyways, I got lost at this part...


View attachment 42194



What exactly will I do? Which will I click next? Please help?


View attachment 42195


Do you have a Youtube Tutorial for this? Again, thanks for sharing this.

Same! I got lost at that part too because by default Openshift didn't generate a public SSH key automatically. 


This is the documentation on how to do it. To be honest, I kinda forgot how I did it. Pretty sure you have to install the RHC Client tools first.
IIRC, I went to "Not now, continue" at that point. Then I went ahead and downloaded and installed Git, Ruby (for Windows), RubyGems, the RHC Client, and Cygwin.


I got the client from RubyGems (at this point I set it up from my normal CLI but you could also do it from Git or Cygwin, I believe).


I switched over to Cygwin for the last part of the RHC setup, when it asks you to change the permissions on the public key they've generated; "chmod" is not a Windows command. After that, you can keep using Cygwin or go back to your other interface of choice.


Once they've got your public key and the part on your computer registers it as a protected file (which is what the "chmod 600 C:\Users\[YourUserName\.ssh\ssh\id_rsa" command does), all you need to do is download what's on there, replace it with Dekita's barebones file, set up your game folders, and upload it.


It's a bit convoluted but very, very easy once you run "rhc setup." And it might seem excessive to install all of those programs, but they'll more than likely come in handy if you intend to continue developing for web, at least. They give you a bit more flexibility, too. 


Once it's up, though, updating is just a matter of changing the content in the folders where you have your Client files and running the last few Git commands to put it online.
Oh my! This is actually pretty neat!!


I'll try this out right now na na na~!  😀
IIRC, I went to "Not now, continue" at that point. Then I went ahead and downloaded and installed Git, Ruby (for Windows), RubyGems, the RHC Client, and Cygwin.



Thanks for the links! I didn't use Cygwin as I didn't know how to use it, but I was able to setup the folders and everything by following this video tutorial:
 














But Now, I'm stuck at this part:

 

If you have no interest in that (which there is really no need), enter the following three commands one after another into the command window:



git add .
git commit -m "changes"
git push




You should then see a stream of information about the uploading of your new files, and eventually - assuming everything went correctly - your application server will reboot. When this happens, its done. You have successfully got your game hosted online for free. Now all that's left to do is view your game.



Where do I type this? The command window? or a specific Git command window? I tried it but it ended up like this:

Capture.PNG

 


If this is 'common sense' to others, sorry, I'm pretty idiotic when it comes to these kind of things. It's my first time messing with command windows. And for some reason, I didn't even touch the Git command window at all... but I was still able to do this:


Capture.PNG

So... Oddly enough, I guess I'm doing it right?

I have no idea, LMFAO!~ 😀

Original thread: https://forums.rpgmakerweb.com/threads/how-to-host-your-game-online-for-free.64501/