Setting up an AS3 Club Penguin Private Server on Ubuntu 18.04


#1

Hey

Here we have the step by step guide on how to setup and host an AS3 Club Penguin Private Server on a Virtual Private Server. This guide is very detailed and is intended specifically for trouble shooting.

Solero will release a tool that requires less work from you, and an easier way of setting up a CPPS. Keep a look out for it soon!

We will be using nginx as our web-server, mysql as our database management system, and python2.7 to run Houdini. You are free to use an alternative, but you may find it incompatible with this tutorial, so you must find a work-around/alternative.

For example, people prefer mariadb over mysql which is completely fine and you may use it as an alternative, but if you run into any problems with mariadb specifically you will have to troubleshoot for yourself.

Please remember that this tutorial does not encourage weak practices of security, however it has been made for the ‘average joe’, therefore we are keeping things pretty simple for now.

For the experienced ones, you may skip the steps that you are already familiar with.

But before we begin, you must have the following requirements.

REQUIREMENTS:

ADDITIONAL OPTIONAL TOOLS:

Now that we are prepared, let’s begin…

THE INITIALIZATION OF YOUR VPS

When buying a Virtual Private Server, it’ll usually prompt you with a question asking what OS you would like to install. You should choose Ubuntu 18.04 or anything higher than that.

If you decide to choose another distribution whilst following this tutorial, you may run into compatibilities issues. Seek alternatives or work-arounds if you are not using Ubuntu 18.04.

If you have a lower version but know what you’re doing that’s completely fine.

The company you bought your VPS from would send your VPS details in the form of an email with the title: Your VPS installation

The email would typically be along the lines of:

Dear Customer,

Your VPS has just been installed on the following operating system/distribution
Ubuntu 18.04 Server (64-bit version)

ACCESS SETTINGS:
Your VPS’s IPv4 address is: VPSIP
Your VPS’s IPv6 address is: …

Your VPS name is: …

The following administrator account has been configured on the VPS:
Username: root
Password: MyVPSPassword

GETTING STARTED
If you are connecting to a VPS for the first time, we suggest that you refer to the following guide:
https://www.ovh.co.uk/g1260.how_to_log_in_to_your_vps

MANAGEMENT, BILLING, SUPPORT
You can manage your VPS from your control panel
at the following address:
https://www.ovh.com/manager/

TO GET HELP:
To assist you in getting started with your VPS, we provide you with
user guides:
https://www.ovh.co.uk/support/knowledge/

A large community of users are also available via our forum and our mailing lists here:
https://www.ovh.co.uk/support/

Kind regards,
The OVH Team

Thank you for choosing OVH!

Kind regards,

The OVH team

Using a tool like PuTTy or Terminal (from the requirements), we can now login to the Virtual Private Server remotely.

macOS users can open up terminal and type in the following:

ssh [email protected]

Windows users can use PuTTy, refer to this guide.

Both ways should prompt you with a password, which you obviously retrieve from the installation email. Once you are succesfully logged in, we should probably update the package list before starting to install packages.

Run the command:

sudo apt-get update

You should find yourself at an output like this:

If this is successful, we can move on to what we call: the heap of commands.

Whenever you are prompted with Y/N, you will want to select y as you are agreeing to install the following module.

The Firewall

Every Ubuntu 18.04 VPS is preinstalled with UFW (a firewall), however the service is not active by default.

What we want to do before we activate the firewall, is to create a set of rules to allow our needed ports to bypass the firewall. So execute the following commands:

sudo ufw allow 6112,9875,22,80/tcp

For the purpose of learning, I will explain why we enabled each port and how it relates to us.

6112 - a port that our emulator listens to for the login server.
9857 - a port that our emulator listens to for the world server.
22 - a port that our VPS listens on for SSH access.
80 - a port that our VPS listens on to receive from a web client.

Now that we have enabled these ports to be bypassed through the firewall, we can enable the firewall.

Execute the command:

sudo ufw enable

When prompted, it will ask

Command may disrupt existing ssh connections. Proceed with operation (y|n)?

You want to type y and click enter as you are agreeing to enable this firewall.

This activates the UFW service (a firewall) to prevent any unauthorized incoming connections.
A successful result would say this:

Firewall is active and enabled on system startup

You can see if this works by executing the command:

sudo ufw status

By doing this, you are able to see a table of ports that are allowed to be passed through

The Web-Server

