User Tools

Site Tools


servers:linux:nginx:friendica

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
servers:linux:nginx:friendica [2025/09/11 18:02] – [Timer] Sean Rhoneservers:linux:nginx:friendica [2025/10/17 01:56] (current) – [Etc] Sean Rhone
Line 4: Line 4:
   * [[information:realm_of_espionage|Realm of Espionage]]   * [[information:realm_of_espionage|Realm of Espionage]]
   * https://social.realmofespionage.xyz   * https://social.realmofespionage.xyz
 +
 +===== Resources =====
 +
 +  * https://wiki.friendi.ca/docs/bbcode
  
 ===== Prerequisites ===== ===== Prerequisites =====
Line 17: Line 21:
   * https://wiki.friendi.ca/docs/install#requirements   * https://wiki.friendi.ca/docs/install#requirements
  
-  sudo zypper install php-composer2 php8-curl php-gd php8-gmp php8-pdo php8-mbstring php8-intl php8-mysql php8-zip php8-openssl php8-posix+  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 ====== ====== Download Source ======
Line 28: Line 32:
  
   * https://github.com/friendica/friendica-addons/commits/develop/   * https://github.com/friendica/friendica-addons/commits/develop/
-  * Required for ''composer install'' even without addons actively used+  * :!: Required for ''composer install'' even 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'   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'
Line 52: Line 56:
   GRANT ALL PRIVILEGES ON friendica.* to 'friendica'@'localhost';   GRANT ALL PRIVILEGES ON friendica.* to 'friendica'@'localhost';
  
-  FLUSH PRIVILEGES; +  FLUSH PRIVILEGES;EXIT;
- +
-  EXIT+
  
 ====== nginx + PHP-FPM Configuration ====== ====== nginx + PHP-FPM Configuration ======
Line 195: Line 197:
  
   nano '/srv/www/social/config/local.config.php'   nano '/srv/www/social/config/local.config.php'
 +
 +  exit
  
 ====== Settings ====== ====== Settings ======
Line 234: Line 238:
 ==== Timer ==== ==== Timer ====
  
