Deploy EzyPlatform

Updated at 1715419485000
EzyPlatform can be deployed on different operating systems, but it is recommended to use Linux-based operating systems such as Ubuntu or CentOS for automatic restart capabilities. Here, I will use Ubuntu as the operating system.

Add SSH Public Keys

Add SSH public keys for convenient login.

mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys
# add key and close

Change Timezone

timedatectl list-timezones | grep <keyword>
sudo timedatectl set-timezone your_time_zone
timedatectl

Install Firewall

Note that you only need to install the firewall for servers or VPSs that do not have a firewall service.

Refer to: How To Set Up a Firewall with UFW on Ubuntu 20.04

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw enable
sudo ufw allow http
sudo ufw allow https

If your application uses sockets and websockets, you will need to open additional ports.

  1. 3005 for sockets
  2. 2208 if you only use ws
  3. 2812 if you use wss
  4. 2611 if you use UDP
sudo ufw allow 3005
sudo ufw allow 2208
sudo ufw allow 2812
sudo ufw allow 2611/udp

Install MySQL

Refer to: How To Install MySQL on Ubuntu 20.04.

sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql.service

MySQL Configuration

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<new password>';
exit
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;
exit
sudo mysql_secure_installation

Create Database

CREATE SCHEMA `new_schema` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ;

Create a new user, for example:

CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON new_schema . * TO '<username>'@'localhost';

Install Nginx

Refer to: How To Install Nginx on Ubuntu 20.04

sudo apt update
sudo apt install nginx
systemctl status nginx

Restart Nginx:

sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx

Remove the default file in the /etc/nginx/sites-enabled and /etc/nginx/sites-available directories.

Go to the /etc/nginx/sites-enabled directory and create two files for the public site and admin site.

Public site, for example :

server {
    server_name <host name>;

    location / {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://127.0.0.1:8080";
        client_max_body_size 50M;
    }
}

If you want to add Cache-Control header for web you can add:

 location ~* \.(css|js|woff|woff2|ttf|gif|jpg|jpeg|png)$ {
        expires 1h;
        proxy_pass "http://127.0.0.1:8080";
}

Admin site, for example admin.:

server {
    server_name admin.<host name>;

    location / {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://127.0.0.1:9090";
        client_max_body_size 100M;
    }
}

If you want to add Cache-Control header for admin you can add:

location ~* \.(css|js|woff|woff2|ttf|gif|jpg|jpeg|png)$ {
        expires 24h;
        proxy_pass "http://127.0.0.1:9090";
}

Check the Nginx configuration: sudo nginx -t, if it displays like this, it's okay.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart Nginx

sudo systemctl reload nginx

Install Certbot

sudo apt install certbot python3-certbot-nginx
sudo certbot

After using Certbot, the configuration file may be changed like this:

server {
    server_name admin.tvd12.com;

    location / {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://127.0.0.1:9090";
        client_max_body_size 100M;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/tvd12.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/tvd12.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    listen 80;
    server_name admin.tvd12.com;
}
server {
    if ($host = admin.tvd12.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name admin.tvd12.com;
    listen 80;
    return 404; # managed by Certbot
}

Remove Redundant Section

Remove the following section:

server {
    listen 80;
    server_name admin.tvd12.com;
}

Then restart Nginx: sudo systemctl reload nginx.

Install JDK 8

Refer to: How To Install Java with Apt on Ubuntu 20.04.

sudo apt update
java -version

Running these commands will display the list of Java installations.

apt install default-jre            
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless 
apt install openjdk-9-jre-headless

Choose openjdk-8-jre-headless for the apt install.

Set up JAVA_HOME by adding the following line to the .bash_profile using vim:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

Then run: source ~/.bash_profile to apply.

Install EzyPlatform

You can download the latest version from the Home page and then use a tool to copy it to the server, or use wget and inspect the download button on the Home page to get the latest version, for example:

wget https://ezyplatform.com/api/v1/platforms/0.3.6/download && mv download ezyplatform.zip

Then unzip the file: unzip ezyplatform.zip.

Navigate to the ezyplatform/settings folder and modify the setup.properties file (e.g., nano settings/setup.properties) with the database information you created earlier, for example:

datasource.jdbc_url=jdbc:mysql://localhost:3306/<databaseName>
datasource.driver_class_name=com.mysql.cj.jdbc.Driver
datasource.username=<username>
datasource.password=<password>
tables.create_manually=false

Start by running in console mode first to check for any errors:

bash cli.sh "console admin"
If you see EZHTTP READY printed in the console and no exceptions, it means the startup was successful.

From here, let's assume the website you want to create is tvd12.com. Open your browser and go to: https://admin.tvd12.com/setup-admin, where you will see the setup screen:

setup-ezyplatform.png

Set up the necessary information and submit, then the home screen will be displayed:

ezyplatform-home.png

Make sure you turn off all ezyplatform websites running on localhost and clear all cookies.

Go to Dashboard > Admin and update the Admin URL and Admin Properties, for example:

ezyplatform-admin.png
https://admin.tvd12.com
cors.allowed_origins=https://admin.tvd12.com
cors.enable=true
server.host=0.0.0.0
server.multipart.file_size_threshold=100MB
server.multipart.max_file_size=100MB
server.multipart.max_request_size=100MB
server.port=9090

Now, turn off the console mode by pressing Ctrl+C, and start in the background mode:

bash cli.sh "start admin" ; tail -f logs/admin-server.log

Wait for about 10-15 seconds for the server to finish startup, then go back to your browser and select Dashboard > Web. Update the Web URL and Web properties, for example:

ezyplatform-web.png
https://tvd12.com
cors.allowed_origins=https://tvd12.com,https://admin.tvd12.com
cors.enable=true
management.enable=true
management.port=18080
management.uris_expose=true
resources.enable=true
resources.locations=static
resources.upload.enable=true
server.allow_override_uri=true
server.host=0.0.0.0
server.multipart.file_size_threshold=100MB
server.multipart.max_file_size=100MB
server.multipart.max_request_size=100MB
server.port=8080

Then click the start button. Wait for 10-15 seconds and you can access: https://tvd12.com.

Setup SSL for socket

If you don't need to use socket or you are in localhost, you can skip this step.

  1. You can look at here to see how to create a keystore file.
  2. After you have the keystore file, you can upload and set the password via Dashboard > Socket > SSL configuration.

Congratulations! You have successfully deployed EzyPlatform on an Ubuntu server. Next, you can install themes and plugins according to your preferences.