From now on, if you run into any issues with installing these modules, read the error message given as an output on terminal and attempt to identify a solution, try and google search the error/output from your console or feel free to post it in the support channels of Solero’s Discord server.

For this tutorial, we are going to be using nginx as our web-server. However, if you know what you are doing you may use an alternative webserver like apache.

Execute this:

sudo apt-get install nginx

If you want to check whether that was successful or not, you could test it using this command:

sudo service nginx status

And it would show an output like this…

Now if you head over to your browser and enter your VPS IP into the URL bar, you will find yourself at the nginx installation page, which means the installation was successful.

Database Management

Like I said earlier, you are free to use alternatives but for this tutorial we will specifically be using mysql.

You want to head over to PuTTy or Terminal and execute the following command:

sudo apt-get install mysql-server

If you want to check whether that was successful or not, you could test it using this command:

sudo service mysql status

You should find an output similar to this:

If that was successfully installed, you should execute the next command to set a password for the root login:

sudo mysql_secure_installation

You will be asked whether you want to use the validate password plugin to set a password or to set your own, I suggest you use https://randomkeygen.com for reliable, secure passwords and set a password yourself.

However you are still free to use the validate password plugin as long as you know what password you have used

I would enter n when prompted, this would allow me to set my own password, which I will retrieve from https://randomkeygen.com, save it somewhere and use it for the root login like shown:

You should save this password somewhere using a password database manager or by remembering it. However we will not use it in this tutorial again, you may need it for the future if you are connecting to MySQL via SSH as root.

Once you have entered that, it will ask a range of questions about the security of your mysql server. You want to enter y each time it prompts you, like shown:

What this will do is disable the default root login when remotely accessing the database (which is why we don’t need it again), and what we will do next is create a non root login with a secure password to be used to connect to our database remotely.

The password you set for this new, non root user, will definitely have to be remembered or saved using a password database manager. Just make sure you don’t forget it as we will need it later in the tutorial.

You want to head over to PuTTy or Terminal and execute the following command:

sudo mysql -u root -p

Since you are logging into mysql as root, you don’t need to enter a password when prompted because you are a superuser (root) and already have bypassed access. You will be successfully logged in when you see a prompt like this saying mysql>

Now we are going to enter a bunch of queries to create a new, non root mysql user so we can remotely connect to our database from a database tool like DataGrip or Sequel Pro.

Execute the following query in PuTTy or Terminal:

CREATE USER ‘MYUSERNAME’@‘localhost’ IDENTIFIED BY ‘MYPASSWORD’;

As you can notice from reading the query, you would want to replace MYUSERNAME with a MySQL username of your choice, personally i’d choose something completely random.

You also want to replace MYPASSWORD with a secure password, i’d recommend choosing one from https://randomkeygen.com.

You then want to save your new MySQL username and password somewhere, perhaps a password database manager that you can have on your desktop or if you can somehow remember it.

Just remember that these are sensitive details and these should not be disclosed with anyone at any point. We do not encourage you to use the passwords from this tutorial either, create your own using https://randomkeygen.com.

Here is an example of what i’d do:

The Query OK output gives us an indication that this was successful, if you chose a weak password as your password you may get an error message for it e.g.

This just simply means that you need to set a more secure password, try to use the passwords under the Strong Passwords or Fort Knox Passwords categories

Now we created a new user, we should probably create Houdini’s database where we would grant privileges to our new mysql user to use the database.

So you want to execute the next query:

CREATE DATABASE Houdini;

What this will do is create your database to manage your penguin data and assets, you will be able to see a graphical representation of this using a database tool like DataGrip or Sequel Pro, but for now we are only executing the queries via SSH to create it.

You then want to execute the next query:

USE Houdini;

and then, you will want to copy and paste EVERYTHING from this SQL file and paste it into PuTTy or Terminal as a query.

For Windows users, using your keyboard you may want to use CTRL+A to highlight all of the SQL code within that file, then do CTRL+C to copy all of the code

For macOS users, using your keyboard you may want to use CMD+A to highlight all of the SQL code within that file, then do CMD+C to copy all of the code.

You then want to head over to PuTTy or Terminal, and if you are using PuTTy you want to right click using your mouse to paste the query. If you are a using Terminal (macOS) you can use CMD+V on your keyboard to paste it.

It should be done like this:

You can tell it’s successful when it says at the end

Query OK, 0 rows affected (0.00 sec)

If there is still a query to execute e.g. it’s finished like this without saying Query OK

Then execute it, click enter!

