Skip to content

Instantly share code, notes, and snippets.

@deemru
Last active March 28, 2024 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deemru/de167671b4be73cc65505a16fb01bc79 to your computer and use it in GitHub Desktop.
Save deemru/de167671b4be73cc65505a16fb01bc79 to your computer and use it in GitHub Desktop.
Setup w8io Web Server

Setup w8io Web Server

Never copy and paste commands that you do not understand or that were given to you by unknown people. This can be dangerous for your system, your security and your privacy. You can accidentally delete important files, get infected by a virus, give access to your data or do other unwanted actions. Always check and learn the commands before running them and use reliable sources of information.

Prerequisites

  • Debian (or similar OS)
  • Login as root

Install Software

One-liner:

apt update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoremove -f -y && apt-get autoclean -y && \
apt install net-tools curl sudo wget git sqlite3 unzip -y && \
sudo apt -y install lsb-release apt-transport-https ca-certificates && \
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list && 
apt update && \
apt purge apache* && \
apt purge php* && \
export PHP_VERSION=8.3 && \
apt install php${PHP_VERSION} php${PHP_VERSION}-fpm php${PHP_VERSION}-opcache php${PHP_VERSION}-zip php${PHP_VERSION}-sqlite3 php${PHP_VERSION}-gmp php${PHP_VERSION}-xml php${PHP_VERSION}-mbstring php${PHP_VERSION}-gd php${PHP_VERSION}-curl -y \
&& \
\
echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | debconf-set-selections && \
apt install unattended-upgrades -y \
&& \
\
export CADDY_VERSION=2.7.6 && \
wget https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.deb && \
dpkg -i caddy_${CADDY_VERSION}_linux_amd64.deb && \
unlink caddy_${CADDY_VERSION}_linux_amd64.deb && \
caddy version; \
php -v

Install composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"

Setup caddyfile

nano /etc/caddy/Caddyfile
http://:80 {
    root * /www/w8io
    php_fastcgi unix//run/php/php8.3-fpm.sock
    route {
        file_server /static/*
        rewrite * /index.php
    }
}

Setup php-fpm

nano /etc/php/8.3/fpm/pool.d/www.conf
  • search for "owner" with Ctrl + W and replace with "caddy:caddy"
  • (optionally) add more pm.max_children for example pm.max_children = 16 (i use for w8.io)

PHP and Caddy ready

service php8.3-fpm restart && service caddy restart

Setup w8io

Create working dir and activate login for www-data

mkdir /www && \
chown -R www-data:www-data /www
chsh -s /bin/bash www-data

Login as www-data

su - www-data

Setup w8io repo

cd /www && \
git clone https://github.com/deemru/w8io.git && \
cd /www/w8io && \
COMPOSER_CACHE_DIR=/dev/null composer update -o

Update config.sample.php

cp config.sample.php config.php
nano config.php
  • change W8IO_NETWORK (default: W)
  • change W8IO_NODES (default: http://127.0.0.1:6869 and https://nodes.wavesexplorer.com)
  • change W8IO_MAX_UPDATE_BATCH to 10..50 if your node is local (default: 1)

Running php w8_updater.php

  • You should run php w8_updater.php command a few times
  • Or you can run bash updater.sh to do it for you
  • You should reach updater status for w8_updater to be able to browse your data
  • Beware it can take A LOT of time to fully index your blockchain (mainnet 3-5 days with local node)

Logout back to root

logout

Setup cron

nano /etc/crontab
@reboot www-data nohup bash /www/w8io/updater.sh > /www/w8io/var/db/updater.sh.log &
@reboot www-data nohup bash /www/w8io/updater_headers.sh > /www/w8io/var/db/updater_headers.sh.log &

Problems

If you feel you messed up with permissions you can always do as root:

chown -R www-data:www-data /www
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment