How to put a program and php files on a server?

I’m not new to programming, but I am new to doing things in the “cloud” and am feeling completely lost here.

In order to continue to do research during the Covid I am going to have to migrate my methods with humans to the internet. I have successfully used the game development/programming environment “Unity” to create a WebGL program (a simple video game) that will run in a browser to deliver my experimental protocols and retrieve data.

What I need now (or at least it is what I think I need) is a way to host that game on a server so that it can a: send a request to the server and retrieve a text file, and then b: send data to the server and have it save that data to a text file.

I have studied the general procedures via several different sites & videos and believe I have my Game and PhP files setup so that I can achieve a: and b:. What I have no clue about is how to get all that working on a server.

I assume that this is something that I can accomplish with Cloudways. I assume I would setup a server and upload the game and php files to the server, then obtain web addresses for those so that I would have a link to the game and links to the php files that I would put within the game for it to do the retrieval and data-saving it needs to do. This is what i would assume to be pretty basic stuff. Although the start page states, “Let’s launch the first one, it’s super simple :)” I am lost the moment I press launch and am confronted with choosing the application server & details.

For example, I see Google, Vultr, AWS, etc… when I though that Cloudways was providing the server and I have no idea as to what the differences are with respect to what I need to accomplish. I selected Vultr and apparently manged to get a server up and running. Can someone point me to some reading material as to how to accomplish getting my files up onto that server and configured (if some further configuration is necessary) to be able to accomplish my a: and b: goals above?

Many thanks,

Hi drjbn,

SFTP (secure file transfer protocol) is what is used to upload files to a server. You need to use a program that can send files over SFTP. I like to use FileZilla. The second video on this link explains how to setup Filezilla to send files to your Cloudways server. Alternatively, you can find SFTP plugins for many IDEs that will immediately upload files to the server whenever you save them. That can be pretty convenient as well, but may be a little bit more difficult to setup.

There are 2 parts to your system. There is the server-side code that is running in PHP, and there is the client-side code that is running in WebGL. You’ll have to follow the instructions Unity provides to setup a page that can run your WebGL game on your server.

Then to create your PHP backend, all you have to do is upload your PHP files, and PHP is pretty simple, there isn’t anything more you need to do to get your API running. After uploading the files, you should be able to use the domain name you setup, or the default one Cloudways gives you to visit any of the endpoints in your API by going to You can put something simple inside of your PHP file such as <?php echo "test" to test that you are able to reach your PHP endpoint. Then as you start creating your endpoint, if you ever run into an error, it will get logged to the log file located at ~/applications/yourApplication/logs/apache…error.log.

You’re going to end up with 2 different files. The first will be something like that will retreive the text file, and the second will be to save the data. I’m assuming these files will be different for each user. You’ll want to send a unique identifier to identify the name of the file you want to save/retreive. You can do this with a query string parameter e.g., or by sending a POST request. With either method you would end up being able to access the ID in PHP by doing $_REQUEST['id'].

Back to your Unity game. In your game you would then make a request to… using whatever method Unity has for fetching data from the web. Your Unity game will also need to remember the id that it uses when talking with your backend.

Russell, many many thanks for your reply and clarifications!