servers:linux:nginx:friendica
Table of Contents
Information
Resources
Prerequisites
Dependencies
sudo zypper install php-composer2 php8-curl php-gd php8-gmp php8-pdo php8-mbstring php8-intl php8-mysql php8-zip php8-openssl php8-fileinfo php8-posix
Download Source
sudo git clone --branch 'develop' --depth '1' --recurse-submodules 'https://github.com/friendica/friendica.git' '/srv/www/social' && sudo chown -R 'wwwrun':'www' '/srv/www/social' && sudo chmod -R '0755' '/srv/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' '/srv/www/social/addon' && sudo chown -R 'wwwrun':'www' '/srv/www/social/addon' && sudo chmod -R '0755' '/srv/www/social/addon'
Environment
Composer
sudo su 'wwwrun' -s '/bin/bash'
cd '/tmp' && '/usr/bin/composer' --working-dir='/srv/www/social' --no-cache install --no-dev
exit
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/php8/fpm/php-fpm.d/social.conf' && sudo systemctl restart 'php-fpm'
[social] ; User/Group user = "wwwrun" group = "www" ; Socket listen = "/run/php-fpm/social.sock" listen.owner = "wwwrun" listen.group = "www" 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" ; openSUSE php.ini Defaults php_value[session.save_path] = "/var/lib/php8/sessions" ; 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/default.d/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-fpm/social.sock';
}
# End
Server Block
sudo -e '/etc/nginx/vhosts.d/social.conf' && sudo systemctl reload 'nginx'
server {
listen '443' 'ssl';
http2 'on';
server_name 'social.realmofespionage.xyz';
root '/srv/www/social';
index 'index.php';
include '/etc/nginx/default.d/social.conf';
include '/etc/nginx/default.d/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
Initial Setup
Initialize
Change
--dbpass, and--adminto email
sudo su 'wwwrun' -s '/bin/bash'
cd '/srv/www/social' && '/srv/www/social/bin/console' autoinstall --dbhost 'localhost' --dbport '3365' --dbdata 'friendica' --dbuser 'friendica' --url 'https://social.realmofespionage.xyz' --basepath '/srv/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 'wwwrun' -s '/bin/bash'
cd '/srv/www/social' && '/srv/www/social/bin/console' user password 'x'
Disable Registration
sudo su 'wwwrun' -s '/bin/bash'
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' config 'config' 'register_policy' '0'
Etc
sudo su 'wwwrun' -s '/bin/bash'
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' worker
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' dbstructure update --force
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' dbstructure drop --execute
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' postupdate
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' cache clear
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' clearavatarcache
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' config 'system' 'basepath' '/srv/www/social'
cd '/srv/www/social' && '/usr/bin/php' '/srv/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 -e '/srv/www/social/config/local.config.php' && sudo chown -v 'wwwrun':'www' '/srv/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' => '/srv/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 'wwwrun':'www' '/etc/nginx/scripts/social/git-fix.sh'
#!/bin/bash cd '/tmp' '/usr/bin/rm' -Rf '/srv/www/social/.git' '/usr/bin/git' -C '/srv/www/social' init --initial-branch='develop' '/usr/bin/git' -C '/srv/www/social' add '.' ######################################## '/usr/bin/git' -C '/srv/www/social' config 'user.email' 'espionage724@x' ######################################## '/usr/bin/git' -C '/srv/www/social' commit --message='x' '/usr/bin/git' -C '/srv/www/social' remote add 'origin' 'https://github.com/friendica/friendica.git' '/usr/bin/git' -C '/srv/www/social' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase '/usr/bin/git' -C '/srv/www/social' reset --hard 'origin/develop' '/usr/bin/git' -C '/srv/www/social' gc --aggressive --prune='all' '/usr/bin/git' -C '/srv/www/social' fsck --full --strict '/usr/bin/rm' -Rf '/srv/www/social/addon/.git' '/usr/bin/git' -C '/srv/www/social/addon' init --initial-branch='develop' '/usr/bin/git' -C '/srv/www/social/addon' add '.' ######################################## '/usr/bin/git' -C '/srv/www/social/addon' config 'user.email' 'espionage724@x' ######################################## '/usr/bin/git' -C '/srv/www/social/addon' commit --message='x' '/usr/bin/git' -C '/srv/www/social/addon' remote add 'origin' 'https://github.com/friendica/friendica-addons.git' '/usr/bin/git' -C '/srv/www/social/addon' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase '/usr/bin/git' -C '/srv/www/social/addon' reset --hard 'origin/develop' '/usr/bin/git' -C '/srv/www/social/addon' gc --aggressive --prune='all' '/usr/bin/git' -C '/srv/www/social/addon' fsck --full --strict # End
Execute
sudo su 'wwwrun' -s '/bin/bash'
'/etc/nginx/scripts/social/git-fix.sh'
exit
Services
Worker
Service
sudo -e '/etc/systemd/system/social-d.service'
[Service] User=wwwrun Group=www Type=oneshot WorkingDirectory=/srv/www/social ExecStart='/usr/bin/php' '/srv/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=wwwrun Group=www Type=oneshot WorkingDirectory=/srv/www/social Environment="COMPOSER_CACHE_DIR=/dev/null" ExecStart='/usr/bin/git' -C '/srv/www/social' reset --hard 'origin/develop' ExecStart='/usr/bin/git' -C '/srv/www/social' pull origin 'develop' --rebase ExecStart='/usr/bin/git' -C '/srv/www/social/addon' reset --hard 'origin/develop' ExecStart='/usr/bin/git' -C '/srv/www/social/addon' pull origin 'develop' --rebase ExecStart='/usr/bin/composer' --working-dir='/srv/www/social' --no-cache install --no-dev ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' dbstructure update --force ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' dbstructure drop --execute ExecStartPost='/usr/bin/php' '/srv/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=/srv/www/social ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/friendica-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/srv/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 '/srv/lib/mysql/auth' && sudo -e '/srv/lib/mysql/auth/friendica' && sudo chown 'mysql':'mysql' '/srv/lib/mysql/auth/friendica' && sudo chmod '0600' '/srv/lib/mysql/auth/friendica'
[mariadb-dump] user=friendica password=x # End
Service
mkdir -p ~/'backups' && sudo mkdir -p '/srv/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=/srv/lib/mysql ExecStart='/usr/bin/bash' -c '"/usr/bin/mariadb-dump" --defaults-extra-file="/srv/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=wwwrun Group=www Type=oneshot WorkingDirectory=/srv/www/social ExecStart='/usr/bin/git' -C '/srv/www/social' gc --aggressive --prune='all' ExecStart='/usr/bin/git' -C '/srv/www/social' fsck --full --strict ExecStart='/usr/bin/git' -C '/srv/www/social/addon' gc --aggressive --prune='all' ExecStart='/usr/bin/git' -C '/srv/www/social/addon' fsck --full --strict ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' cache clear ExecStart='/usr/bin/php' '/srv/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 '/srv/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 '/srv/www/social'
Restore Files
sudo tar -xzf ~/'friendica-files-'*'.tar.gz' -C '/srv/www' 'social' && sudo chown -R 'wwwrun':'www' '/srv/www/social' && sudo chmod -R '0755' '/srv/www/social'
Git Fix
Set email for
user.email
sudo su 'wwwrun' -s '/bin/bash'
rm -Rf '/srv/www/social/.git'
git -C '/srv/www/social' init --initial-branch='develop'
git -C '/srv/www/social' add '.'
git -C '/srv/www/social' config 'user.email' 'espionage724@x'
git -C '/srv/www/social' commit --message='x'
git -C '/srv/www/social' remote add 'origin' 'https://github.com/friendica/friendica.git'
git -C '/srv/www/social' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase
git -C '/srv/www/social' reset --hard 'origin/develop'
git -C '/srv/www/social' gc --aggressive --prune='all'
git -C '/srv/www/social' fsck --full --strict
Addons
Set email for
user.email
rm -Rf '/srv/www/social/addon/.git'
git -C '/srv/www/social/addon' init --initial-branch='develop'
git -C '/srv/www/social/addon' add '.'
git -C '/srv/www/social/addon' config 'user.email' 'espionage724@x'
git -C '/srv/www/social/addon' commit --message='x'
git -C '/srv/www/social/addon' remote add 'origin' 'https://github.com/friendica/friendica-addons.git'
git -C '/srv/www/social/addon' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase
git -C '/srv/www/social/addon' reset --hard 'origin/develop'
git -C '/srv/www/social/addon' gc --aggressive --prune='all'
git -C '/srv/www/social/addon' fsck --full --strict
exit
Database Connection
sudo -e '/srv/www/social/config/local.config.php' && sudo chown -v 'wwwrun':'www' '/srv/www/social/config/local.config.php'
'database' => [ 'hostname' => 'localhost',
'system' => [ 'basepath' => '/srv/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 'wwwrun' -s '/bin/bash'
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' -h
Show Config
sudo su 'wwwrun' -s '/bin/bash'
cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' config
1)
https://social.realmofespionage.xyz doesn't redirect to single-profile URL and shows an error
C:/www/wiki/data/pages/servers/linux/nginx/friendica.txt · Last modified: by Sean Rhone
