| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| servers:linux:nginx:friendica [2025/09/18 03:29] – [Service] Sean Rhone | servers:linux:nginx:friendica [2025/12/21 21:52] (current) – Sean Rhone |
|---|
| ===== Prerequisites ===== | ===== Prerequisites ===== |
| |
| * [[linux:distros:server:opensuse_tumbleweed_server|openSUSE Tumbleweed (Server)]] | * [[linux:distros:server:ubuntu_server|Ubuntu Server]] |
| * [[servers:linux:nginx_php_php-fpm|nginx + PHP + PHP-FPM]] | * [[servers:linux:nginx_php_php-fpm|nginx + PHP + PHP-FPM]] |
| * [[servers:linux:nginx:lets_encrypt|Certbot (Let's Encrypt)]] | * [[servers:linux:nginx:lets_encrypt|Certbot (Let's Encrypt)]] |
| * 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 php8-pdo php8-fileinfo |
| | |
| | sudo apt install composer php-curl php-gd php-gmp php-mbstring php-intl php-mysql php-zip |
| |
| ====== Download Source ====== | ====== Download Source ====== |
| * https://github.com/friendica/friendica/commits/develop/ | * https://github.com/friendica/friendica/commits/develop/ |
| |
| 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' | 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 ===== | ===== Addons ===== |
| |
| * 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' '/var/www/social/addon' && sudo chown -R 'www-data':'www-data' '/var/www/social/addon' && sudo chmod -R '0755' '/var/www/social/addon' |
| |
| ====== Environment ====== | ====== Environment ====== |
| ===== Composer ===== | ===== Composer ===== |
| |
| sudo su 'wwwrun' -s '/bin/bash' | sudo su 'www-data' -s '/bin/bash' |
| |
| cd '/tmp' && '/usr/bin/composer' --working-dir='/srv/www/social' --no-cache install --no-dev | cd '/tmp' && '/usr/bin/composer' --working-dir='/var/www/social' --no-cache install --no-dev |
| |
| exit | exit |
| 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 ====== |
| |
| ; User/Group | ; User/Group |
| user = "wwwrun" | user = "www-data" |
| group = "www" | group = "www" |
| |
| ; Socket | ; Socket |
| listen = "/run/php-fpm/social.sock" | listen = "/run/php-fpm/social.sock" |
| listen.owner = "wwwrun" | listen.owner = "www-data" |
| listen.group = "www" | listen.group = "www" |
| listen.mode = "0662" | listen.mode = "0662" |
| http2 'on'; | http2 'on'; |
| server_name 'social.realmofespionage.xyz'; | server_name 'social.realmofespionage.xyz'; |
| root '/srv/www/social'; | root '/var/www/social'; |
| index 'index.php'; | index 'index.php'; |
| |
| * :!: Change ''--dbpass'', and ''--admin'' to email | * :!: Change ''--dbpass'', and ''--admin'' to email |
| |
| sudo su 'wwwrun' -s '/bin/bash' | sudo su 'www-data' -s '/bin/bash' |
| |
| cd '/srv/www/social' && '/srv/www/social/bin/console' autoinstall --dbhost 'localhost' --dbport '3365' --dbuser 'friendica' --dbdata 'friendica' --url 'https://social.realmofespionage.xyz' --dbpass 'x' --admin 'x' | cd '/var/www/social' && '/var/www/social/bin/console' autoinstall --dbhost 'localhost' --dbport '3365' --dbuser 'friendica' --dbdata 'friendica' --url 'https://social.realmofespionage.xyz' --dbpass 'x' --admin 'x' |
| |
| ===== Website ===== | ===== Website ===== |
| * :!: ''x'' is the **nickname** chosen at website registration, lower-case | * :!: ''x'' is the **nickname** chosen at website registration, lower-case |
| |
| sudo su 'wwwrun' -s '/bin/bash' | sudo su 'www-data' -s '/bin/bash' |
| |
| cd '/srv/www/social' && '/srv/www/social/bin/console' user password x | cd '/var/www/social' && '/var/www/social/bin/console' user password x |
| |
| ===== Etc ===== | ===== Etc ===== |
| |
| cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' -h | cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' -h |
| |
| cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' worker | cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' worker |
| |
| cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' dbstructure update --force | cd '/var/www/social' && '/usr/bin/php' '/var/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 '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' dbstructure drop --execute |
| |
| cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' postupdate | cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' postupdate |
| |
| cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' cache clear | cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' cache clear |
| |
| cd '/srv/www/social' && '/usr/bin/php' '/srv/www/social/bin/console.php' clearavatarcache | cd '/var/www/social' && '/usr/bin/php' '/var/www/social/bin/console.php' clearavatarcache |
| |
| nano '/srv/www/social/config/local.config.php' | nano '/var/www/social/config/local.config.php' |
| | |
| | exit |
| |
| ====== Settings ====== | ====== Settings ====== |
| <code> | <code> |
| [Service] | [Service] |
| User=wwwrun | User=www-data |
| Group=www | Group=www-data |
| Type=oneshot | Type=oneshot |
| |
| WorkingDirectory=/srv/www/social | WorkingDirectory=/var/www/social |
| |
| ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' worker | ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' worker |
| |
| ExecStartPost='/usr/bin/sync' | ExecStartPost='/usr/bin/sync' |
| ==== Timer ==== | ==== Timer ==== |
| |
| * Every 12 hours | * 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 |
| |
| [Timer] | [Timer] |
| OnBootSec=12h | OnBootSec=10m |
| OnUnitActiveSec=12h | OnUnitActiveSec=10m |
| |
| [Install] | [Install] |
| <code> | <code> |
| [Service] | [Service] |
| User=wwwrun | User=www-data |
| Group=www | Group=www-data |
| Type=oneshot | Type=oneshot |
| |
| WorkingDirectory=/srv/www/social | WorkingDirectory=/var/www/social |
| Environment="COMPOSER_CACHE_DIR=/dev/null" | Environment="COMPOSER_CACHE_DIR=/dev/null" |
| |
| ExecStart='/usr/bin/git' -C '/srv/www/social' pull origin 'develop' | ExecStart='/usr/bin/git' -C '/var/www/social' pull origin 'develop' |
| ExecStart='/usr/bin/git' -C '/srv/www/social/addon' pull origin 'develop' | ExecStart='/usr/bin/git' -C '/var/www/social/addon' pull origin 'develop' |
| |
| ExecStart='/usr/bin/composer' --working-dir='/srv/www/social' --no-cache install --no-dev | ExecStart='/usr/bin/composer' --working-dir='/var/www/social' --no-cache install --no-dev |
| |
| ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' dbstructure update --force | ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' dbstructure update --force |
| ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' dbstructure drop --execute | ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' dbstructure drop --execute |
| ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' postupdate | ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' postupdate |
| ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' cache clear | ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' cache clear |
| ExecStart='/usr/bin/php' '/srv/www/social/bin/console.php' clearavatarcache | ExecStart='/usr/bin/php' '/var/www/social/bin/console.php' clearavatarcache |
| |
| ExecStartPost='/usr/bin/sync' | ExecStartPost='/usr/bin/sync' |
| Type=oneshot | Type=oneshot |
| |
| 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"' | 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' | ExecStartPost='/usr/bin/sync' |
| === Timer === | === Timer === |
| |
| * ''01'' day of every month at ''01:10:00'' | * ''01'' day of every month at ''04:10:00'' |
| |
| 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 | 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> |
| [Service] | [Service] |
| User=wwwrun | User=www-data |
| Group=www | Group=www-data |
| Type=oneshot | Type=oneshot |
| |
| ExecStart='/usr/bin/git' -C '/srv/www/social' reset --hard | ExecStart='/usr/bin/git' -C '/var/www/social' reset --hard |
| ExecStart='/usr/bin/git' -C '/srv/www/social' gc --aggressive --prune='all' | ExecStart='/usr/bin/git' -C '/var/www/social' gc --aggressive --prune='all' |
| ExecStart='/usr/bin/git' -C '/srv/www/social' fsck --full --strict | ExecStart='/usr/bin/git' -C '/var/www/social' fsck --full --strict |
| |
| ExecStart='/usr/bin/git' -C '/srv/www/social/addon' reset --hard | ExecStart='/usr/bin/git' -C '/var/www/social/addon' reset --hard |
| ExecStart='/usr/bin/git' -C '/srv/www/social/addon' gc --aggressive --prune='all' | ExecStart='/usr/bin/git' -C '/var/www/social/addon' gc --aggressive --prune='all' |
| ExecStart='/usr/bin/git' -C '/srv/www/social/addon' fsck --full --strict | ExecStart='/usr/bin/git' -C '/var/www/social/addon' fsck --full --strict |
| |
| ExecStartPost='/usr/bin/sync' | ExecStartPost='/usr/bin/sync' |
| **** | **** |
| |
| sudo tar -czf ~/'friendica-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/srv/www' 'social' | sudo tar -czf ~/'friendica-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/var/www' 'social' |
| |
| ===== Database ===== | ===== Database ===== |
| scp ~/'Downloads/friendica-files-'*'.tar.gz' espionage724@192.168.1.152:~ | scp ~/'Downloads/friendica-files-'*'.tar.gz' espionage724@192.168.1.152:~ |
| |
| scp ~/'Downloads/friendica-database-'*'.sql' espionage724@192.168.1.152:~ | scp ~/'Downloads/friendica'*'.sql' espionage724@192.168.1.152:~ |
| |
| ===== Stop nginx ===== | ===== Stop nginx ===== |
| **** | **** |
| |
| ls ~/'friendica-files-'*'.tar.gz' && sudo rm -Rf '/srv/www/social' | ls ~/'friendica-files-'*'.tar.gz' && sudo rm -Rf '/var/www/social' |
| |
| ===== Restore Files ===== | ===== 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' | sudo tar -xzf ~/'friendica-files-'*'.tar.gz' -C '/var/www' 'social' && sudo chown -R 'www-data':'www' '/var/www/social' && sudo chmod -R '0755' '/var/www/social' |
| | |
| | ===== Git Fix ===== |
| | |
| | * :!: 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)) |
| | |
| | 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' |
| | |
| | <code> |
| | 'database' => [ |
| | 'hostname' => 'localhost',</code> |
| | |
| | <code> |
| | 'system' => [ |
| | 'basepath' => '/var/www/social',</code> |
| |
| ===== Restore Database ===== | ===== Restore Database ===== |
| sudo mariadb --execute='CREATE DATABASE friendica;' | sudo mariadb --execute='CREATE DATABASE friendica;' |
| |
| sudo mariadb 'friendica' < ~/'friendica-database-'*'.sql' | sudo mariadb 'friendica' < ~/'friendica'*'.sql' |
| |
| ===== Start nginx ===== | ===== Start nginx ===== |
| **** | **** |
| |
| rm -fv ~/'friendica-files-'*'.tar.gz' ~/'friendica-database-'*'.sql' | rm -fv ~/'friendica-files-'*'.tar.gz' ~/'friendica'*'.sql' |
| |