How I Move My server and upgrade it to Gnu-social

This is mostly so that I can remember how to move stuff. I’ll take moving my server as an example.

So in order to move you’ll have to have a dump of the database this can be accomplished with:

mysqldump -u statusnetuser -p databasename > databasename-da-te.sql

it is a good idea to run this command regularly after all having a backup strategy can save your bacon.

Next up will have to save your dir I usually tar it and then gunzip it. So:

tar -zcvf statusnet.tar.gz sn

Sn is my directory on my server and statusnet.tar.gz is the file it will be tar’ed in.

Next up is moving your certs if you have ssl enabled - they are where you put them :P

So on the new server you should have installed all the dependencys for You need to drop your certs where you want them and configure your subdomain in apache/nginx.

So in order to import the database into mysql/mariadb you’ll need to set it up in mysql:

mysql -u root -p

create database databasename;

GRANT ALL on databasename.* TO 'user'@'localhost' IDENTIFIED BY 'agoodpassword';

use databasename;

source database-da-te.sql; #this assumes you are in the directory where you extracted your database dump.

you can now extract your statusnet.tar.gz to where ever you want it on your system (I’m on arch so it goes into /usr/share/webapps/sn and remember to chwon it as the user you run with - for me that is http). Enable you sn instance in your apache config restart apache and bob is your uncle.

Now you might want to “upgrade” to gnusocial while you are moving you site anyway. Upgrading straight to the latest git pull doesn’t work for me so you’ll have to start with the 1.1.x branch

mkdir ~/Build

cd ~/Build

git clone -b 1.1.x gnusocial

So you now have the gnusocial branch 1.1.x in your homedir under Build/gnusocial.

sudo cp ~/Build/gnusocial /usr/share/webapps/sn

now you have a directory you can point your webserver to with gnusocial in but well need to put some stuff in there from your backup of

So lets assume you extracted your dir in ~/Build/sn

sudo cp ~/Build/sn/config.php /usr/share/webapps/sn

sudo cp ~/Build/sn/.htaccess /usr/share/webapps/sn

sudo cp -R ~/Build/sn/avatar /usr/share/webapps/sn

sudo cp -R ~/Build/sn/background /usr/share/webapps/sn

sudo cp -R ~/Build/sn/file /usr/share/webapps/sn

sudo cp -R ~/Build/sn/theme /usr/share/webapps/sn

so we now have all the files in the direcotry but we need to upgrade to gnusocial

sudo chown -R http:http /usr/share/webapps/sn

cd /usr/share/webapps/sn/scripts

sudo php upgrade.php

this should update stuff to gnu social. But we’re not on the latest branch and there are still a few things to remove as well

cd ~/build/gnusocial

git checkout -b master

    git branch --set-upstream-to=origin/master master

    git pull

Seems like some git versions are different so you if stuff fails try

git branch --set-upstream-to origin/master master

so we now have the latest branch in ~/Build/gnusocial. We’ll now want to move that to our gnusocial/ dir. But first we’ll back up the current dir

    cd /usr/share/webapps

    sudo mv sn bak-sn

    sudo cp -R ~/Build/gnusocial sn

    cd bak-sn

sudo cp ~/Build/sn/config.php /usr/share/webapps/sn

    sudo cp ~/Build/sn/.htaccess /usr/share/webapps/sn

    sudo cp -R ~/Build/sn/avatar /usr/share/webapps/sn

    sudo cp -R ~/Build/sn/background /usr/share/webapps/sn

    sudo cp -R ~/Build/sn/file /usr/share/webapps/sn

    sudo cp -R ~/Build/sn/theme /usr/share/webapps/sn

    cd /usr/share/webapps/sn

    sudo make

    sudo rm -rf install.php .git*

    cd ..

    sudo chown -R http:http sn

    cd sn/scripts

    sudo php upgrade.php

if you get some sort of error after running the upgrade.php script it could be that your /tmp isn’t large enought so you could thry this

# mount -t tmpfs -o remount,size=1G tmpfs /tmp

Remember to do that as root

so we have now moved from to gnusocial. time to enable the it on the webserver and start the quedaemons if you use those.

cd sn/scripts

sudo ./ #this should fork the daemon and run it as http

A small note to why I do stuff as sudo and am not logged in as root. In general I avoid being logged in as root and you can set a lot of restrictions on the sudo user.

Also I probably could have done this in a fewer steps if I had more git foo but I’m not there yet.

Written by Theru
Later article
Podcasts I listen to