Follow this guide for builds on the supported Operating Systems:
yum
-based upstreamQ: "Do I need an Nvidia GPU for native crypto? What about MacOS brew installs?"
A: Recommending make or acquire a refurbished machine made from recycled parts instead. Teach rebuild from existing mfg'd materials like a real hacker. ClearLinux* OS w/a long-life Intel CPU is the only truly ecological, low-cost option for Ecosteading natives seeking encrypted currency appreciations.
A: The ultra-expensive Nvidia and the ultra-expensive Apple machines are not supported by Ecosteaders. Recommend is you stop funding genocide and think local instead. Where can you find old hardware, not freshly-mined metals?
This guide is a work-in-progress, but contains lines of code that will help you break free from insane dudes. Can be modified to build any of the following Ruby on Rails use cases:
RAILS_ENV=production RAILS_ENV=development RAILS_ENV=test
ssh -o AddKeysToAgent=yes ecosteader@your.mastodon.host
once you have configured the non-root user.From your local recycled parts computer:
ssh root@your-debian12-ipaddress
Once logged in, build postgres as the machine's root user:
:~# sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' :~# apt install gnupg2 apt-transport-https libpq-dev -y :~# echo "deb [signed-by=/usr/share/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list :~# apt install postgresql-15
Test out your postgres by moving to /var/lib/postgresql
directory and entering the command: sudo -u posgres psql
/var/lib/postgresql$ sudo -u postgres psql psql (15.6 (Debian 15.6-0+deb12u1)) Type "help" for help.
Once you have done this, create your primary SABRETOOTH'D MASTODON server database admin and database; name them whatever you want or re-use the same from a server migration:
postgres=# CREATE USER mastodon; CREATE ROLE postgres=# CREATE DATABASE mastodon_production WITH OWNER mastodon; CREATE DATABASE
If you want to add password ALTER USER mastodon WITH PASSWORD 'password';
Always remember the semicolon at the end of your inputs and exit with backslash q: postgres=# \q
Now for the Apache and Nginx server's prerequisites.
:~# apt install apache2 autoconf bison build-essential certbot curl dh-exec g++ gcc gettext git-core libecpg-dev libecpg6 libedit libffi-dev libgdbm-dev libicu-dev libidn11-dev libjemalloc-dev libjpeg-dev libpng-dev libpq5 libreadline-dev libssl-dev libtiff-dev libwebp-dev libxslt1-dev libyaml-dev mawk net-tools nginx openssh-server pkg-config protobuf-compiler python3-certbot redis-server redis-tools wget zlib1g-dev
Make an account for your default non-root account user:
:~# adduser ecosteader :~# usermod -a -G sudo ecosteader - prompt will ask you to enter your desired password and other info :~# exit
Now you're logged out of the remote machine's root login; log back in with the account you just created.
Add your local ssh keys to the remote non-root account and login with your newly-created account:
$ ssh -o AddKeysToAgent=yes ecosteader@your-debian12-ipaddress
$ ssh ecosteader@your-debian12-ipaddr
Now you can test that the postgresql you installed as root is the same. Again, 'change directory' to
avoid permission-denied errors by typing:
$ cd /var/lib/postgresql/
Then login with sudo (sudo is not actually a Debian creation, but that is another discussion, entirely)
sudo -u postgres psql psql (15.6 (Debian 15.6-0+deb12u1)) Type "help" for help.
From here, you can try \l
to see your previously-created database user and database name.
Remember to set the postgresql user to authentication method of "trust"
or "peer"
if you opted for the
passwordless mastodon user like it recommended in the original tootsuite documentation. In Debian 12, this
file is under the "etc" directory for some reason: cd /etc/postgresql/15/main && nano pg_hba.conf
Build imagemagick
from source by ensuring that none of the default system packages are on your system. Probably
none are unless you are building or rebuilding on a non-default Linux or Debian. In any case you will need to
first remove apt or yum-based imagemagick libmagickcore-dev libmagickwand-dev
; one way to do this is:
$ sudo apt remove "*imagemagick*" --purge -y && apt autoremove --purge -y
.
Now copy this entire line and paste it into your non-user root terminal to run it; the script should install imagemagick and show you what it is doing the entire time.
t=$(mktemp) && wget 'https://dist.1-2.dev/imei.sh' -qO "$t" && bash "$t" && rm "$t"
Neat, eh?
Now we are adding NVM to install nodejs; nvm should make your life easier for future node versions and yarn updates:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
When that is done, query for and pull the latest nodejs numbered "long term support" versions
$ source ~/.bashrc
$ nvm ls-remote
Pick a version that the latest mastodon upstream recommends, or simply use the lts:
$ nvm install node
OR $ nvm install --lts
With nodejs installed we can now use (compared to previous build and install instructioned) the GREATLY SIMPLIFIED corepack method of yarn install:
$ corepack enable $ yarn set version classic
Debugging help: any errors in the above may require a removal of default system yarn; you can check as follows: and remove the
ls -al /usr/bin/yarn -rwxr-xr-x 1 root root 20734 Feb 23 2018 rm -rf /usr/bin/yarn
This section is for getting the Mastodon UI code for streaming
Advanced git users can use this first command: git clone git@github.com:ecosteader/mastodon.git
otherwise, the second command should suffice: git clone https://github.com/ecosteader/mastodon.git
$ cd mastodon $ git pull $ sudo cp ApacheConfigDocs/hosts.deny /etc/ $ cd /dist
Update the follwing files with your primary MASTODON db admin and mastodon_production configs, and copy them over to /etc/systemd/system
:
$ nano mastodon-web #edit this file to reflect the directory structure on your server $ nano mastodon-sidekiq #edit this file to reflect directory naming structure on your server $ nano mastodon-streaming #edit this to point to the right file under the right directory where you cloned ecosteader mastodon code $ nano mastodon-fallback #this file is on the nginx_fixes branch, can be updated by advanced users $ sudo cp /home/mastodon/dist/mastodon-*.service /etc/systemd/system $ sudo systemctl daemon-reload
Here we install ruby, gems, and the Rails infrastructure. Ruby is the language, gems are the libraries that can be managed via the command-line tool. Since libraries are often updated with many versions, rbenv helps code writers test integrations of code changes.
We first configure to let rbenv
manage your ruby builds:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Ruby-build works as both a plugin and standalone install; this example covers the first option:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build rbenv install -l
The rbenv install 3.0.6
takes awhile do not fret; also note that if you
previously installed any other versions of ruby, you must first run rbenv rehash
for the ruby interpreter to work without complaining. Try rbenv local
outside
your mastodon directory.
$ rbenv local rbenv: no local version configured for this directory rbenv global 3.2.3 cd mastodon rbenv install 3.0.6
To configure for rbenv to load automatically, add these three lines to the bottom of your ~.bashrc
file:
export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
Again, refresh with $source ~/.bashrc
and check everything worked by finding output of type rbenv
:
source ~/.bashrc type rbenv
Now run bundler
and install the production gems
$ gem install bundler $ bundle config deployment 'true' $ bundle config without 'development test' $ bundle install -j$(getconf _NPROCESSORS_ONLN)
This line builds the asset pipeline for this version of ruby
bundle exec rails assets:precompile RAILS_ENV=production NODE_OPTIONS="--openssl-legacy-provider"
Apache servers will function with less strain when you add the following mods w/sudo
$ sudo a2enmod ssl proxy proxy_http proxy_balancer lbmethod_byrequests headers $ sudo a2enmod socache_redis.load Enabling module socache_redis. $ systemctl restart apache2
NOTE that your "debian apache2` page should now be live on the www at the IP address your DigitalOcean or Linode or other webhost provided. Type it in the URL bar.
Start the database server, Postgresql service workers:
sudo systemctl start postgresql.service sudo systemctl enable postgresql.service sudo systemctl status postgresql.service
To move the database off the old machine:
$ pg_dump -Fc date_of_dump+mastodon_production -f backup.dump
Copy the backup.dump file over, move to /var/lib/postgresql
and create an empty database:
$ sudo createdb -T template0 mastodon_production
To unroll the database you copied over, one of these should work
$ sudo -u postgres pg_restore -U postgres -d mastodon_development -v /backups/backup_18Nov2023.dump $ pg_restore -Fc -U mastodon -n public --no-owner --role=mastodon -d mastodon_production backup.dump
After unrolled, the db still needs loaded and migrations need to run
$ bin/rails db:schema:load RAILS_ENV=development #may be needed depending on your configs $ bin/rails db:migrate RAILS_ENV=development $ systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming $ systemctl start mastodon-{web,sidekiq,streaming}.service $ systemctl daemon-reload # any time you edit system settings under /etc that would require a ruby on rails "Restart", this is the command to use
A useful rsync
command for backup from the migrating mastodon docs the Ecosteader admin co-authored, for moving all the files people uploaded to your site.
$ rsync -avz ~/live/public/system/ mastodon@example.com:~/live/public/system/
DO ALSO REMEMBER to get your .env.production
file backed up somewhere safe; default mastodon .gitignore
ensures it does not
accidentally get uploaded to the wrong place when you sync code.
$ sudo ufw allow Apache2 Secure # if you have previously enabled UFW firewall settings, this command will be needed $ sudo ufw allow Nginx # if you have previously enabled UFW firewall settings, this command will be needed
$ sudo apt install lynis $ sudo lynis audit system
systemctl stop mastodon-{web,sidekiq,streaming}.service dpkg -l | grep postgresql
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt update
sudo apt install postgresql-15 postgresql-client-15 postgresql-contrib-15
dpkg -l | grep postgresql
確認したら下記をしてクラスタを確認
pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file 9.5 main 5432 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log 10 main 5433 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
次にインストール先の 10 を止めて、PostgreSQL もとめてアップグレード開始
sudo pg_dropcluster 10 main --stop sudo service postgresql stop sudo pg_upgradecluster 9.5 main
終わったら再度確認 pg_lsclusters
すると 10 のほうがポートが 5432 になっているはず
Ver Cluster Port Status Owner Data directory Log file 9.5 main 5433 offline postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log 10 main 5432 offline postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
sudo service postgresql restart psql --version
sudo pg_dropcluster 9.5 main
systemctl restart mastodon-{web,sidekiq,streaming}.service