2021-04-30 Gnu Social and Activitypub on Bullseye or Buster
How to install GNU Social and ActivityPub on Debian 10 or 11.
# Article is out of date
# I am no longer using GNU Social.
1 Intro
=======
GNU Social is a successor[1] to the StatusNet project. The latter, with
its then primary server identi.ca became one of the first widely-used
micro-blogging social media solutions available as open source,
somewhere between 2010 and 2013.
The Wikipedia entry on GNU Social is woefully out of date; the project
is once again under active development[2]. A team of developers at the
University of Porto, with financial support from the European
Commission, is adding lots of new energy into the project.
Their biggest achievement so far: GNU Social now includes
ActivityPub[3], a W3C standard for federation of messages across other
social media solutions.
After a lot of trial and error with several other open source
solutions offering ActivityPub federation, I find GNU Social is by far
the easiest to install.
2 Server host requirements
==========================
2.1 GNU Social
~~~~~~~~~~~~~~
To get ActivityPub you should use the master[4] version. Note: this
blog previously advised to use nightly. I've changed/updated this blog
on 22 December 2021.
,----
| wget https://notabug.org/diogo/gnu-social/archive/master.tar.gz
`----
and unpack it
,----
| tar zxf master.tar.gz
`----
which places the code in a directory /home/$user/gnus-social
Then, as root, move gnus-social it to /var/www/gnu-social and change
permissions:
,----
| chown -R www-data:www-data /var/www/gnu-social
`----
To work around an error, either check if these directories are there,
or else create them.
,----
| mkdir /var/www/gnu-social/file/
| mkdir /var/www/gnu-social/file/avatar
`----
2.2 Apache
~~~~~~~~~~
To prepare the Apache webserver, we configure a virtual host for GNU
Social. We also create a LetsEncrypt certificate for our host: below
we use host.example.org. We will give a hint on how to do the latter
but nothing more than that, and you should not use it like this.
As user root:
,----
| cd /etc/apache2/sites-available/
| cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/gnusocial.conf
`----
Edit the latter conf file to match your domain. A complete example of
a virtual host file is provided below. The first section will redirect
all HTTP traffic to HTTPS, all all the other settings go into the
second section.
The DocumentRoot and Directory lines are important: for some domains,
you'll have to include "/public", without the quote marks, and no
trailing /.
The Directory AllowOveride All is also crucial, to allow the .htaccess
file.
You should not forget to copy the sample httaccess file from GNU
Social to your *DocumentRoot*. Don't put it in the wrong directory by
mistake, because then GNU Social will be unable to find it.
In addition, when you copy this file as root, make sure it has the
same owner and group file permissions as the other files in your
Apache directory.
You must have mod rewrite, so check /etc/apache2/mods-enabled/. If it
is not listed:
,----
| a2enmod rewrite
`----
You can now add the GNU Social site:
,----
| a2ensite gnu-social
`----
Please make sure you have PHP enabled
,----
| a2enmod php7.3
`----
This will request
,----
| systemctl restart apache2
`----
Apache virtual host configuration *sample* file:
,----
|
| ServerName host.example.org
| Redirect "/" "https://host.example.org"
| LogLevel warn
|
|
|
|
|
| SSLEngine on
| ServerAdmin admin@example.org
| ServerName host.example.org
| DocumentRoot /var/www/gnu-social/public
|
|
| AllowOverride All
| Require all granted
| Order Deny,Allow
| Allow from all
|
|
| ErrorLog ${APACHE_LOG_DIR}/error.log
| CustomLog ${APACHE_LOG_DIR}/access.log combined
|
| SSLCertificateFile /etc/letsencrypt/live/example.org/fullchain.pem
| SSLCertificateKeyFile /etc/letsencrypt/live/example.org/privkey.pem
| Include /etc/letsencrypt/options-ssl-apache.conf
|
|
`----
2.2.1 LetsEncrypt
-----------------
Please make sure you have a valid HTTPS certificate for your domain.
The below is merely a sample, don't use this as it is.
,----
| certbot --expand-d example.org,host.example.org
`----
2.3 MariaDB
~~~~~~~~~~~
Ensure you have an up to date version of MariaDB. For some reason, a
recent Raspberry Pi OS installed mariadb-server-10.0 which will not
work with GNU Social. You want Mariadb-server-10.3 (on Buster) or
MariaDB 10.5 (on Bullseye).
Initialise the database, as root:
,----
| mysql -u root -p
| CREATE DATABASE gnusocial;
| CREATE USER gnusocial;
| GRANT ALL PRIVILEGES on gnusocial.* TO 'gnusocial'@'localhost' IDENTIFIED BY ****** ;
| FLUSH PRIVILEGES;
| EXIT
`----
2.4 PHP
~~~~~~~
You will need several PHP packages, but most importantly, you may not
have PHP-Pear installed. You may not have it installed it as a
dependency with other solutions. The GNU Social developers have
included their own Pear version, and if you mix this with Debian
PHP-Pear, GNU Social will not work.
Developers are planning to resolve this.
On Debian Buster and Bullseye, you'll need
,----
| php
| php-bcmath
| php-cli
| php-curl
| php-date
| php-gd
| php-gmp
| php-intl
| php-mbstring
| php-mysql
| php-net-url2
| php-stomp
| php-validate
`----
This will bring three additional packages
,----
| php-common
| php-json
| php-readline
`----
Then, you will want, depending on your version of PHP, either
php7.3-opcache or php7.4-opcache. You will also want:
libapache2-mod-php*VERSION*
2.5 *First run*
~~~~~~~~~~~~~~~
Now take a browser and go to
If all is well you see a message that you have not yet configured your
site and that you should use the install.php file.
You can also directly go to: your.domain.name/public/install.php
Fill in the the webform: this initialises the database, add a first
user to the project, and creates a config.php file.
When this is done, you are instructed to visit your GNU Social
instance at:
2.6 Themes
~~~~~~~~~~
To change the theme, read the GNU Social documentation. Quick example,
if you add
,----
| $config'site']['theme'] = 'neo-gnu';
`----
to your config.php file, you change the default theme to Neo-GNU,
which performs better on mobile devices.
2.7 Errors
~~~~~~~~~~
1) When I go to host.example.org, I see only a white screen.
Check the Apache Vhost, check your PHP installation.
1) I see PHP code all over the browser window:
Most probably you have Debian PHP-Pear installed. Please remove it.
1) I get "MDB syntax error"
Most likely that is because of an outdated version of Mariadb.
2.8 Upgrading
~~~~~~~~~~~~~
New Master?
Here is how to do upgrade GNU-Social if you do not use Git. First we
make a backup of the current instance, and then replace it with the
new version. We need to copy over config file, the .htaccess, and
avatar and thumbnails. (You can also copy over the logs, if you like.)
As $user, we do (like before):
,----
| wget https://notabug.org/diogo/gnu-social/archive/master.tar.gz
`----
and unpack it
,----
| tar zxf master.tar.gz
`----
As root:
,----
| cd /var/www/
| mv gnu-social gnu-social-$today
| cp -a /home/$user/gnu-social .
| cp -a gnu-social-$today/file/ gnu-social/file
| cp gnu-social-$today/config.php gnus-social/
| cp gnu-social-$today/public/.htaccess gnu-social/public/
| chown -R www-data:www-data gnu-social
`----
If everything checks out, you can move the backup (gnu-social-$today)
out of the way.
2.9 Debugging
~~~~~~~~~~~~~
You can try to debug GNU Social by adding one of these to the end of
your config.php
,----
| $config'site']['logdebug'] = true;
| $config'site']['logfile'] = '/var/www/gnu-social/gnusocial-debug.log'
`----
Here are two more debug settings to experiment with. Make sure you
have backups, and be aware that you could be showing passwords on the
site.
,----
| $config'db']['debug'[8] = 3 ; # spits out everything on the web page
| # including passwords
| $config[9]: = 1 ; # is less verbose, but is useful here.
`----
2.10 Relevant links
~~~~~~~~~~~~~~~~~~~
This text is based in information on several other websites. I started
with:
https://notabug.org/diogo/gnu-social/
and:
https://vorkbaard.nl/install-gnu-social-on-debian-8/
The mailing list is not super active (yet!), I'm told users should
also try to contact the project on IRC (#GNU Social at libera.chat).
https://lists.gnu.org/mailman/listinfo/social-discuss
The unofficial GNU Social manual here is, of course, also helpful:
http://thomask.sdf.org/social/en/user/getting_started.html
And this is the new home for GNU Social:
https://gnusocial.rocks/
[1]: https://en.wikipedia.org/wiki/GNU_social
[2]: https://nlnet.nl/project/GNUSocial/
[3]: https://en.wikipedia.org/wiki/ActivityPub
[4]: https://notabug.org/diogo/gnu-social/src/master