User Tools

Site Tools


servers:windows:nginx:friendica

This is an old revision of the document!


Information

Prerequisites

Dependencies

"wsl.exe"
sudo zypper install 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

"%ProgramFiles%\Git\bin\git.exe" clone --branch "develop" --depth "1" --recurse-submodules "https://github.com/friendica/friendica.git" "%SystemDrive%\www\social"

Addons

"%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 2)
"%ProgramFiles%\MariaDB 12.1\bin\mariadb.exe" -u "root" -p
CREATE DATABASE friendica;
CREATE USER 'friendica'@'%' IDENTIFIED BY 'x';
GRANT ALL PRIVILEGES ON friendica.* to 'friendica'@'%';
FLUSH PRIVILEGES;
EXIT

Environment

PHP

"wsl.exe"
sudo -e '/etc/php8/fpm/php-fpm.d/social.conf'
[social]

; Socket
listen = "127.0.0.1:9005"
listen.allowed_clients = "127.0.0.1"

; Process Management
pm = "ondemand"
pm.max_children = "8"
pm.process_idle_timeout = "30"

; openSUSE php.ini Defaults
php_value[session.save_path] = "/var/lib/php8/sessions"

; General
php_value[log_errors] = "0"
php_value[error_reporting] = "~E_ALL"
;php_value[display_errors] = "On"
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"

; End
"php.exe" -c "%SystemDrive%\www\php\social.ini" -m

Composer

"wsl.exe"
cd '/tmp' && '/usr/bin/composer' --working-dir='/mnt/c/www/social' --no-cache install --no-dev

nginx + PHP-CGI Configuration

PHP-CGI

"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"

Batch Files

MKDIR "%SystemDrive%\www\scripts\social"
"explorer.exe" "%SystemDrive%\www\scripts\social"

PHP-CGI

"notepad.exe" "%SystemDrive%\www\scripts\social\PHP-FPM.bat"
@echo off

START "Social PHP-FPM" "wsl.exe" --distribution openSUSE-Tumbleweed -- php-fpm -c '/etc/php8/fpm/php-fpm.d/social.conf' -F

:: End
"%SystemDrive%\www\scripts\social\PHP-FPM.bat"

logrotate

  • Sets php-fpm.log permissions so php-fpm can run non-root
"wsl.exe" --distribution openSUSE-Tumbleweed
sudo rm -f '/var/log/php-fpm.log' && echo 'x' | sudo tee '/var/log/php-fpm.log' > '/dev/null'
sudo -e '/etc/logrotate.d/99-php-fpm.log' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/logrotate.d/99-php-fpm.log'
'/var/log/php-fpm.log' {
    create '0640' 'CHANGEME' 'CHANGEME'
    daily
    rotate 0
    nocompress
    missingok
    notifempty
    nocopy
    nomail
    noshred
}

# End
sudo logrotate --force '/etc/logrotate.d/99-php-fpm.log'
exit

Autostart

explorer "%ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp"
"%SystemDrive%\www\scripts\social\PHP-CGI.bat"
Social PHP-CGI

Scripts

Folder

MKDIR "%SystemDrive%\www\scripts\media"
"explorer.exe" "%SystemDrive%\www\scripts\media"

PHP-CGI

"notepad.exe" "%SystemDrive%\www\scripts\media\PHP-CGI.bat"
@echo off

SET "PHP_FCGI_MAX_REQUESTS=0"
SET "PHP_FCGI_CHILDREN=1"

START "Media PHP-CGI" "php-cgi.exe" -b "127.0.0.1:9003" -c "%SystemDrive%\www\php\media.ini" -q

:: End
"%SystemDrive%\www\scripts\media\PHP-CGI.bat"

Update

"notepad.exe" "%SystemDrive%\www\scripts\media\Update.bat"
@echo off

:: Piwigo
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media" pull origin "master"

:: Bootstrap Darkroom
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media\themes\bootstrap_darkroom" pull origin "master"

:: End
"%SystemDrive%\www\scripts\media\Update.bat"

Back-up

  • TODO
"notepad.exe" "%SystemDrive%\www\scripts\media\Back-up.bat"
@echo off

:: User\Downloads
"tar.exe" -czf "%UserProfile%\Downloads\dokuwiki-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www\wiki" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"

:: NAS
::"tar.exe" -czf "D:\Servers\Scheduled Backups\dokuwiki-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www\wiki" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"

:: End
"%SystemDrive%\www\scripts\media\Back-up.bat"

Maintenance

"notepad.exe" "%SystemDrive%\www\scripts\media\Maintenance.bat"
@echo off

:: Piwigo
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media" reset --hard

"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media" gc --aggressive --prune="all"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media" fsck --full --strict

:: Bootstrap Darkroom
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media\themes\bootstrap_darkroom" reset --hard

"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media\themes\bootstrap_darkroom" gc --aggressive --prune="all"
"%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\media\themes\bootstrap_darkroom" fsck --full --strict

:: End
"%SystemDrive%\www\scripts\media\Maintenance.bat"

Git Fix

  • :!: Set email for both user.email
"notepad.exe" "%SystemDrive%\www\scripts\social\Git Fix.bat"
@echo off

:: Friendica
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

:: Addons
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

PAUSE

