Server transfer documentation

From titipi
Revision as of 11:22, 10 January 2024 by Angeliki (talk | contribs) (Created page with "This is a rough documentation of the server migration of TiTIPI that took place in December 2023. Please read carefully the urls with the official guides for migrating a server. Each case differs. == Create a Virtual Private Server (VPS) in Greenhost == Order a VPS in Greenhost and create an account. You will be asked to pay a small amount less than a euro. When you access the Service Center with your account create a new VPS. Then you will receive an invoice to pay th...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a rough documentation of the server migration of TiTIPI that took place in December 2023. Please read carefully the urls with the official guides for migrating a server. Each case differs.

Create a Virtual Private Server (VPS) in Greenhost

Order a VPS in Greenhost and create an account. You will be asked to pay a small amount less than a euro. When you access the Service Center with your account create a new VPS. Then you will receive an invoice to pay the actual amount.

Ubuntu vs Debian

We choose Debian because of these reasons (ref: https://itsfoss.com/debian-vs-ubuntu/):

Debian is older and more stable. Debian’s focus on stability means that it does not always aim for the latest versions of the software. It supports both 32-bit and 64-bit architecture and focuses primarily on FOSS (free and open source software). This means that the kernel provided by Debian does not include proprietary drivers and firmware. Debian is a true community project. The long-term support and reliability of Debian's stable release make the distro a preferred option for servers that require uninterrupted, surprise-free operation. Debian's package manager (the Advanced Package Tool, or APT for short) simplifies software installations and updates.

Ubuntu is based on Debian. It has PPA (Personal Package Archive). With PPA, installing newer software or getting the latest software version becomes a bit easier and it is a lot more forgiving when it comes to including proprietary drivers and firmware in the default ISO. Ubuntu is backed by Canonical. However, it is not entirely a corporate project. It does have a community but the final decision on any matter is in Canonical’s hands.

New VPS in Greenhost

We added the ssh key of Femke's laptop in order to create a root user (doesn't have password). With this user we create new users and add them to the sudoers file.

Add users:

$ useradd -m helen -s /bin/bash or adduser helen (both of these commands create a home directory and load the bash features on the user)

$ passwd helen

$ adduser helen sudo

Install tmux to share terminal sessions $ sudo apt install tmux

Install Apache2

How to: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-debian-11

$ apt update

$ apt install apache2

$ apt install ufw

$ ufw app list

$ ufw allow OpenSSH

$ ufw allow 'WWW'

$ ufw enable

$ ufw status

$ systemctl status apache2

$ hostname -I

Configure apache for domain titipi.org:

$ cd /var/www/

$ mkdir titipi.org

$ mkdir titipi.org/log

$ chmod -R 755 /var/www/titipi.org/

$ nano titipi.org/index.html

$ nano /etc/apache2/sites-available/titipi.org.conf

$ a2ensite titipi.org.conf

$ systemctl reload apache2

Disable default domain apache configuration

$ a2dissite 000-default.conf

$ systemctl reload apache2

$ apache2ctl configtest

$ systemctl restart apache2

Access logs

Reduce the size of the domain logs automatically:

Install logrotate: https://linux.die.net/man/8/logrotate

$ apt-get install logrotate

$ nano /etc/logrotate.d/apache2.conf

/var/log/apache2/* {
    weekly
    rotate 3
    size 10M
    compress
    delaycompress
}

/var/www/titipi.org/log/* {
    daily
    rotate 3
    size 10M
    compress
    delaycompress
}

/var/www/ddivision.xyz/log/* {
    daily
    rotate 3
    size 10M
    compress
    delaycompress
}

$ logrotate -d /etc/logrotate.d/apache2.conf

$ nano /var/log/apache2/access.log

$ nano /etc/apache2/sites-available/titipi.org.conf

$ mkdir log

$ systemctl reload apache2

Install and migrate MediaWiki

How to move a mediawiki: https://www.mediawiki.org/wiki/Manual:Moving_a_wiki

MediaWiki version of old server (Linode)

    Version: https://titipi.org/wiki/index.php/Special:Version  
    MediaWiki 1.35.1   
    PHP 7.4.21 (apache2handler)  
    MySQL 5.7.34-0ubuntu0.18.04.1  

How to: https://www.mediawiki.org/wiki/Manual:Moving_a_wiki

Steps

  1. Install the latest mediawiki version on the new server https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki and https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu#Get_latest_MediaWiki
  2. Set up database for new mediawiki on the new server https://www.mediawiki.org/wiki/Manual:MariaDB/en (We choose MariaDB because MySql uses proprietary source code)
  3. Install wiki-to-pdf on new server (see #wiki-to-pdf)
  4. Make a backup of the wiki on the old server (more in detail: https://sharkysoft.com/wiki/how_to_move_a_MediaWiki_wiki_from_one_server_to_another.html)
  5. upgrade the MediaWiki on the old server
  6. mysqldump + xml dump old wiki (backup again)
  7. Transfer backups from the old server to the new one
  8. Restore the backup on the new server

Prepare the ground on the new server and download MediaWiki:

$ apt upgrade

$ apt update

$ apt-get install php php-mysql libapache2-mod-php php-xml php-mbstring

$ apt-get install mariadb-server

$ apt-get install imagemagick

$ systemctl reload apache2

$ cd /tmp/

$ wget https://releases.wikimedia.org/mediawiki/1.40/mediawiki-1.40.1.tar.gz

$ apt-get install wget

$ tar -xvzf mediawiki-1.40.1.tar.gz

$ mkdir /var/www/titipi.org/wiki

$ mv mediawiki-1.40.1/* /var/www/titipi.org/wiki/

Install requirements:

$ apt install php-intl

$ systemctl reload apache2

$ apt-get install php-apcu inkscape php-gd php-cli php-curl php-bcmath git

$ systemctl reload apache2

Set up database. Check here: https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki

$ mariadb -u root -p -h localhost

$ cp /home/femke/LocalSettings.php /var/www/titipi.org/wiki/

$ ls /var/www/titipi.org/wiki/

database info old server (Linode)

    $wgDBname = "new_wiki";

    $wgDBuser = "admin";

    $wgDBpassword = "bugreport";

Back up the wiki on the old server

How to back up a MediaWiki: https://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki

$ cd /var/www/html/titipi.org/backups/

$ mysqldump -u admin -pbugreport new_wiki -c > wikidb.sql

$ tar czvf images.tgz images/

$ mv images.tgz ../../backups/

$ cd ../../ $ cd backups/

$ mysqldump -u admin -pbugreport new_wiki --xml > wiki.xml

Upgrade mediawiki in old server

How to upgrade a MediaWiki: https://www.mediawiki.org/wiki/Manual:Upgrading

new server (Greenhost):
MediaWiki    1.40.1
PHP    8.2.7 (apache2handler)
ICU    72.1
MariaDB    10.11.4-MariaDB-1~deb12u1

Old server (Linode):
MediaWiki     1.35.1
PHP     7.4.21 (apache2handler)
MySQL     5.7.34-0ubuntu0.18.04.1

$ sudo tmux attach -t webserver

check storage space, which files take more space:

$ du -h -d 1 .

$ df

$ df -h

let's vacuum it!

$ journalctl --vacuum-size=100M

$ apt clean

Python wants us to have virtual environments but we go for installing through Debian packages. We tried but it was very complex. We continued with a virtual environment.

[SCREENSHOT FROM THAT]


Install Wiki-to-pdf

Don't forget to copy the pub/ folder in the new server (it includes the publications from the old server)

How to: https://titipi.org/wiki/index.php/Wiki-to-pdf-manual and https://gitlab.constantvzw.org/titipi/wiki-to-pdf

Install Pico

Install pico and check: https://picocms.org/download/

$ tar --exclude='public_html/wiki' --exclude='public_html/wiki-to-pdf' --exclude='public_html/wiki-to-pdf-webhook.php' -zcvf backups/site.tgz public_html/

Check the php modules dom and mbstring installed for pico to run

$ php -m

From /titipi.org we update pico

$ rm -r vendor/

$ wget https://github.com/picocms/Pico/releases/download/v3.0.0-alpha.2/pico-release-v3.0.0-alpha.2.tar.gz $ tar -xvzf pico-release-v3.0.0-alpha.2.tar.gz

$ rm pico-release-v3.0.0-alpha.2.tar.gz

With filezilla we replaced: themes/default/css/ and themes/default/index.twig

Femke had to make her user the owner to have access to the /var content: $ chown -R femke:femke /var/www/titipi.org/

Make ssh key in Greenhost for git clone the wiki-to-pdf.

We create a user for managing access to the world such as git called 'expert'.

Domain transfer

Login to the domain provider (Gandi) to change DNS for the domain we want.

Replace old IPv4 address with the new one from Greenhost.

Make a directory for domain ddivision.xyz:

$ cd /var/www/

$ mkdir ddivision.xyz

$ mkdir ddivision.xyz/log

$ chmod -R 755 /var/www/ddivision.xyz/

$ nano /etc/apache2/sites-available/ddivision.xyz.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName ddivision.xyz
    ServerAlias 37.218.240.79
    DirectoryIndex index.html index.php
    DocumentRoot /var/www/ddivision.xyz
    ErrorLog /var/www/ddivision.xyz/log/error.log
    CustomLog /var/www/ddivision.xyz/log/access.log combined

</VirtualHost>

$ a2ensite ddivision.xyz.conf

$ systemctl restart apache2

Install and configure Certbot

How to: https://certbot.eff.org/instructions and https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-debian-11

In Gandi create web forward for http://www.your_domain to http://your_domain