servers:linux:nginx:friendica
This is an old revision of the document!
Table of Contents
Information
Resources
Prerequisites
Dependencies
sudo apt install composer php-curl php-gd php-gmp php-mbstring php-intl php-mysql php-zip
Download Source
sudo git clone --branch 'develop' --depth '1' --recurse-submodules 'https://github.com/friendica/friendica.git' '/var/www/social' && sudo chown -R 'www-data':'www-data' '/var/www/social' && sudo chmod -R '0755' '/var/www/social'
Addons
Required for
composer installeven without any addons enabled
sudo git clone --branch 'develop' --depth '1' --recurse-submodules 'https://github.com/friendica/friendica-addons.git' '/var/www/social/addon' && sudo chown -R 'www-data':'www-data' '/var/www/social/addon' && sudo chmod -R '0755' '/var/www/social/addon'
Environment
Composer
sudo su 'www-data' -s '/bin/bash'
cd '/tmp' && '/usr/bin/composer' --working-dir='/var/www/social' --no-cache install --no-dev
exit
php-json-ld Fix
- 2025/12/22:
git.friendi.carequires authentication and fails duringcomposer install
nano '/var/www/social/composer.lock'
"url": "https://github.com/digitalbazaar/php-json-ld.git",
"reference": "fe18c3f2ce47f30ace904ef58e7416f933be25e1"
friendica/json-ld
"name": "friendica/json-ld",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/digitalbazaar/php-json-ld.git",
"reference": "fe18c3f2ce47f30ace904ef58e7416f933be25e1"
},
sed Test
sudo su 'www-data' -s '/bin/bash'
sed -i 's|https://git.friendi.ca/friendica/php-json-ld|https://github.com/digitalbazaar/php-json-ld.git|g' '/var/www/social/composer.lock'
sed -i 's/1f33c8766b5cfbecfbc2122238873debeed35fb6/fe18c3f2ce47f30ace904ef58e7416f933be25e1/g' '/var/www/social/composer.lock'
Database
sudo mariadb
CREATE DATABASE friendica;
CREATE USER 'friendica'@'localhost' IDENTIFIED BY 'x';
GRANT ALL PRIVILEGES ON friendica.* to 'friendica'@'localhost';
FLUSH PRIVILEGES;EXIT;
nginx + PHP-FPM Configuration
PHP-FPM Socket
sudo -e '/etc/php/8.4/fpm/pool.d/social.conf' && sudo systemctl restart 'php8.4-fpm'
[social] ; User/Group user = "www-data" group = "www-data" ; Socket listen = "/run/php/social.sock" listen.owner = "www-data" listen.group = "www-data" listen.mode = "0662" ; Process Management pm = "ondemand" pm.max_children = "4" pm.process_idle_timeout = "30" ; Logging php_value[log_errors] = "0" php_value[error_reporting] = "~E_ALL" ; General php_value[date.timezone] = "America/New_York" ; Friendica php_value[max_execution_time] = "200" php_value[memory_limit] = "512M" php_value[post_max_size] = "10M" php_value[upload_max_filesize] = "10M" php_value[max_file_uploads] = "100" php_value[register_argc_argv] = "On" ; End
FastCGI
sudo -e '/etc/nginx/snippets/social.conf'
location '~' '\.(php|phar)(/.*)?$' {
fastcgi_split_path_info '^(.+\.(?:php|phar))(/.*)$';
fastcgi_intercept_errors 'on';
fastcgi_index 'index.php';
include 'fastcgi_params';
fastcgi_param 'SCRIPT_FILENAME' '$document_root$fastcgi_script_name';
fastcgi_param 'PATH_INFO' '$fastcgi_path_info';
fastcgi_param 'HTTPS' 'on';
fastcgi_pass 'unix:/run/php/social.sock';
}
# End
Server Block
sudo -e '/etc/nginx/sites-available/social.conf'
server {
listen '443' 'ssl';
http2 'on';
server_name 'social.realmofespionage.xyz';
root '/var/www/social';
index 'index.php';
include '/etc/nginx/snippets/social.conf';
include '/etc/nginx/snippets/headers.conf';
client_max_body_size '10M';
# access_log '/var/log/nginx/social-access.log';
# error_log '/var/log/nginx/social-error.log';
location '/' {
try_files '$uri' '/index.php?pagename=$uri&$args';
}
location '^~' '/.well-known/' {
allow 'all';
rewrite '^' '/index.php?pagename=$uri';
}
location '~*' '\.(tpl|md|tgz|log|out)$' {
deny 'all';
}
location '~' '/\.' {
deny 'all';
}
}
# End
sudo ln -s -f '/etc/nginx/sites-available/social.conf' '/etc/nginx/sites-enabled/social.conf' && sudo systemctl reload 'nginx'
Initial Setup
Initialize
Change
--dbpass, and--adminto email
sudo su 'www-data' -s '/bin/bash'
cd '/var/www/social' && '/var/www/social/bin/console' autoinstall --dbhost 'localhost' --dbport '3365' --dbdata 'friendica' --dbuser 'friendica' --url 'https://social.realmofespionage.xyz' --basepath '/var/www/social' --dbpass 'x' --admin 'x'
Account Create
Be sure the email matches what was used on the above command
User
xis the nickname chosen at website registration
sudo su 'www-data' -s '/bin/bash'
cd '/var/www/social' && '/var/www/social/bin/console' user password 'x'
Disable Registration
sudo su 'www-data' -s '/bin/bash'
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' config 'config' 'register_policy' '0'
Etc
sudo su 'www-data' -s '/bin/bash'
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' worker
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' dbstructure update --force
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' dbstructure drop --execute
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' postupdate
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' cache clear
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' clearavatarcache
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' config 'config' 'info' 'https://wiki.realmofespionage.xyz/servers:linux:nginx:friendica'
exit
Settings
frio Theme
- Navigation bar background color:
3d8bff - Navigation bar icon color:
ffffff - Link color:
3d8bff - Set the background color:
dedede - Login page background color:
484848
- Copy or paste schemestring:
{"nav_bg":"#3d8bff","nav_icon_color":"#ffffff","link_color":"#3d8bff","background_color":"#dedede","background_image":"","contentbg_transp":"100","login_bg_image":"","login_bg_color":"#484848"}
local.config.php
Change database
passwordand configadmin_email
sudo -u 'www-data' -e '/var/www/social/config/local.config.php'
<?php
return [
'database' => [
'hostname' => 'localhost',
'username' => 'friendica',
'password' => 'x',
'database' => 'friendica',
'charset' => 'utf8mb4',
],
'config' => [
'php_path' => '/usr/bin/php',
'admin_email' => 'espionage724@x',
'sitename' => 'RoE | Social',
'register_policy' => \Friendica\Module\Register::CLOSED,
'max_import_size' => 200000,
],
'system' => [
'url' => 'https://social.realmofespionage.xyz',
'basepath' => '/var/www/social',
'default_timezone' => 'America/New_York',
'language' => 'en',
],
];
// End
Scripts
Git Fix
Set email for both
user.email
sudo mkdir -p '/etc/nginx/scripts/social' && sudo -e '/etc/nginx/scripts/social/git-fix.sh' && sudo chmod '0500' '/etc/nginx/scripts/social/git-fix.sh' && sudo chown 'www-data':'www-data' '/etc/nginx/scripts/social/git-fix.sh'
#!/bin/bash cd '/tmp' '/usr/bin/rm' -Rf '/var/www/social/.git' '/usr/bin/git' -C '/var/www/social' init --initial-branch='develop' '/usr/bin/git' -C '/var/www/social' add '.' ######################################## '/usr/bin/git' -C '/var/www/social' config 'user.email' 'espionage724@x' ######################################## '/usr/bin/git' -C '/var/www/social' commit --message='x' '/usr/bin/git' -C '/var/www/social' remote add 'origin' 'https://github.com/friendica/friendica.git' '/usr/bin/git' -C '/var/www/social' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase '/usr/bin/git' -C '/var/www/social' reset --hard 'origin/develop' '/usr/bin/git' -C '/var/www/social' gc --aggressive --prune='all' '/usr/bin/git' -C '/var/www/social' fsck --full --strict '/usr/bin/rm' -Rf '/var/www/social/addon/.git' '/usr/bin/git' -C '/var/www/social/addon' init --initial-branch='develop' '/usr/bin/git' -C '/var/www/social/addon' add '.' ######################################## '/usr/bin/git' -C '/var/www/social/addon' config 'user.email' 'espionage724@x' ######################################## '/usr/bin/git' -C '/var/www/social/addon' commit --message='x' '/usr/bin/git' -C '/var/www/social/addon' remote add 'origin' 'https://github.com/friendica/friendica-addons.git' '/usr/bin/git' -C '/var/www/social/addon' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase '/usr/bin/git' -C '/var/www/social/addon' reset --hard 'origin/develop' '/usr/bin/git' -C '/var/www/social/addon' gc --aggressive --prune='all' '/usr/bin/git' -C '/var/www/social/addon' fsck --full --strict # End
sudo -u 'www-data' '/etc/nginx/scripts/social/git-fix.sh'
Services
Worker
Service
sudo -e '/etc/systemd/system/social-d.service'
[Service] User=www-data Group=www-data Type=oneshot WorkingDirectory=/var/www/social ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' worker # End
Timer
- Every 10 minutes
sudo -e '/etc/systemd/system/social-d.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-d.timer' --now && sudo systemctl start 'social-d' && sudo systemctl status 'social-d' -l
[Unit] Description=Friendica Worker Daemon After=network-online.target Wants=network-online.target [Timer] OnBootSec=10m OnUnitActiveSec=10m [Install] WantedBy=timers.target # End
Updater
Service
sudo -e '/etc/systemd/system/social-up.service'
[Service] User=www-data Group=www-data Type=oneshot WorkingDirectory=/var/www/social Environment="COMPOSER_CACHE_DIR=/dev/null" ExecStart='/usr/bin/git' -C '/var/www/social' reset --hard 'origin/develop' ExecStart='/usr/bin/git' -C '/var/www/social' pull origin 'develop' --rebase ExecStart='/usr/bin/git' -C '/var/www/social/addon' reset --hard 'origin/develop' ExecStart='/usr/bin/git' -C '/var/www/social/addon' pull origin 'develop' --rebase # Temp php-json-ld Fix (#15340) ExecStart='/usr/bin/sed' -i 's|https://git.friendi.ca/friendica/php-json-ld|https://github.com/digitalbazaar/php-json-ld.git|g' '/var/www/social/composer.lock' ExecStart='/usr/bin/sed' -i 's/1f33c8766b5cfbecfbc2122238873debeed35fb6/fe18c3f2ce47f30ace904ef58e7416f933be25e1/g' '/var/www/social/composer.lock' ExecStart='/usr/bin/composer' --working-dir='/var/www/social' --no-cache install --no-dev ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' dbstructure update --force ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' dbstructure drop --execute ExecStartPost='/usr/bin/php' '/var/www/social/bin/console.php' postupdate ExecStartPost='/usr/bin/sync' # End
Timer
- Daily
04:00:00 AM
sudo -e '/etc/systemd/system/social-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-up.timer' --now && sudo systemctl start 'social-up' && sudo systemctl status 'social-up' -l
[Unit] Description=Friendica Git Updater After=network-online.target Wants=network-online.target [Timer] OnCalendar=*-*-* 04:00:00 Persistent=true [Install] WantedBy=timers.target # End
Backup
Files
Service
mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/social-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/social-fb.service'
[Service] Type=oneshot WorkingDirectory=/var/www/social ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/friendica-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/var/www" "social"' ExecStartPost='/usr/bin/sync' # End
Timer
- Monthly (5th)
04:15:00 AM
sudo -e '/etc/systemd/system/social-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-fb.timer' --now
[Unit] Description=Friendica Files Backup [Timer] OnCalendar=*-*-05 04:15:00 Persistent=true [Install] WantedBy=timers.target # End
sudo systemctl start 'social-fb' && sudo systemctl status 'social-fb' -l
Database
Database Auth
sudo mkdir -p '/var/lib/mysql/auth' && sudo -e '/var/lib/mysql/auth/friendica' && sudo chown 'mysql':'mysql' '/var/lib/mysql/auth/friendica' && sudo chmod '0600' '/var/lib/mysql/auth/friendica'
[mariadb-dump] user=friendica password=x # End
Service
mkdir -p ~/'backups' && sudo mkdir -p '/var/lib/mysql/tmp' && sudo -e '/etc/systemd/system/social-db.service' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/systemd/system/social-db.service'
[Service] Group=mysql Type=oneshot WorkingDirectory=/var/lib/mysql ExecStart='/usr/bin/bash' -c '"/usr/bin/mariadb-dump" --defaults-extra-file="/var/lib/mysql/auth/friendica" --single-transaction --quick "friendica" -r "/home/CHANGEME/backups/friendica-database-auto-"$$(date +%%Y-%%m-%%d)".sql"' ExecStartPost='/usr/bin/sync' # End
Timer
- Monthly (5th)
04:10:00 AM
sudo -e '/etc/systemd/system/social-db.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-db.timer' --now && sudo systemctl start 'social-db' && sudo systemctl status 'social-db' -l
[Unit] Description=Friendica Database Backup After=mariadb.service [Timer] OnCalendar=*-*-05 04:10:00 Persistent=true [Install] WantedBy=timers.target # End
Maintenance
Service
sudo -e '/etc/systemd/system/social-m.service'
[Service] User=www-data Group=www-data Type=oneshot WorkingDirectory=/var/www/social ExecStart='/usr/bin/git' -C '/var/www/social' gc --aggressive --prune='all' ExecStart='/usr/bin/git' -C '/var/www/social' fsck --full --strict ExecStart='/usr/bin/git' -C '/var/www/social/addon' gc --aggressive --prune='all' ExecStart='/usr/bin/git' -C '/var/www/social/addon' fsck --full --strict ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' cache clear ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' clearavatarcache ExecStartPost='/usr/bin/sync' # End
Timer
- Monthly (5th)
04:30:00 AM
sudo -e '/etc/systemd/system/social-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-m.timer' --now
[Unit] Description=Friendica Maintenance After=network-online.target Wants=network-online.target [Timer] OnCalendar=*-*-05 04:30:00 Persistent=true [Install] WantedBy=timers.target # End
sudo systemctl start 'social-m' && sudo systemctl status 'social-m' -l
Backup
Files
sudo tar -czf ~/'friendica-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/var/www' 'social'
Database
sudo mariadb-dump --single-transaction --quick 'friendica' -r ~/'friendica-database-manual-'$(date +%Y-%m-%d)'.sql'
scp
scp espionage724@192.168.1.152:~/'friendica-files-'*'.tar.gz' ~/'Downloads'
scp espionage724@192.168.1.152:~/'friendica-database-'*'.sql' ~/'Downloads'
Restore
scp
scp ~/'Downloads/friendica-files-'*'.tar.gz' espionage724@192.168.1.152:~
scp ~/'Downloads/friendica'*'.sql' espionage724@192.168.1.152:~
Stop nginx
sudo systemctl stop 'nginx'
Remove Existing Files
ls ~/'friendica-files-'*'.tar.gz' && sudo rm -Rf '/var/www/social'
Restore Files
sudo tar -xzf ~/'friendica-files-'*'.tar.gz' -C '/var/www' 'social' && sudo chown -R 'www-data':'www-data' '/var/www/social' && sudo chmod -R '0755' '/var/www/social'
Git Fix
Set email for
user.email
sudo su 'www-data' -s '/bin/bash'
rm -Rf '/var/www/social/.git'
git -C '/var/www/social' init --initial-branch='develop'
git -C '/var/www/social' add '.'
git -C '/var/www/social' config 'user.email' 'espionage724@x'
git -C '/var/www/social' commit --message='x'
git -C '/var/www/social' remote add 'origin' 'https://github.com/friendica/friendica.git'
git -C '/var/www/social' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase
git -C '/var/www/social' reset --hard 'origin/develop'
git -C '/var/www/social' gc --aggressive --prune='all'
git -C '/var/www/social' fsck --full --strict
Addons
Set email for
user.email
rm -Rf '/var/www/social/addon/.git'
git -C '/var/www/social/addon' init --initial-branch='develop'
git -C '/var/www/social/addon' add '.'
git -C '/var/www/social/addon' config 'user.email' 'espionage724@x'
git -C '/var/www/social/addon' commit --message='x'
git -C '/var/www/social/addon' remote add 'origin' 'https://github.com/friendica/friendica-addons.git'
git -C '/var/www/social/addon' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase
git -C '/var/www/social/addon' reset --hard 'origin/develop'
git -C '/var/www/social/addon' gc --aggressive --prune='all'
git -C '/var/www/social/addon' fsck --full --strict
exit
Database Connection
sudo -u 'www-data' -e '/var/www/social/config/local.config.php'
'database' => [ 'hostname' => 'localhost',
'system' => [ 'basepath' => '/var/www/social',
Restore Database
sudo mariadb --execute='DROP DATABASE friendica;'
sudo mariadb --execute='CREATE DATABASE friendica;'
sudo mariadb 'friendica' < ~/'friendica'*'.sql'
Start nginx
sudo systemctl start 'nginx'
Clean-up
rm -fv ~/'friendica-files-'*'.tar.gz' ~/'friendica'*'.sql'
Quick Commands
Commands
sudo su 'www-data' -s '/bin/bash'
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' -h
Show Config
sudo su 'www-data' -s '/bin/bash'
cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' config
1)
https://social.realmofespionage.xyz doesn't redirect to single-profile URL and shows an error
/var/www/wiki/data/attic/servers/linux/nginx/friendica.1766388706.txt.gz · Last modified: by Sean Rhone
