Joe*_*ter 2 hosting vps virtual-machines gameserver
我制作了一个 ActionScript 3.0 Flash 游戏并使用 SmartFoxServer 实现了多人游戏功能。现在我想把这个游戏放在我的网站上,这个网站托管在 000webhost 上。
我的游戏在本地主机上运行得非常好。但是我需要将我的 smartfox 实例放在公开可用的地方。这是我需要你们帮助的地方。
有一篇文章解释了需要做什么 - http://docs2x.smartfoxserver.com/GettingStarted/installation
我不明白,我是否必须将我的游戏和 smartfox 实例放在远程服务器、vps、专用服务器或什么上?
Tom*_*nor 12
对。你需要一个 VPS,或者至少一个 Amazon EC2 云实例来运行它。我 99.99% 肯定你不能使用 000webhost 的免费包来做到这一点。他们是一个纯粹的虚拟主机,你需要一个可以配置和安装 Java 和 SmartFox 服务器的地方。
所以.. 访问aws.amazon.com并注册一个免费帐户。
您需要向他们提供信用卡/借记卡号码,但只要您保持在免费层资源限制内,他们就不会向您收费。
获得帐户后,请转到此处并启动 EC2 实例。如果您进行一些谷歌搜索,互联网上有大量 AWS 101 教程。
这一切都假设您对 linux 有所了解,但是如果您使用 Ubuntu Linux 12.04 64 位服务器创建您的第一个实例,它将使一切变得更容易!
当您单击以创建实例时,您将获得以下选择器:
选择“经典向导”并 AMI 启动。
选择 对于这个例子..
而 也。
选择默认存储选项
然后命名。
您现在需要创建一个 SSH 密钥,并为其命名。当您单击“下载密钥对”时,您的浏览器将保存私钥。请妥善保管,因为如果丢失它,您实际上已经丢失了新服务器的主密钥。
现在我们需要创建一个安全组。这是 Amazon EC2 的防火墙。
为 SSH、HTTP 和 HTTPS 添加入站规则。这已经足够了。
查看您所做的选择。
欢呼!现在应该可以启动了。。
是时候进入它了。这是控制面板。
选择您的新服务器实例,然后右键单击它,您将获得此菜单。
然后点击连接。
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 root@ec2-xx-xx-xx-xx.compute-1.amazonaws.com
Run Code Online (Sandbox Code Playgroud)
这几乎是正确的,除了它是一个 Ubuntu 实例,你想要
ssh -i SmartFox.pem ubuntu@ec2-xx-xx-xx-xx.compute-1.amazonaws.com
Run Code Online (Sandbox Code Playgroud)
所以,让我们这样做。
ubuntu@ip-10-243-117-245:~$
Run Code Online (Sandbox Code Playgroud)
我们在。魔术!
接下来需要SmartFox 安装程序..
用 wget 下载,然后 tar xzvf 并解压。
cd ~
wget http://www.smartfoxserver.com/downloads/sfs2x/SFS2X_unix_2_0_1_64.tar.gz
tar xzvf SFS2X_unix_2_0_1_64.tar.gz
ls -lah
total 98544
drwxr-xr-x 4 tom staff 136B 19 Feb 22:51 .
drwxr-xr-x 79 tom staff 2.6K 19 Feb 22:41 ..
-rw-r--r-- 1 tom staff 48M 21 May 2012 SFS2X_unix_2_0_1_64.tar.gz
drwxr-xr-x 9 tom staff 306B 13 Feb 2012 SmartFoxServer2X
? SmartFoxServer2X ls -lah
total 160
drwxr-xr-x 9 tom staff 306B 13 Feb 2012 .
drwxr-xr-x 4 tom staff 136B 19 Feb 22:51 ..
drwxr-xr-x 15 tom staff 510B 13 Feb 2012 .install4j
drwxr-xr-x 6 tom staff 204B 13 Feb 2012 Client
-rwxr-xr-x 1 tom staff 71K 13 Feb 2012 LicenseAgreement.pdf
-rwxr-xr-x 1 tom staff 5.7K 13 Feb 2012 RELEASE-NOTES.html
drwxr-xr-x 13 tom staff 442B 13 Feb 2012 SFS2X
drwxr-xr-x 8 tom staff 272B 13 Feb 2012 jre
drwxr-xr-x 9 tom staff 306B 13 Feb 2012 third-party-licenses
Run Code Online (Sandbox Code Playgroud)
所以,你现在可以继续开始这该死的事情了。
ubuntu@ip-10-243-117-245:~/SmartFoxServer2X/SFS2X$ ./sfs2x-service start
Run Code Online (Sandbox Code Playgroud)
或者使用完整路径,通过运行启动它
/home/ubuntu/SmartFoxServer2X/SFS2X/sfs2x-service start
Run Code Online (Sandbox Code Playgroud)
并停止它:
/home/ubuntu/SmartFoxServer2X/SFS2X/sfs2x-service stop
Run Code Online (Sandbox Code Playgroud)
您可以对该 sfs2x-service 执行以下命令: {start|stop|status|restart|force-reload}
有趣的是,它看起来像默认情况下的 SmartFox,需要在 AWS 安全组防火墙上打开端口 8080。
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
Run Code Online (Sandbox Code Playgroud)
幸运的是,这真的很容易。
在控制面板的侧边栏上,有一个安全组链接。
编辑它,添加自定义 TCP 规则并允许端口 8080 到 0.0.0.0/0
添加规则,并应用更改。
您现在应该能够通过 Amazon EC2 在控制面板中为您提供的 DNS 名称访问您的 SmartFox 游戏服务器。这与您之前使用 SSH 的方式相同。
这就是所有的人!