Once successful, you now have an existing database, you now need to grant privileges to the new mysql user you created so that it can access it when run the emulator.

Execute this next query:

GRANT ALL PRIVILEGES ON Houdini.* TO ‘MYUSERNAME’@‘localhost’;

Obviously you should replace MYUSERNAME with your actual MySQL username.

For example my MySQL username is flake so I would do the following:

Then finally, I would execute the command to refresh privileges.

FLUSH PRIVILEGES;

You can then type this into the console to exit out of mysql command line, and now you have your database setup.

quit

Installing Houdini and Python

Now we are going to install python modules so that we can run our emulator Houdini.

Go to PuTTy or Terminal and execute the following command:

sudo apt-get install git

This will install the git command which we will use to install Houdini’s emulator onto our VPS.

We are going to install the AS3 branch of Houdini into the /Houdini directory of your VPS using git.

Execute the following command:

git clone -b as3 https://github.com/solero/houdini ~/houdini

We will later modify Houdini to have our own preferences.

Next we need to install python, so execute this command:

sudo apt-get install python2.7 python-pip python-dev python-setuptools

REMINDER: Running Houdini with python3 will not work. It is imperative you use python2.7.

Once that is installed, we need to install some python modules that Houdini uses. We will use pip

Execute the following command:

cd /root/houdini

Then execute this:

pip install -r requirements.txt

If you run into any issues, you may want to find an alternative for it e.g. use sudo apt-get install to install it.

TROUBLESHOOTING AND ALTERNATIVES

Remember that if you run into any issues during this process/it crashes, then you will have to solve that one module individually, then remove it from requirements.txt and continue using pip to install the modules

Here is an example, I executed the command and most of the modules are installing except for one, mysql-python which has caused the installation to crash.

What you then want to do is seek an alternative, so in this case I would research that error message and see that there is an alternative from here so I would execute the alternative command for that module which is:

sudo apt-get install python-mysqldb

It should install successfully, next you want to remove this module from the requirements list so you can install the rest of the requirements.

So we will execute:

sudo nano /root/houdini/requirements.txt

This will make an editor pop up to modify requirements.txt with all the python modules that we try to install, since we found an alternative to mysql, you want to remove it.

So your file should finally look like this:

Then you want to click CTRL+X to close the file, it will ask if you want to save the newer version, just type y and press enter, it will ask what file to write it to, just write it to the default file it gives.

Once saved you want to re try installing the modules with pip

So execute the command:

pip install -r requirements.txt

Once installed successfully your final output should look like this with no errors:

You want to do the same thing as I did in the example if you run into any issues, find alternatives and remove the module that doesn’t work from requirements.txt.

Now here is the final piece of server work we need to do, we need to install the redis-server.

Execute the following command:

sudo apt-get install redis-server

Now the server work is done, we can move onto deploying our resources!

INSTALLING YOUR MEDIA-SERVER

You are free to use any AS3 media server you want, as long as you can configure it correctly. If you want to run into no issues, you may want to stick to using this media server provided by the Solero team, also known as the vanilla media-server.

You want to head over to PuTTy or terminal, and enter the following command:

cd /var/www/html

This will take you to your web-servers directory where the media server belongs, you then want to execute the following command:

wget -r https://icer.ink/.repo/vanilla/media.zip

A successful installation would look like this:

The media-server would be found in /var/www/html/icer.ink/.repo/vanilla and we need to move it to the web-server directory. So execute the following command:

mv /var/www/html/icer.ink/.repo/vanilla/media.zip /var/www/html/media.zip

Now your media server will be in the correct folder, where you can unzip it.

First we need to install an unzip tool, so execute the next command:

sudo apt install unzip

This will install a tool that we can use to unzip the media server. Once successfully installed you want to execute the next command which will unzip the media-server.

unzip media.zip

Yeah, a lot of files!

CONFIGURING THE WEBSERVER

For this part, you may want to find an alternative if you don’t have a domain because this part requires an actual domain.

You may want to load it in the form VPSIP/play and VPSIP/media but that is your choice and you will have to take out the correct edits/configuration.

If you have a domain, go to the domain panel (or if your site is under cloudfare then cloudfares panel) and find the part where you can add DNS records.

For your domain to link your VPS, you need to add an A Record and insert your VPS IP and domain name in the correct areas. Each domain panel has their own design/setup so you may want to refer to external sources for extra support, but here is an example of how I would do mine (as it’s under cloudfare).

Considering my domain name is cpps.network:

