====== Information ====== * Friendica ((https://friendi.ca/)) * [[Information:Realm of Espionage]] * https://social.realmofespionage.xyz ===== Prerequisites ===== * [[windows;10|Windows 10 (21H2)]] * [[servers;windows;nginx_php_php-cgi|nginx]] * [[servers;windows;nginx;lets_encrypt|Certbot (Let's Encrypt)]] * [[programs;windows;git|Git]] * [[servers;windows;mariadb|MariaDB]] ==== WSL ==== * [[windows;notes;wsl|WSL]] * [[windows;opensuse_tumbleweed_wsl|openSUSE Tumbleweed]] * [[servers;windows;php_php-fpm_wsl|PHP + PHP-FPM]] ====== Dependencies ====== * https://friendi.ca/resources/requirements/ * https://wiki.friendi.ca/docs/install#requirements "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- zypper install --no-confirm php-composer2 php8-curl php8-fileinfo php-gd php8-gmp php8-pdo php8-mbstring php8-intl php8-mysql php8-zip php8-openssl php8-posix php8-opcache ====== Download Source ====== * https://github.com/friendica/friendica/commits/develop/ "%ProgramFiles%\Git\bin\git.exe" clone --branch "develop" --depth "1" --recurse-submodules "https://github.com/friendica/friendica.git" "%SystemDrive%\www\social" ===== Addons ===== * https://github.com/friendica/friendica-addons/commits/develop/ "%ProgramFiles%\Git\bin\git.exe" clone --branch "develop" --depth "1" --recurse-submodules "https://github.com/friendica/friendica-addons.git" "%SystemDrive%\www\social\addon" ====== Database ====== * :!: TODO: Limit ''%'' to WSL ((WSL ''php'' is blocked from ''localhost'')) "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" CREATE DATABASE friendica; CREATE USER 'friendica'@'%' IDENTIFIED BY 'x'; GRANT ALL PRIVILEGES ON friendica.* to 'friendica'@'%'; FLUSH PRIVILEGES;EXIT; ====== Environment ====== ===== PHP ===== "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- '/usr/bin/nano' '/etc/php8/fpm/php-fpm.d/social.conf' [social] listen = "127.0.0.1:9005" user = "espionage724" group = "espionage724" listen.allowed_clients = "127.0.0.1" pm = "ondemand" pm.max_children = "8" pm.process_idle_timeout = "30" php_value[error_reporting] = "~E_ALL" php_value[display_errors] = "Off" php_value[log_errors] = "Off" php_value[date.timezone] = "America/New_York" 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" php_value[session.save_path] = "/var/lib/php8/sessions" ; End ===== Composer ===== **** "wsl.exe" --distribution openSUSE-Tumbleweed -- '/usr/bin/composer' --working-dir='/mnt/c/www/social' --no-cache install --no-dev ====== nginx + PHP-FPM Configuration ====== ===== PHP-FPM ===== "notepad.exe" "%SystemDrive%\www\nginx\default.d\social.conf" location "~" "\.(php)(/.*)?$" { fastcgi_split_path_info "^(.+\.(?:php))(/.*)$"; fastcgi_intercept_errors "on"; fastcgi_index "index.php"; include "C:/www/nginx/conf/fastcgi_params"; fastcgi_param "SCRIPT_FILENAME" "/mnt/c/www/social$fastcgi_script_name"; fastcgi_param "PATH_INFO" "$fastcgi_path_info"; fastcgi_param "HTTPS" "on"; fastcgi_pass "127.0.0.1:9005"; } # End ===== Server Block ===== "notepad.exe" "%SystemDrive%\www\nginx\vhosts.d\social.conf" server { listen "443" "ssl"; http2 "on"; server_name "social.realmofespionage.xyz"; root "C:/www/social"; index "index.php"; include "C:/www/nginx/default.d/social.conf"; include "C:/www/nginx/default.d/headers.conf"; client_max_body_size "10M"; # access_log "logs/social-access.log"; # error_log "logs/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 "%SystemDrive%\www\scripts\nginx\Reload.bat" ====== Scripts ====== ===== Folder ===== MKDIR "%SystemDrive%\www\scripts\social" "explorer.exe" "%SystemDrive%\www\scripts\social" ===== PHP-FPM ===== "notepad.exe" "%SystemDrive%\www\scripts\social\PHP-FPM.bat" @echo off START "Social PHP-FPM" /MIN "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- '/usr/sbin/php-fpm' -c '/etc/php8/fpm/php-fpm.d/social.conf' -F :: End "%SystemDrive%\www\scripts\social\PHP-FPM.bat" ===== Worker ===== "notepad.exe" "%SystemDrive%\www\scripts\social\Worker.bat" @echo off TITLE Social Worker "wsl.exe" --distribution openSUSE-Tumbleweed --cd "/mnt/c/www/social" -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' worker :: End "%SystemDrive%\www\scripts\social\Worker.bat" ===== Update ===== "notepad.exe" "%SystemDrive%\www\scripts\social\Update.bat" @echo off TITLE Social Updater "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" reset --hard "origin/develop" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" pull origin "develop" --rebase "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" reset --hard "origin/develop" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" pull origin "develop" --rebase "wsl.exe" --distribution openSUSE-Tumbleweed -- '/usr/bin/composer' --working-dir='/mnt/c/www/social' --no-cache install --no-dev "wsl.exe" --distribution openSUSE-Tumbleweed --cd "/mnt/c/www/social" -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' worker "wsl.exe" --distribution openSUSE-Tumbleweed --cd "/mnt/c/www/social" -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' dbstructure update --force "wsl.exe" --distribution openSUSE-Tumbleweed --cd "/mnt/c/www/social" -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' dbstructure drop --execute "wsl.exe" --distribution openSUSE-Tumbleweed --cd "/mnt/c/www/social" -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' postupdate :: End "%SystemDrive%\www\scripts\social\Update.bat" ===== Back-up ===== * ''D:\Servers\Scheduled Backups'' "notepad.exe" "%SystemDrive%\www\scripts\social\Back-up.bat" @echo off TITLE Social Back-up :: User\Downloads ::"tar.exe" -czf "%UserProfile%\Downloads\friendica-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "social" ::"%ProgramFiles%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" --opt -r "%UserProfile%\Downloads\%RANDOM%-friendica.sql" "friendica" :: NAS "tar.exe" -czf "D:\Servers\Scheduled Backups\friendica-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "social" "%ProgramFiles%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" --opt -r "D:\Servers\Scheduled Backups\%RANDOM%-friendica.sql" "friendica" :: End "%SystemDrive%\www\scripts\social\Back-up.bat" ===== Maintenance ===== "notepad.exe" "%SystemDrive%\www\scripts\social\Maintenance.bat" @echo off TITLE Social Maintenance CALL "%SystemDrive%\www\scripts\social\Git Fix.bat" "wsl.exe" --distribution openSUSE-Tumbleweed --cd "/mnt/c/www/social" -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' cache clear "wsl.exe" --distribution openSUSE-Tumbleweed --cd "/mnt/c/www/social" -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' clearavatarcache :: End "%SystemDrive%\www\scripts\social\Maintenance.bat" ===== Git Fix ===== * :!: Set email for both ''user.email'' "notepad.exe" "%SystemDrive%\www\scripts\social\Git Fix.bat" @echo off TITLE Social Git Fix RMDIR /S /Q "%SystemDrive%\www\social\.git" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" init --initial-branch="develop" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" add "." "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" config "user.email" "espionage724@x" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" commit --message="x" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" remote add "origin" "https://github.com/friendica/friendica.git" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" pull --depth "1" --recurse-submodules "origin" "develop" --rebase "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" reset --hard "origin/develop" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" gc --aggressive --prune="all" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social" fsck --full --strict RMDIR /S /Q "%SystemDrive%\www\social\addon\.git" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" init --initial-branch="develop" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" add "." "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" config "user.email" "espionage724@x" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" commit --message="x" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" remote add "origin" "https://github.com/friendica/friendica-addons.git" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" pull --depth "1" --recurse-submodules "origin" "develop" --rebase "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" reset --hard "origin/develop" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" gc --aggressive --prune="all" "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\social\addon" fsck --full --strict :: End "%SystemDrive%\www\scripts\social\Git Fix.bat" ====== Shortcuts ====== ===== Autostart ===== ==== PHP-FPM ==== "explorer.exe" "%AppData%\Microsoft\Windows\Start Menu\Programs\StartUp" "%SystemDrive%\www\scripts\social\PHP-FPM.bat" Social PHP-FPM ====== Task Scheduler ====== **** taskschd.msc ===== Worker ===== * TODO: On-login, every 15 minutes Social Worker "%SystemDrive%\www\scripts\social\Worker.bat" ===== Update ===== * ''4:00:00 AM'' daily Social Update "%SystemDrive%\www\scripts\social\Update.bat" ===== Back-up ===== * Monthly -> All months -> Days: ''5'' * ''4:15:00 AM'' Social Back-up "%SystemDrive%\www\scripts\social\Back-up.bat" ===== Maintenance ===== * Monthly -> All months -> Days: ''5'' * ''4:30:00 AM'' Social Maintenance "%SystemDrive%\www\scripts\social\Maintenance.bat" ====== Service ====== ===== Worker ===== ==== Service ==== "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- '/usr/bin/nano' '/etc/systemd/system/social-d.service' [Service] User=espionage724 Group=espionage724 Type=oneshot WorkingDirectory=/mnt/c/www/social ExecStart='/usr/bin/php' '/mnt/c/www/social/bin/console.php' worker ExecStartPost='/usr/bin/sync' # End ==== Timer ==== * Every 10 minutes (([[https://wiki.friendi.ca/docs/install#required_background_tasks|info]])) "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- '/usr/bin/nano' '/etc/systemd/system/social-d.timer' && "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- '/usr/bin/systemctl' daemon-reload && "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- '/usr/bin/systemctl' enable 'social-d.timer' --now && "wsl.exe" --distribution openSUSE-Tumbleweed --user root -- '/usr/bin/systemctl' start 'social-d' && "wsl.exe" --distribution openSUSE-Tumbleweed -- '/usr/bin/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 ====== Initial Setup ====== * TODO ====== Settings ====== * ''x'' is WSL virtual adapter ''IPv4 Address'' ipconfig "notepad.exe" "%SystemDrive%\www\social\config\local.config.php" 'database' => [ 'hostname' => '172.x', 'system' => [ 'basepath' => '/mnt/c/www/social', ====== Files ====== ===== Backup ===== **** "tar.exe" -czf "%UserProfile%\Downloads\friendica-files-manual-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "social" ====== Database ====== ===== Backup ===== **** CD "%UserProfile%\Downloads" && "%ProgramFiles%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" -p --opt -r "friendica.sql" "friendica" ===== Restore ===== * [[#database|Initial set-up]] "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" --execute="CREATE DATABASE friendica" "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" "friendica" < "%UserProfile%\Downloads\friendica.sql" ====== TODO ====== "wsl.exe" --distribution openSUSE-Tumbleweed -- '/usr/sbin/php-fpm' -c '/etc/php8/fpm/php-fpm.d/social.conf' -F "wsl.exe" --distribution openSUSE-Tumbleweed -- '/usr/bin/php' '/mnt/c/www/social/bin/console.php' worker "wsl.exe" --distribution openSUSE-Tumbleweed -- '/usr/bin/composer' --working-dir='/mnt/c/www/social' --no-cache install --no-dev