For a 'small instance' (just one for yourself and not many users) a VPS 200 is sufficient.
I recommend setting up the instance on a VPS 200.
If you feel like the instance is slowing down, you can always update to a bigger server trough the CCP.
The server needs to have Ubuntu 22.04 already installed.
You will also need a domain. A domain used in a webhosting package is sufficient. (You can still use it for your webhosting, because we will use a subdomain.)
A.First you need to log in to your server via SSH, then follow these steps:
sudo -s to get root privileges.Enter.add-apt-repository ppa:ondrej/php -y && apt update -y && apt upgrade -y to update the server.Enter once to continue.apt install curl nginx git zip unzip php8.2-fpm php8.2-cli php8.2-gd php8.2-curl php8.2-cli php8.2-bcmath php8.2-mysql php8.2-ctype php8.2-fileinfo php8.2-mbstring php8.2-tokenizer php8.2-xml php8.2-zip -y || curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && snap install certbot --classic to install all the required software.Enter once to continue.composer update to update composer. (When asked if you want to continue as root, enter Yes and press Enter to continue.)Follow these steps to install and configure MariaDB:
apt install mariadb-server to install MariaDB.mysql_secure_installation to configure MariaDB.Enter to continue (there is no password yet).n and press Enter to continue.n and press Enter to continue.y and press Enter to continue.y and press Enter to continue.y and press Enter to continue.y and press Enter to continue.mysql -u root to log in to MariaDB.CREATE DATABASE 2fauth; to create the database.CREATE USER '2fauth'@'localhost' IDENTIFIED BY '<REPLACE_WITH_PASSWORD>'; to create a user. Replace <REPLACE_WITH_PASSWORD> with a password of your choice.GRANT ALL PRIVILEGES ON 2fauth.* TO '2fauth'@'localhost'; to grant the user all privileges.FLUSH PRIVILEGES; to apply the changes.exit; to exit MariaDB.mkdir /var/www/2fauth && chown www-data 2fauth && cd /var/www/2fauth to create a directory for 2FAuth.sudo su -l www-data -s /bin/bash to switch to the www-data user.curl https://api.github.com/repos/Bubka/2FAuth/tags | grep "tarball_url" | grep -Eo 'https://[^\"]*' | sed -n '1p' | xargs wget -O - | tar -xz --strip-components=1 -C /var/www/2fauth to download and extract the latest version of 2FAuth.cd /var/www/2fauth && composer install --prefer-dist --no-scripts --no-dev && exit to install the dependencies.php artisan 2fauth:install to start the installation.http://2fauth.example.com) and press Enter.my and press Enter five times to select MariaDB as the database driver.Enter.Enter.mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old && nano /etc/nginx/nginx.conf to edit the nginx standard config file.user www-data;
events {}
http {
include mime.types;
access_log /dev/stdout;
error_log /dev/stderr;
server {
listen 80;
server_name 2fauth.example.com;
root /var/www/2fauth/public;
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
}
Ctrl + X, then Y and then Enter.systemctl reload nginx.certbot --nginx to start the CertBot setup.Enter to select the only option (your domain).We need a firewall to protect our server from unwanted connections.
We will use ufw (Uncomplicated Firewall) to set up the firewall, because it is easy to use and configure and is also pre-installed on Ubuntu.
ufw allow ssh && ufw allow http && ufw allow https && ufw enable to allow SSH, HTTP and HTTPS connections and to enable the firewall.Y and then Enter to confirm.https://2fauth.example.com).I recommend disabling registration after you have registered your account. You can do this by opening the settings and enabling "Disable registration" at the bottom of the page.
Now you have successfully installed 2FAuth!
From now on your 2FAuth instance will be available under your subdomain (e.g. https://2fauth.example.com).
Thank you for using this tutorial!
Copyright (c) 2023 Konstantin Protzen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
By making a contribution to this project, I certify that:
The contribution was created in whole or in part by me and I have the right to submit it under the licence indicated in the file; or
The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate licence and I have the right under that licence to submit that work with modifications, whether created in whole or in part by me, under the same license (unless I am permitted to submit under a different licence), as indicated in the file; or
The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the licence(s) involved.