2

I'm using Web.com to host a website for my MMO. I'm currently developing a simple server and testing it out on the web server. I've uploaded the server.jar file to the web server and now I can't figure out how to run it. How would I run it on the webserver?

Also the client would need an IP address to connect to, would that IP be the server's IP? And one more thing, what port should I use?

Any help would be greatly appreciated!

Jacob Pickens
  • 471
  • 1
  • 7
  • 15

2 Answers2

4

Web.com doesn't seem like the type of host you need for this. You'll need some sort of VPS-provider, such as AWS, DigitalOcean, or Linode. They'll give you a Linux virtual machine with SSH access, which is what you need to host your server.

To get SSH access after renting your server, you'll need an SSH client. On Linux and Mac, this is preinstalled - just run ssh <ip>. On Windows, you'll need something like Putty.

Then, you'll need to add your server.jar as a startup script. Linux distributions have various ways to do this, but the most common way (on recent Ubuntu versions, Arch Linux, and many other distributions) is through Systemd. Add a file like this to /etc/systemd/system/mmoserver.service (nano is a good terminal editor for newbies, run nano <path>):

[Unit]
Description=MMO Server

[Service]
ExecStart=java -jar /path/to/server.jar -options=blahblahblah

[Install]
WantedBy=multi-user.target 

Basically, this says when the server starts into multi-user mode (the normal mode, as opposed to single-user mode which is only when something breaks hard), it runs the ExecStart command - your server. Now reboot and use ps aux to verify your server is running. Pipe it to less (ps aux | less) to scroll using the arrow keys, use q to exit less.

You can find your VPS' external ip by running ifconfig and looking for inet addr:.... That said, you'll need the ip to SSH to it in the first place, so you'll probably already have it... :-)

vgel
  • 3,225
  • 1
  • 21
  • 35
2

You can run the server using an ssh session with the command:

ssh user@server 'java -jar server.jar'

If clients should establish a connection with the server, the IP adress is indeed the IP adress over the server.

The port is in many cases "hardcoded" in the Java application (you need to inspect the source code), or it is given as a parameter with the jar (for instance java -jar server.jar -port 8080, other programs (like Apache use a set of config files where the port must be specified). (Mind this depends on the actual java program. Flags not interpreted by the program are in many cases simply ignored).

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555