-  * Every 1 hour+  * Every 10 minutes (([[https://wiki.friendi.ca/docs/install#required_background_tasks|info]]))
  
   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   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
Line 245: Line 249:
  
 [Timer] [Timer]
-OnBootSec=1h +OnBootSec=10m 
-OnUnitActiveSec=1h+OnUnitActiveSec=10m
  
 [Install] [Install]
Line 304: Line 308:
 # End</code> # End</code>
  
-===== Maintenance =====+===== Backup =====
  
-==== Service ====+==== Files ====
  
-  sudo -e '/etc/systemd/system/social-m.service'+=== 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'
  
 <code> <code>
 [Service] [Service]
-User=nginx 
-Group=nginx 
 Type=oneshot Type=oneshot
-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 
-ExecStartPost='/usr/bin/sync'</code> 
  
-==== Timer ====+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"'
  
-  * ''01'' day of every month at ''03:20:00''+ExecStartPost='/usr/bin/sync' 
 + 
 +# End</code> 
 + 
 +=== Timer === 
 + 
 +  * ''01'' day of every month at ''04:15:00''
  
-  sudo -e '/etc/systemd/system/social-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-m.timer' --now && sudo systemctl start 'social-m' && sudo systemctl status 'social-up' -l+  sudo -e '/etc/systemd/system/social-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-fb.timer' --now
  
 <code> <code>
 [Unit] [Unit]
-Description=friendica Maintenance +Description=Friendica Files Backup
-After=network-online.target +
-Wants=network-online.target+
  
 [Timer] [Timer]
-OnCalendar=*-*-01 03:20:00+OnCalendar=*-*-01 04:15:00
 Persistent=true Persistent=true
  
 [Install] [Install]
-WantedBy=timers.target</code>+WantedBy=timers.target
  
-===== Backup =====+# End</code>
  
-==== Files ====+  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' 
 + 
 +<code> 
 +[mariadb-dump] 
 +user=friendica 
 +password=x 
 + 
 +# End</code>
  
 === Service === === 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'+  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'
  
 <code> <code>
 [Service] [Service]
 +Group=mysql
 Type=oneshot Type=oneshot
-WorkingDirectory=/var/www + 
-ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/friendica-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "social"' +ExecStart='/usr/bin/bash' -c '"/usr/bin/mariadb-dump" --defaults-extra-file="/var/lib/mysql/auth/friendica" --single-transaction --quick "friendica" -"/home/CHANGEME/backups/friendica-database-auto-"$$(date +%%Y-%%m-%%d)".sql"' 
-ExecStartPost='/usr/bin/sync'</code>+ 
 +ExecStartPost='/usr/bin/sync' 
 + 
 +# End</code>
  
 === Timer === === Timer ===
  
-  * ''01'' day of every month at ''03:35:00''+  * ''01'' day of every month at ''04:10:00''
  
-  sudo -e '/etc/systemd/system/social-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-fb.timer' --now && sudo systemctl start 'social-fb' && sudo systemctl status 'social-fb' -l+  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
  
 <code> <code>
 [Unit] [Unit]
-Description=friendica Files Backup+Description=Friendica Database Backup 
 +After=mariadb.service
  
 [Timer] [Timer]
-OnCalendar=*-*-01 03:35:00+OnCalendar=*-*-01 04:10:00
 Persistent=true Persistent=true
  
 [Install] [Install]
-WantedBy=timers.target</code>+WantedBy=timers.target
  
-==== Database ====+# End</code>
  
-=== Database Auth ===+===== Maintenance =====
  
-  sudo mkdir -p '/var/lib/mysql/auth' && sudo -e '/var/lib/mysql/auth/friendica' && sudo chown -R 'mysql':'mysql' '/var/lib/mysql/auth/friendica' && sudo chmod '600' '/var/lib/mysql/auth/friendica' && sync+==== Service ====
  
-<code> +  sudo -e '/etc/systemd/system/social-m.service'
-[mariadb-dump] +
-user=friendica +
-password=x</code> +
- +
-=== 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'+
  
 <code> <code>
 [Service] [Service]
 +User=wwwrun
 +Group=www
 Type=oneshot Type=oneshot
-WorkingDirectory=/var/lib/mysql/tmp 
-ExecStartPre='/usr/bin/mariadb-dump' --defaults-extra-file='/var/lib/mysql/auth/friendica' --single-transaction 'friendica' -r '/var/lib/mysql/tmp/friendica.sql' 
-ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/friendica.sql' 
-ExecStart='/usr/bin/bash' -c '"/usr/bin/mv" "/var/lib/mysql/tmp/friendica.sql.gz" "/home/CHANGEME/backups/friendica-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"' 
-ExecStartPost='/usr/bin/sync'</code> 
  
-=== Timer ===+ExecStart='/usr/bin/git' -C '/srv/www/social' reset --hard 
 +ExecStart='/usr/bin/git' -C '/srv/www/social' gc --aggressive --prune='all' 
 +ExecStart='/usr/bin/git' -C '/srv/www/social' fsck --full --strict
  
-  * Every day at ''03:45:00''+ExecStart='/usr/bin/git-C '/srv/www/social/addonreset --hard 
 +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
  
-  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+ExecStartPost='/usr/bin/sync' 
 + 
 +# End</code> 
 + 
 +==== Timer ==== 
 + 
 +  * ''01'' day of every month at ''04:30:00'' 
 + 
 +  sudo -e '/etc/systemd/system/social-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'social-m.timer' --now
  
 <code> <code>
 [Unit] [Unit]
-Description=friendica Database Backup +Description=Friendica Maintenance 
-After=mariadb.service+After=network-online.target 
 +Wants=network-online.target
  
 [Timer] [Timer]
-OnCalendar=*-*-* 03:45:00+OnCalendar=*-*-01 04:30:00
 Persistent=true Persistent=true
  
 [Install] [Install]
-WantedBy=timers.target</code>+WantedBy=timers.target
  
-====== Backup ======+# End</code>
  
-  * Create backup archive on server and transfer to client computer+  sudo systemctl start 'social-m' && sudo systemctl status 'social-m' -l
  
-===== Server =====+====== Backup ======
  
-==== Stop Services ====+===== Files =====
  
 **** ****
  
-  sudo systemctl stop nginx php-fpm+  sudo tar -czf ~/'friendica-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/srv/www' 'social'
  
-==== Backup Folder ====+===== Database =====
  
 **** ****
  
-  cd '/var/www&& sudo tar -cvzf ~/'friendica-files-manual-'$(date +%Y-%m-%d)'.tar.gz'social' && cd ~ && sync+  sudo mariadb-dump --single-transaction --quick 'friendica' -~/'friendica-database-manual-'$(date +%Y-%m-%d)'.sql'
  
-==== Backup Database ====+===== scp =====
  
-****+  scp espionage724@192.168.1.152:~/'friendica-files-'*'.tar.gz' ~/'Downloads'
  
-  sudo mariadb-dump --defaults-extra-file='/var/lib/mysql/auth/friendica' --single-transaction 'friendica' -r ~/'friendica-database-manual-'$(date +%Y-%m-%d)'.sql' && sync+  scp espionage724@192.168.1.152:~/'friendica-database-'*'.sql' ~/'Downloads'
  
-==== Start Services ====+====== Restore ======
  
-****+===== scp =====
  
-  sudo systemctl start nginx php-fpm+  scp ~/'Downloads/friendica-files-'*'.tar.gz' espionage724@192.168.1.152:~
  
-===== Client =====+  scp ~/'Downloads/friendica'*'.sql' espionage724@192.168.1.152:~
  
-==== Transfer Files To Client ====+===== Stop nginx =====
  
 **** ****
  
-  scp espionage724@192.168.1.152:~/'friendica-files-'*'.tar.gz' espionage724@192.168.1.152:~/'friendica-database-'*'.sql' ~/'Downloads' && sync+  sudo systemctl stop 'nginx'
  
-====== Restore ======+===== Remove Existing Files =====
  
-===== Client =====+****
  
-==== Uncompress Database ====+  ls ~/'friendica-files-'*'.tar.gz' && sudo rm -Rf '/srv/www/social'
  
-  * This is only needed if restoring an **automated** database backup ((manual doesn't gzip))+===== Restore Files =====
  
-  gunzip ~/'Downloads/friendica-database-'*'.sql.gz'+****
  
-==== Transfer Files To Server ====+  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 =====
  
-  scp ~/'Downloads/friendica-files-'*'.tar.gz~/'Downloads/friendica-database-'*'.sqlespionage724@192.168.1.152:~+  * :!: Set email for ''user.email'' 
 +  * :!: Requires [[#etc|Etc]] commands afterwards ((https://social.realmofespionage.xyz doesn't redirect to single-profile URL and shows an error))
  
-==== Remove Files ====+  sudo su 'wwwrun' -s '/bin/bash'
  
-****+  rm -Rf '/srv/www/social/.git'
  
-  rm -f ~/'Downloads/friendica-files-'*'.tar.gz' ~/'Downloads/friendica-database-'*'.sql&& sync+  git -'/srv/www/socialinit --initial-branch='develop'
  
-===== Server =====+  git -C '/srv/www/social' add '.'
  
-==== Stop Services ====+  git -C '/srv/www/social' config 'user.email' 'espionage724@x'
  
-****+  git -C '/srv/www/social' commit --message='x'
  
-  sudo systemctl stop nginx php-fpm+  git -C '/srv/www/social' remote add 'origin' 'https://github.com/friendica/friendica.git'
  
-==== Remove Previous Folder ====+  git -C '/srv/www/social' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase
  
-****+  git -C '/srv/www/social' reset --hard 'origin/develop'
  
-  sudo rm -Rf '/var/www/social'+  git -'/srv/www/social' gc --aggressive --prune='all'
  
-==== Restore Friendica Folder ====+  git -C '/srv/www/social' fsck --full --strict
  
-****+==== Addons ====
  
-  cd '/var/www' && sudo tar -xvzf ~/'friendica-files-'*'.tar.gz'social' && sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' '/var/www/social(/.*)?' && sudo restorecon -F -I -R '/var/www/social' && sudo chown -R 'nginx':'nginx' '/var/www/social&& cd ~ && sync+  * :!: Set email for ''user.email''
  
-==== Drop Previous Database ====+  rm -Rf '/srv/www/social/addon/.git'
  
-  sudo mariadb+  git -C '/srv/www/social/addon' init --initial-branch='develop'
  
-  DROP DATABASE friendica;+  git -C '/srv/www/social/addon' add '.'
  
-  FLUSH TABLES;+  git -C '/srv/www/social/addon' config 'user.email' 'espionage724@x'
  
-  EXIT+  git -C '/srv/www/social/addon' commit --message='x'
  
-==== Re-create Databases ====+  git -C '/srv/www/social/addon' remote add 'origin' 'https://github.com/friendica/friendica-addons.git'
  
-  sudo mariadb+  git -C '/srv/www/social/addon' pull --depth '1' --recurse-submodules 'origin' 'develop' --rebase
  
-  CREATE DATABASE friendica;+  git -C '/srv/www/social/addon' reset --hard 'origin/develop'
  
-  EXIT+  git -C '/srv/www/social/addon' gc --aggressive --prune='all'
  
-==== Restore Database ====+  git -C '/srv/www/social/addon' fsck --full --strict
  
-****+  exit
  
-  sudo mariadb 'friendica' < ~/'friendica-database-'*'.sql' && sync+===== Database Connection =====
  
-==== Reapply Permissions ====+  sudo -e '/srv/www/social/config/local.config.php' && sudo chown -v 'wwwrun':'www' '/srv/www/social/config/local.config.php'
  
-  sudo mariadb+<code> 
 + 'database' => [ 
 + 'hostname' => 'localhost',</code>
  
-  GRANT ALL PRIVILEGES ON friendica.* to 'friendica'@'localhostIDENTIFIED BY 'x';+<code> 
 + 'system=> [ 
 + 'basepath=> '/srv/www/social',</code> 
 + 
 +===== Restore Database ===== 
 + 
 +  * [[#database|Initial set-up]]
  
-  FLUSH PRIVILEGES;+  sudo mariadb --execute='DROP DATABASE friendica;'
  
-  EXIT+  sudo mariadb --execute='CREATE DATABASE friendica;'
  
-==== Start Services ====+  sudo mariadb 'friendica' < ~/'friendica'*'.sql' 
 + 
 +===== Start nginx =====
  
 **** ****
  
-  sudo systemctl start nginx php-fpm+  sudo systemctl start 'nginx'
  
-==== Remove Backups ====+===== Clean-up =====
  
-  Verify that Friendica works before running+****
  
-  rm ~/'friendica-files-'*'.tar.gz' ~/'friendica-database-'*'.sql' && sync+  rm -fv ~/'friendica-files-'*'.tar.gz' ~/'friendica'*'.sql'
  
/srv/www/wiki/data/attic/servers/linux/nginx/friendica.1757628168.txt.gz · Last modified: by Sean Rhone