Helper links:
Swift releases: https://swift.org/download/#releases
https://www.swift.org/install/linux/#installation-via-tarball
How To Install Vapor Server on Ubuntu 20.04 (root)
sudo apt-get update
apt-get install \
binutils \
git \
gnupg2 \
libc6-dev \
libcurl4 \
libedit2 \
libgcc-9-dev \
libpython2.7 \
libsqlite3-0 \
libstdc++-9-dev \
libxml2 \
libz3-dev \
pkg-config \
tzdata \
uuid-dev \
zlib1g-dev \
mc
wget https://download.swift.org/swift-5.9-release/ubuntu2004/swift-5.9-RELEASE/swift-5.9-RELEASE-ubuntu20.04.tar.gz
tar xzf swift-5.9-RELEASE-ubuntu20.04.tar.gz
Add the Swift binaries to path
mcedit ~/.bashrc
Copy and save in your .bashrc file
export PATH=/home/<profile-name>/swift-5.9-RELEASE-ubuntu20.04/usr/bin:”${PATH}”
In your ssh terminal
source ~/.bashrc
Check that swift is installed (optional)
swift --version
git clone https://github.com/vapor/toolbox.git
cd toolbox
git checkout 18.7.4
swift build -c release --disable-sandbox
sudo mv .build/release/vapor /usr/local/bin
mkdir /home/<profile-name>/projects
cd /home/<profile-name>/projects
vapor new VaporHelloWorldApp
cd VaporHelloWorldApp/
for Release mode:
swift run -c release
The first step is to install Nginx on your server. Connect to your server with ssh and run these commands :
sudo apt-get update
sudo apt-get install nginx
Once Nginx is installed, run this command to configure Nginx for your application :
mcedit /etc/nginx/sites-enabled/default
Setup the configuration by editing your server name and the root path :
# Default server configuration
#
server {
server_name sample-server-name.com; #
listen 80;
root /home/<profile-name>/projects/VaporHelloWorldApp/Public/; #fix path
# Serve all public/static files via nginx and then fallback to Vapor for the rest
location / {
try_files $uri @proxy;
}
location @proxy {
proxy_pass http://127.0.0.1:8080;
proxy_pass_header Server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Server;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
}
}
systemctl restart nginx
systemctl status nginx
apt-get install supervisor
configfile
sh -c 'echo_supervisord_conf > /etc/supervisor/supervisord.conf'
reboot server
reboot
mcedit /etc/supervisor/supervisord.conf
add
[program:VaporHelloWorldApp]
command=/home/<profile-name>/projects/VaporHelloWorldApp/.build/release/App serve --env prod
directory=/home/<profile-name>/projects/VaporHelloWorldApp/
user=vapor
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log
supervisorctl reread
supervisorctl update
reboot server
reboot
And open http://<your_domain_or_ip> in your browser, it should show the message “It works!”.
- Update the repository lists:
sudo apt-get update
- Install the latest version
apt-get install postgresql
sudo su - postgres
reboot
3) Check your database connection
sudo su - postgres
psql
postgres=# \l
postgres=# \q
a) Create a database mybase
sudo su - postgres
psql
postgres=# create database mybase;
CREATE DATABASE
postgres=# create database mybase;
CREATE DATABASE
b) Create user myuser with password mypass:
postgres=# create user myuser with encrypted password 'mypass';
CREATE ROLE
c) Give the user permissions to access the mybase database:
postgres=# grant all privileges on database mybase to myuser;
GRANT
postgres=# \q
d) Check the connection with Ubuntu OS user rights:
psql -hlocalhost -Umyuser -W mybase
curl -o- https://raw.githubusercontent.com/vinyll/certbot-install/master/install.sh | bash
sudo certbot --installer nginx -d lavteam.ddns.net
The end
PS
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
$ sudo systemctl restart ssh
we need to set root’s password
sudo passwd
mcedit /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
mcedit /etc/postgresql/12/main/pg_hba.conf
host all all 0.0.0.0/0 md5
host all all ::/0 md5