From my notes, and a bit as a funny as our cat is named Pip.
apt-get update && apt-get -y upgrade && apt-get install python-pip && pip install --upgrade pip
Failed and working projects, notes etc.
From my notes, and a bit as a funny as our cat is named Pip.
apt-get update && apt-get -y upgrade && apt-get install python-pip && pip install --upgrade pip
sudo systemctl set-default multi-user.target
sudo systemctl set-default graphical.target
sudo systemctl isolate multi-user.target
sudo systemctl isolate graphical.target
Starting a virtual terminal: Press Ctrl+Alt+F2
To return: Press Ctrl+Alt+F1 or Ctrl+Alt+F7
For the old version, click here.
So a new release came out and it is important to get this update as soon as possible! This manual is a transcript of the way that I have updated my Mastodon instance. Please make sure you make proper backups and use your brain while updating things
Linux flavour: Debian
Update from: 4.2.X
su - mastodon
cd /home/mastodon/live
git fetch --tags
git checkout [type the most recent version here, starting with the letter v. For example; v4.2.5 git checkout v4.2.5
If you get a ruby version error, please see bottom of this article for a fix! bundle install
yarn install
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=production bundle exec rails assets:precompile
exit
Okay, you can not choose to either reboot or restart the services.
REBOOT:
This command may vary, depending on your Linux flavour. systemctl reboot
RESTART:
This command may vary, depending on your Linux flavour. systemctl restart mastodon-sidekiq systemctl reload mastodon-web Optional: systemctl restart mastodon-streaming
My system was unable to find the required v3.2.3 of Ruby and I have fixed this by doing the following steps:
Please make sure that your path is correct. git -C ~/.rbenv/plugins/ruby-build pull
rbenv install 3.2.3 *WAIT TILL DONE* (it may take a little while)
To check all the installed versions type: rbenv versions
To set v3.2.3 as the global version, type: rbenv global 3.2.3
To double-check the active, installed version, type: rbenv versions
This manual is a transcript of the way that I have updated my Mastodon instance. Please make sure you make proper backups and use your brain while updating things.
Sources: https://richstone.io/where-is-ruby-3-0-0-on-rbenv/
Original post: https://3xn.nl/projects/2023/09/20/crude-solution-to-ban-bots-by-their-user-agent/
I’ve very much simplified the script that instantly redirects unwanted traffic away from the server. Currently, I am using a very cheap VPS to receive all that traffic.
Here ya go:
<?php // CC-BY-NC (2023) // Author: FoxSan - fox@cytag.nl // This is a functional but dirty hack to block bots, spiders and indexers by looking at the HTTP USER AGENT. // Traffic that meets the conditions is being yeeted away to any place of your choice. ////////////////////////////////////////////////////////////// // Emergency bypass // goto end; ////////////////////////////////////////////////////////////// // attempt to basically just yeet all bots to another website $targetURL = "https://DOMAIN.TLD/SUB/"; // Function to check if the user agent appears to be a bot or spider function isBot() { $user_agent = $_SERVER['HTTP_USER_AGENT']; $bot_keywords = ['bytespider', 'amazonbot', 'MJ12bot', 'YandexBot', 'SemrushBot', 'dotbot', 'AspiegelBot', 'DataForSeoBot', 'DotBot', 'Pinterestbot', 'PetalBot', 'HeadlessChrome', 'GPTBot', 'Sogou', 'ALittle Client', 'fidget-spinner-bot', 'intelx.io_bot', 'Mediatoolkitbot', 'BLEXBot', 'AhrefsBot']; foreach ($bot_keywords as $keyword) { if (stripos($user_agent, $keyword) !== false) { return true; } } return false; } // Check if the visitor is a bot or spider if (isBot()) { // yeet header("Location: $targetURL"); // Exit to prevent further processing exit; } end: // If the visitor is not a bot, spider, or crawler, continue with your website code. ////////////////////////////////////////////////////////////////////// ?>
I have installed CloudPanel and the new website caused a “Too many redirects” bug. This is because my SSL certificates are controlled by a proxy and this can cause some confusion between the systems. Also, because CloudPanel installs its own certificates.
This application can also install a Let’s Encrypt certificate, but this works only in more conventional systems. Mine is going through a DNS to a Proxy that listens to a certain IP address and that proxy redirects the request to a Virtual Machine on one of my servers.
So, here is my, probably unconventional method of disabling the SSL certificates on my CloudPanel installation:
server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; {{ssl_certificate_key}} {{ssl_certificate}} server_name subdomain.3xn.nl; {{root}} {{nginx_access_log}} {{nginx_error_log}} if ($scheme != "https") { rewrite ^ https://$host$uri permanent; }
server { listen 80; listen [::]:80; # listen 443 ssl http2; # listen [::]:443 ssl http2; # {{ssl_certificate_key}} # {{ssl_certificate}} server_name subdomain.3xn.nl; {{root}} {{nginx_access_log}} {{nginx_error_log}} # if ($scheme != "https") { # rewrite ^ https://$host$uri permanent; # }
Done! Your website should now say “Hello world :-)”
You can see that I have disabled the listen to port 443, the certificate keys, the forced https and the path to the keys. I chose to switch off the forced HTTP, because my proxy is already taking care of that.
This post is subject to change, but this helps you along your way!
EXPIRED: NEW GUIDE AVAILABLE HERE
Updating Mastodon and creating backups are important steps to ensure the security and stability of your instance. Here’s a comprehensive tutorial on how to update Mastodon, including making backups of the database and assets:
Note 1: Always perform updates on a test/staging instance before applying them to your live instance. This tutorial assumes you have some basic command line and server administration knowledge.
Note 2: If you made alterations to your files and want to update to a new branch, like v4.2.0, don’t forget to stash your files first. DO THIS AT YOUR OWN RISK.
cd /home/mastodon/live
git stash
You will not have an error message any more when entering:
I currently do not know how to put the stashed files back, this will be found out later.
git checkout v4.2.0
Note 3: If you switch to a new branch and version, like 4.2.0, you might run into an error stating the following:
rbenv: version '3.2.2' is not installed (set by /home/mastodon/live/.ruby-version)
Take the following steps to solve this problem:
(Type the version you need where it says x.x.x)
rbenv install x.x.x
If that fails, try the following command:
brew update && brew upgrade ruby-build
Followed by:
(Type the version you need where it says x.x.x)
rbenv install x.x.x
OPTIONAL: If bundler or rails fails to work, try the following commands:
gem install bundler gem install rails
Click here for the backup steps. It basically comes down to a Database dump, a settings file backup and a Redis dump. If you wish to backup your assets like images and stuff (User-uploaded files), backup the folder named “public/system”. Keep in mind that this folder can be rather large. Actually, it can become rather massive.
You can always check the folder size by using NCDU, for which you can find the manual here. Also, installations may vary, but this is an example of my instance.
Upgrade procedure.
su - mastodon
cd /home/mastodon/live
git fetch --tags
git checkout [type the most recent version here, starting with the letter v. For example; v4.0.1 Command example: git checkout v4.0.1
bundle install
yarn install
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=production bundle exec rails assets:precompile
exit
reboot now
And that should be it!
If you don’t want to restart your server, use the following commands instead of “reboot now”:
exit
systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
The reload operation is a zero-downtime restart, also called a “phased restart”. As such, Mastodon upgrades usually do not require any advance notice to users about planned downtime. In rare cases, you can use the restart operation instead, but there will be a (short) felt interruption of service for your users.
systemctl restart mastodon-streaming
Done!
PS: When I updated my instance from 4.1.9 to 4.2.0, a lot of warnings flew by, and this is, in my experience, not a problem as the instance is working perfectly.
A handy tool to look up directory sizes is NCDU.
It should be in the standard repository, so:
If you now go into a folder (or the root) and type NCDU, the tool will then start calculating the size of the available folders.
I was in need of a server solution that could be quickly deployed as a VM.
ip a
su
log in as root
apt-get update && apt-get install -y sudo
usermod -aG sudo USER
exit
exit
log back in as USER
sudo apt-get update && sudo apt-get upgrade -y
Now we want some essentials
sudo apt-get install -y dirmngr gnupg2 nano wget gpg curl fail2ban ufw software-properties-common
Preparing the PHP install
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update
sudo apt-get install -y php7.4 libapache2-mod-php7.4 php7.4-mysql php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-xmlrpc php7.4-zip
And restart the Apache2 Webserver
sudo systemctl restart apache2
sudo nano /var/www/html/test.php
Enter this into the php file and press Control X and type Y to save and exit.
<?php // Show all PHP information phpinfo(); ?>
HTTP://IP ADDRESS/test.php
If you see a PHP page with all sorts of data, you’re good. If not, go fix. Don’t ask me, I’m not there yet!
Log in:
mysql -u root -p
Create a user:
create user 'newuser'@'localhost' IDENTIFIED BY 'password';
Give them all the power:
grant all privileges on * . * TO 'newuser'@'localhost';
Reload privileges:
flush privileges;
Ditch a user: (Optional)
drop user 'newuser'@'localhost';
Log out:
\q
—————-
Log in:
mysql -u newuser -p
Create a database for the user:
create database db_name;
List databases: (Optional)
show databases;
Ditch database: (Optional)
drop database db_name;
Log out:
\q
Done.
Super annoying when you get locked out, innit?
It depends a bit how you have installed NextCloud but here are two possible locations for your config file:
/var/www/htdocs/nextcloud/config/config.php ("regular" apache install) /config/www/nextcloud/config/config.php (when using a Docker install)
Open the config.php file and look for
'maintenance' => true,
And change this to
'maintenance' => false,
Done.