Step by Step AWS EC2 Tutorial
This has been roughly adapted from this ServerFault question for the case when it gets removed/deleted/closed.
The question was about how to configure a Flash game server on Linux, but on EC2. I had a good look around, but didn't find any true step-by-step EC2 tutorials for proper beginners. So I made one. This one is fairly specific to SmartFox Server towards the end, but the first few bits about creating an instance, and adding stuff to the security group should be generic enough to be useful.
I have made a ActionScript 3.0 Flash game and implemented multiplayer functionality using SmartFoxServer. Now I want to put this game on my website which is hosted on 000webhost.
My game works absolutely fine on localhost. But I need to put my smartfox instance somewhere where it is publicly available. This is where I need you peoples help.
There is an article explaining what needs to be done - http://docs2x.smartfoxserver.com/GettingStarted/installation
I do not understand, do I have to put my game and my smartfox instance on a remote server, vps, dedicated server or what?
Right. You'll need to get a VPS, or at least an Amazon EC2 cloud instance to run this on. I'm 99.99% certain that you can't use the free package at 000webhost to do this. They're a pure webhost, and you need somewhere you can configure and install Java, and the SmartFox server.
So.. Go to aws.amazon.com and sign up for a free account.
You'll need to provide them with a credit/debit card number, but they won't charge you as long as you keep within the free tier resource limits.
Once you've got an account, go here and start an EC2 instance.
This all assumes you know a bit about linux, but if you create your first instance using Ubuntu Linux 12.04 64-bit server, it'll make everything a bit easier!
When you click to create an instance you get this chooser:
Select "Classic Wizard" and this AMI to boot.
Select the for this instance..
And the defaults on the next page too.
Select the default storage options.
And then name it.
You now need to create a SSH key, and name that too. When you click "Download Keypair" your browser will save the private key. Keep this safe, because if you lose it, you've effectively lost the master key to your new server.
Now we need to create a security group. This is the firewall of Amazon EC2.
Add inbound rules for SSH, HTTP and HTTPS. This'll be enough for now.
Review the selections you've made.
Hurrah! It should now be booting..
Time to get into it. This is the control panel.
Select your new server instance, and right click it and you get this menu.
Then click Connect.
To access your instance: Open an SSH client. Locate your private key file (SmartFox.pem). The wizard automatically detects the key you used to launch the instance. Your key file must not be publicly viewable for SSH to work. Use this command if needed: chmod 400 SmartFox.pem Connect to your instance using its Public DNS. [ec2-xx-xx-xx-xx.compute-1.amazonaws.com]. Example Enter the following command line: ssh -i SmartFox.pem firstname.lastname@example.org
Which is nearly right, except as it's an Ubuntu instance, you want to
ssh -i SmartFox.pem email@example.com
So, let's do that.
And we're in.
Gonna need the SmartFox installer next..
Download with wget, then tar xzvf and extract it.
So, you can go ahead and start the damn thing now.
ubuntu@ip-10-243-117-245:~/SmartFoxServer2X/SFS2X$ ./sfs2x-service start
Interestingly enough, it looks like SmartFox needs port 8080 opening up on the AWS Security Group firewall.
ubuntu@ip-10-243-117-245:~/SmartFoxServer2X/SFS2X$ sudo netstat -anp |grep java tcp6 0 0 127.0.0.1:9933 :::* LISTEN 9142/java tcp6 0 0 :::8080 :::* LISTEN 9142/java udp6 0 0 127.0.0.1:9933 :::* 9142/java
Luckily, that's really easy.
On the sidebar of the control panel, there's a Security Groups link.
Edit it, add a custom TCP rule and allow port 8080 to 0.0.0.0/0
Add the rule, and **apply the changes**.
You should now be able to reach your SmartFox game server on the DNS name given to you by Amazon EC2 in the control panel. It's the same bit you SSH'd to earlier.
That's all folks!
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)