:: End
"%SystemDrive%\www\scripts\social\Git Fix.bat"

Initial Setup

Settings

Purity III Template

Install

  • Install T3 Framework and Purity III from that downloads page

System Dashboard

  • Templates → Site Template Styles
  • Set purity_III - Default to Default

Theme Settings

  • General → Show T3 Logo: Off
  • Theme → Logo Type: Text
  • Theme → Site Name: Realm of Espionage
  • Navigation → Megamenu Configuration → Animation: Fading
  • Navigation → Megamenu Configuration → Duration: 300
  • Add-ons → Off-canvas Sidebar → Enable: Off
  • Assignment → Toggle Selection
  • Last tested: 2024/02/01 on Joomla 5.1.0-dev, T3 Framework 3.2.0, and Purity III 2.1.0

wget -O '/tmp/cc-by-sa-40.png' 'https://licensebuttons.net/l/by-sa/4.0/80x15.png' && sudo mv '/tmp/cc-by-sa-40.png' '/var/www/main/images/cc-by-sa-40.png' && sudo chown 'nginx':'nginx' '/var/www/main/images/cc-by-sa-40.png' && sudo restorecon -F -I -R '/var/www/main/images/cc-by-sa-40.png' && sync
Text
  • Place text within the <section class=“t3-copyright”> section underneath the Bootstrap by Twitter and Font Awesome mentions
  • Remove Bootstrap by Twitter and Font Awesome mentions
sudo -e '/var/www/main/templates/purity_iii/tpls/blocks/footer.php' && sudo chown 'nginx':'nginx' '/var/www/main/templates/purity_iii/tpls/blocks/footer.php'
          <small>
            <img src="https://realmofespionage.xyz/images/cc-by-sa-40.png" width="80" height="15" /> All content and data available on Realm of Espionage is available under the <a href="https://creativecommons.org/licenses/by-sa/4.0" target="_blank">Creative Commons Attribution-ShareAlike 4.0 International</a> license.
          </small>

Custom CSS

  • :!: This shrinks the footer height, and places it back at the bottom of the screen instead of floating half-way up the page when little content exists (source 1, source 2)
  • Also replaces ThemeMagic for Brand Primary Color, Footer Background, and Footer Text Color
  • Last tested: 2024/02/01 on Joomla 5.1.0-dev, T3 Framework 3.2.0, and Purity III 2.1.0
sudo -e '/var/www/main/templates/purity_iii/css/custom.css' && sudo chown 'nginx':'nginx' '/var/www/main/templates/purity_iii/css/custom.css'
html,

body {
  height: 100%;
}

a {
  color: #3D8BFF;
}

a:hover {
  color: #196BE4;
}

.t3-mainnav {
  background-color: #3D8BFF;
}

.logo a {
  background: none;
}

.logo a:hover {
  background: #196BE4;
}

.t3-wrapper {
  position: relative;
  min-height: 100%;
}

.t3-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #484848;
  color: #FFFFFF;
}

.t3-copyright {
  padding-top: 20px;
  padding-bottom: 0px;
}

Articles

Home

  • The line-breaks are intentional and are there to make how it displays look nicer
  • Add links to RoE | Wiki and CC BY-SA 4.0 license
 
 

Welcome! Realm of Espionage is a personal project composed of various services. All services on RoE are free and open-source, self-hosted, and configured with strict security in-mind. My most prominent project currently is RoE | Wiki, a DokuWiki instance that holds my notes on all sorts of operating system, client, and server deployments, free for anyone to view and redistribute under the CC BY-SA 4.0 license.

 

This domain serves as a landing page and provides links to my most-used profiles and projects. To view them, use the navigation bar (desktop) or the ≡ hamburger icon (mobile) at the top of the screen.

 
  • Main menu headers are: System Links → URL# to allow tapping as-expected on mobile
  • Icon sizes are 24×24
  • Menu entries should be named normally before saving for a proper alias, and then add a space on the title afterwards to make it look better with the icon

Global Configuration

Site Meta Description

Realm of Espionage is a personal project composed of various self-hosted services. All services are hosted in-house under secure conditions, and notes are provided for all services under the CC-BY-SA 4.0 license.

Content Rights

Creative Commons Attribution-ShareAlike 4.0 International

Articles

  • System → Global Configuration → Articles
  • Show Title: Hide
  • Show Category: Hide
  • Show Author: Hide
  • Show Publish Date: Hide
  • Show Navigation: Hide
  • Show Print: Hide
  • Show Email: Hide
  • Show Hits: Hide
  • Menus → Main Menu → Home → Link Type → Display in Menu: No
  • Menus → Main Menu → Home → Page Display → Show Page Heading: Hide

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.1\bin\mariadb-dump.exe" -u "root" -p --opt -r "friendica.sql" "friendica"

Restore

"%ProgramFiles%\MariaDB 12.1\bin\mariadb.exe" -u "root" -p --execute="CREATE DATABASE friendica"
"%ProgramFiles%\MariaDB 12.1\bin\mariadb.exe" -u "root" -p "friendica" < "%UserProfile%\Downloads\friendica.sql"
2)
WSL php is blocked from localhost
/srv/www/wiki/data/attic/servers/windows/nginx/friendica.1760360852.txt.gz · Last modified: by Sean Rhone