I would also replace MYIPADDRESS with my VPS IP.

Then you need to add CNAMES, which are sub-domains. For example, for me I would do:

In the Name field, you would enter the sub-domain name (play or media) and in the Domain name field you would put your domains name. Then click Add Records.

Now we need to configure our web-server to load the correct sub-domains for our CPPS to work, so what we’re going to do is modify nginx configuration for our preference.

We are going to be using the editor over SSH, if you prefer using an FTP tool like FileZilla to access these configuration files, and edit it with a source code editor like Visual Studio Code then feel free to do so. But for a quick and easy setup, feel free to follow my steps!

Execute the following commands:

sudo cp -a /etc/nginx/sites-available/default /etc/nginx/sites-available/play

sudo cp -a /etc/nginx/sites-available/default /etc/nginx/sites-available/media

This copies the default configuration file, with a new name play and media for our sub-domains. We are going to edit these using nano.

So execute the next command:

sudo nano /etc/nginx/sites-available/play

You want to remove the default_server part from here:

So that it looks like:

Then you want to scroll down to the root part where it specifies your directory for the sub-domain. You want to change this directory from /var/www/html to /var/www/html/play as it’s for the sub-domain play.

would change to:

Then we need to set the server_name, so change _ to your sub-domain.

Would change to:

Now we need to save the file, so on your keyboard press CTRL+X, you would be prompted with whether you want to save the file, so select y and then it would ask what file you would like to write it to, it will most likely already have the correct file so just click enter.

You should have exit from the editor, and now back into normal terminal.

You now want do the exact same, but for media so execute the command:

sudo nano /etc/nginx/sites-available/media

So you would do the exact same steps as above, but set /var/www/html to /var/www/html/media and set _ to media.cpps.network

So it would look like this

Now we need to save the file, so on your keyboard press CTRL+X, you would be prompted with whether you want to save the file, so select y and then it would ask what file you would like to write it to, it will most likely already have the correct file so just click enter.

We need to create sym-links for this, so execute the next commands:

sudo ln -s /etc/nginx/sites-available/media /etc/nginx/sites-enabled

sudo ln -s /etc/nginx/sites-available/play /etc/nginx/sites-enabled

To test whether this worked successfully, you should execute the next command:

sudo nginx -t

You should find the following output:

Then you should execute the next command to reload nginx:

sudo service nginx reload

If you head over to play.yourdomainname e.g. in my case i’d head over to play.cpps.network, you will find the original play page, just click the play button and it should add /#/login to the end, which will load your play page. It won’t load yet because the domain is still configured for localhost.

CONFIGURING MEDIA-SERVER

Again, we will be using nano to edit these files, so execute the following command:

sudo nano /var/www/html/media/play/web_service/environment_data.xml

On your keyboard, use *CTRL+* to find and replace and within that file you want to replace media.localhost to media.yourdomain, obviously replacing yourdomain with your actual domain name. For example, my domain name is cpps.network:

To:

We then need to configure the play page to load from our domain, and not localhost.

So execute the following command:

sudo nano /var/www/html/play/index.html

On your keyboard, use *CTRL+* to find and replace or scroll down to the part where it says media.localhost, replace that link with media.yourdomain, obviously change yourdomain to your actual domain name, e.g. my one is cpps.network and done like shown:

Now we need to save the file, so on your keyboard press CTRL+X, you would be prompted with whether you want to save the file, so select y and then it would ask what file you would like to write it to, it will most likely already have the correct file so just click enter.

Finally, your play page should load successfully…

If not, make sure you clear your sites cloudfare and your own browsers cache.

We also need to make sure that the IPs are correct in the global crumbs, you could use JPEX to edit this straight as a SWF, or you could download a decompiled version of the crumbs here (FLA) and edit it with Adobe Flash CS6:

You will need to use FileZilla to get a hold of the file, or you could potentially transfer it over SSH. Make sure you transfer the global_crumbs.swf file to your desktop.

For this tutorial, i’ll use JPEX. Open the file from your desktop with JPEX and go to scripts -> frame 1 -> Do Action, you will see some action script code:

You want to click, Edit ActionScript and replace on line 7 and 25, 127.0.0.1 with your VPS IP, it should look like this:

Obviously you would want to replace VPSIP with your actual VPS IP.

Once you have done that you can save the file and you should find a success message:

Then you want to upload this new file to the VPS, overriding the old one.

That’s the media server complete!

