Skip to content
Zhenёq edited this page Dec 3, 2023 · 9 revisions

(WIP Example) How to install on Ubuntu Jammy

Create a user if you don't have one

adduser user
mkdir -p /home/user/.ssh
touch /home/user/.ssh/authorized_keys
chown -R user:user /home/user/.ssh
chmod -R go= /home/user/.ssh
echo 'user ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/user

Add ssh key to /home/user/.ssh/authorized_keys formatted as ssh-rsa <key-without-whitespaces> <comment>

Following instructions assume that you are logged in as user.

Dependencies

Wine

https://wiki.winehq.org/Ubuntu

sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
sudo apt update
sudo apt install -y --install-recommends winehq-stable

Other

sudo apt install -y supervisor zip unzip xvfb

Server files

Upload the latest Evos.Sandbox.zip to you server and unpack it, e.g.

unzip /home/user/atlas/Evos.Sandbox.zip -d /home/user/atlas/Evos/

Alternatively, you can build the binaries yourself. Make sure to upload configuration files as well.

Supervisor

Create a config at /home/user/atlas/atlas.supervisor.conf

[program:xvfb]
user=user
command=Xvfb :0 -noreset 
autostart=false
autorestart=true
stderr_logfile=/home/user/atlas/log/xvfb/err.log
stdout_logfile=/home/user/atlas/log/xvfb/out.log

[program:evos-wine]
user=user
directory=/home/user/atlas/Evos/
environment=WINEPREFIX="/home/user/.atlas/"
command=wine /home/user/atlas/Evos/EvoS.Sandbox.exe
autostart=false
autorestart=true
stderr_logfile=/home/user/atlas/log/evos/err.log
stdout_logfile=/home/user/atlas/log/evos/out.log

You can set autostart=true if you want the app to start on boot. Xvfb is not required for running lobby server but it will be needed during .Net installation.

You can optionally add web controls for Supervisor, just append following lines to the config (replacing username and password).

[inet_http_server]
port=:9001
username=username
password=password

Then run

mkdir -p /home/user/atlas/log/evos
mkdir -p /home/user/atlas/log/xvfb
sed -i -e '/^files = / s/$/ \/home\/user\/atlas\/atlas\.supervisor\.conf/' /etc/supervisor/supervisord.conf
sudo supervisorctl reread
sudo supervisorctl update

.NET

Download installers into /home/user/atlas/:

It is inadvisable to run Wine as root.

sudo supervisorctl start xvfb
WINEPREFIX="/home/user/.atlas/" DISPLAY=":0.0" wine /home/user/atlas/dotnet-runtime-7.0.14-win-x86.exe /q
WINEPREFIX="/home/user/.atlas/" DISPLAY=":0.0" wine /home/user/atlas/aspnetcore-runtime-7.0.14-win-x86.exe /q
sudo supervisorctl stop xvfb

MongoDB

MongoDB 5+ is required.

TODO

Installing locally

https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/

curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
   --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org

TODO

Nginx

sudo apt update
sudo apt install -y nginx

Create site config /etc/nginx/sites-available/atlas. Don't forget to replace <your-ip> and <your-dns-name> (if you don't have the latter, you can just omit it).

server {
	listen 80;
	listen [::]:80;
	root /var/www/atlas/html;
	index index.html index.htm index.nginx-debian.html;

	server_name <your-ip> <your-dns-name>;

	location /api/admin {
		proxy_pass  http://127.0.0.1:3001;
		proxy_set_header  X-Real-IP $remote_addr;
		proxy_set_header  X-Forwarded-Proto https;
		proxy_set_header  X-Forwarded-For $remote_addr;
		proxy_set_header  X-Forwarded-Host $remote_addr;
	}

	location /api {
		proxy_pass  http://127.0.0.1:3002;
		proxy_set_header  X-Real-IP $remote_addr;
		proxy_set_header  X-Forwarded-Proto https;
		proxy_set_header  X-Forwarded-For $remote_addr;
		proxy_set_header  X-Forwarded-Host $remote_addr;
	}
	
	location / {
		gzip_static on;
		try_files $uri $uri/ @index;
	}

	location @index {
		add_header Cache-Control no-store always;
		try_files /index.html =404;
	}
}

If you want to enable admin page, upload the latest Evos.Admin.zip to you server and unpack it

mkdir -p /var/www/atlas/html/
unzip /home/user/atlas/Evos.Admin.zip -d /var/www/atlas/html/
sudo ln -s /etc/nginx/sites-available/atlas /etc/nginx/sites-enabled/
sudo nginx -s reload

Let's Encrypt

TODO

Firewall

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow proto tcp from any to any port 80
sudo ufw allow proto tcp from any to any port 6050
sudo ufw allow proto tcp from any to any port 6060
sudo ufw allow proto tcp from any to any port 9001
sudo ufw enable

Swap (optional)

https://repost.aws/knowledge-center/ec2-memory-swap-file

https://help.ubuntu.com/community/SwapFaq#How_much_swap_do_I_need.3F

Create 2097152 KB of swap

sudo dd if=/dev/zero of=/swapfile bs=1024 count=2097152
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sed -i -e '$a/swapfile swap swap defaults 0 0' /etc/fstab

To check if it is working sudo swapon -s