CONFIGURING AND RUNNING HOUDINI

Don’t worry, we are almost there :~)

We need to configure our source Houdini to have the correct MySQL details for when it runs, so execute the following command, we will be using nano to edit config.py.

sudo nano /root/houdini/config.py

Now you want to use *CTRL+* or manually replace certain configs yourself within this file.

Replace root with the MySQL username you set earlier when setting up the database, then replace the empty password field where it’s literally " " to have your MySQL password. These are the sensitive details that you saved earlier after creating a new user for MySQL.

Here is an example of what mine would be:

You then want to replace the IP 127.0.0.1 with your VPS IP so it would look like this

Obviously replace VPSIP with your actual VPS IP.

UPDATE: Houdini now supports Redis configuration within it’s config.py file, so you must keep that as 127.0.0.1 (even if you are on a VPS). Like shown:

Now we need to save the file, so on your keyboard press CTRL+X, you would be prompted with whether you want to save the file, so select y and then it would ask what file you would like to write it to, it will most likely already have the correct file so just click enter.

Now that Houdini’s configuration file is ready, we are now ready to run the servers.

Just execute these last 2 commands to run your servers:

cd /root/houdini

python Login.py & python World.py

You should get a successful message confirming that it’s running:

Now you can login with the:

Username: Houdini
Password: password

:~)

If not, google the error, install any missing modules or see what is causing it. The most common error is that it will say the address is already in use, well this means Houdini is already running so what you wanna do is execute

killall python

at least twice, and then rerun your servers.

Here is what should be happening, when you login you should check the console (putty or terminal) and if there is no activity going on, then your media-server is not communicating with your source (meaning you haven’t configured something correctly to have your VPS IP).

Before seeking help in Solero, maybe ask yourself these questions:

  • have you checked your web-server logs e.g. /var/log/nginx/error.log
  • have you cleared your cache on your browser and on cloudfare
  • is every file configured?
  • is any other services running on that port ?
  • did you check developer tools for any missing files ?
  • google search ?

Otherwise, head over to our discord server and we have a support channel to give you some guidance :~)

Looking for a working register? Try out my one here

Looking for how to manage user data? rather than through SSH? Use a database tool like DataGrip or Sequel Pro, or even Navicat, some of these costs but are useful to manage your penguins data. There are many guides on the internet on how to use these.

useful additional tips:

  • Enable SSH keys, disable password authentication
  • Add SSL using certbot
  • Put your server under cloudfare
  • Disable root access, add a new user with sudo perms
  • Change the default SSH port
  • Refrain from using a web based database manager (e.g. phpMyAdmin or Adminer)
  • Create a www sub-domain, redirect the normal domain to the www one (e.g. for me cpps.network would redirect to www.cpps.network), setup nginx configuration for it and add homepage files to the directory.
  • Add more firewall rules to restrict access to the VPS, e.g. only allow access from your IP and a VPN IP, deny all others.
  • Any actionscript code, don’t bother attempting to decompile and edit, just inject it through the dependencies!

sources that i used in this tutorial or that may be helpful to you:






https://help.ubuntu.com/community/SSH/OpenSSH/Keys <- SSH Keys for macOS users
https://help.ubuntu.com/lts/serverguide/firewall.html.en <- Firewall rules

Any issues, leave in the comments or ping ro#0008 in Solero’s Discord server.

Any mistakes I made, let me know about it.

~ ro


#2

Hello! Could you help me… i have got some problems on the last step. When I type the last commands (python Login.py …) I get some problem(s)… i saved it there in order not to send a big reply because a text I see after sending the last command (python Login.py) is is big… actually i tried to reinstall it but eventually i got the same error. I used ubuntu 18.04 for the first time and then (now) I am using Ubuntu 18.10, but the mistake is absolutely the same. what can i do? what is the problem? i am not good in it, so I would be grateful if somebody could help me or just give an advice. I did everything according to the guide and I did not have any mistakes on other steps, just the last one when i am trying to run the server. thanks!!! :kissing_smiling_eyes:


#3

For anyone else experiencing the same issue:

In your Houdini configuration (config.py), you should make sure you keep the Address in the Redis block as 127.0.0.1, because you are connecting to Redis on your VPS and not an external server. The same thing with your database connection, unless you are hosting your mysql server on another server then you should keep it as 127.0.0.1.

The only part of your configuration that should be modified for your servers preference is the login and world block.


#4

Very nice tutorial.

Hopefully this will help many AS3 fans.