| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| servers:windows:nginx:wordpress [2025/11/29 00:29] – [Scripts] Sean Rhone | servers:windows:nginx:wordpress [2026/01/20 15:20] (current) – [Git Fix] Sean Rhone |
|---|
| |
| * WordPress ((https://wordpress.org)) | * WordPress ((https://wordpress.org)) |
| * [[Information:Realm of Espionage]] | * [[information;realm_of_espionage|Realm of Espionage]] |
| * https://blog.realmofespionage.xyz | * https://blog.realmofespionage.xyz |
| |
| ===== Prerequisites ===== | ===== Prerequisites ===== |
| |
| * [[windows;10|Windows 10 (21H2)]] | * [[windows;10_ltsc_server|Windows 10 (21H2)]] |
| * [[servers;windows;nginx_php_php-cgi|nginx + PHP + PHP-CGI]] | * [[servers;windows;nginx_php_php-cgi|nginx + PHP + PHP-CGI]] |
| * [[servers;windows;nginx;lets_encrypt|Certbot (Let's Encrypt)]] | * [[servers;windows;nginx;lets_encrypt|Certbot (Let's Encrypt)]] |
| ====== Database ====== | ====== Database ====== |
| |
| "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" -p | "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" |
| |
| CREATE DATABASE wordpress; | CREATE DATABASE wordpress; |
| extension = "sodium" | extension = "sodium" |
| |
| | log_errors = "Off" |
| error_reporting = "~E_ALL" | error_reporting = "~E_ALL" |
| display_errors = "Off" | display_errors = "Off" |
| log_errors = "Off" | display_startup_errors = "Off" |
| | html_errors = "Off" |
| |
| [Date] | [Date] |
| <code> | <code> |
| location "~" "\.(php)(/.*)?$" { | location "~" "\.(php)(/.*)?$" { |
| |
| fastcgi_split_path_info "^(.+\.(?:php))(/.*)$"; | fastcgi_split_path_info "^(.+\.(?:php))(/.*)$"; |
| fastcgi_intercept_errors "on"; | fastcgi_intercept_errors "on"; |
| |
| fastcgi_pass "127.0.0.1:9004"; | fastcgi_pass "127.0.0.1:9004"; |
| | |
| } | } |
| |
| * https://github.com/WordPress/WordPress/tree/master/wp-content/themes | * https://github.com/WordPress/WordPress/tree/master/wp-content/themes |
| * Deny all except ''twentytwentyfive'' | * Deny all except ''twentytwentyfive'' |
| * 2025/11/21: No ''twentytwentysix'' (2026) yet | |
| |
| "notepad.exe" "%SystemDrive%\www\nginx\default.d\wp-themes-deny.conf" | "notepad.exe" "%SystemDrive%\www\nginx\default.d\wp-themes-deny.conf" |
| <code> | <code> |
| server { | server { |
| |
| listen "443" "ssl"; | listen "443" "ssl"; |
| http2 "on"; | http2 "on"; |
| include "C:/www/nginx/default.d/headers.conf"; | include "C:/www/nginx/default.d/headers.conf"; |
| include "C:/www/nginx/default.d/wp-themes-deny.conf"; | include "C:/www/nginx/default.d/wp-themes-deny.conf"; |
| |
| client_max_body_size "10M"; | |
| |
| # access_log "logs/blog-access.log"; | # access_log "logs/blog-access.log"; |
| |
| rewrite "/wp-admin$" "$scheme://$host$uri/" "permanent"; | rewrite "/wp-admin$" "$scheme://$host$uri/" "permanent"; |
| |
| } | } |
| |
| |
| <code> | <code> |
| | @echo off |
| | |
| | CD "%Temp%" |
| | |
| SET "PHP_FCGI_MAX_REQUESTS=0" | SET "PHP_FCGI_MAX_REQUESTS=0" |
| SET "PHP_FCGI_CHILDREN=1" | SET "PHP_FCGI_CHILDREN=1" |
| |
| START "Blog PHP-CGI" /MIN "php-cgi.exe" -b "127.0.0.1:9004" -c "%SystemDrive%\www\php\blog.ini" -q | START "Blog PHP-CGI" /MIN "php-cgi.exe" -b "127.0.0.1:9004" -c "%SystemDrive%\www\php\blog.ini" -q |
| | |
| | SET "PHP_FCGI_MAX_REQUESTS=" |
| | SET "PHP_FCGI_CHILDREN=" |
| |
| :: End</code> | :: End</code> |
| |
| TITLE Blog Updater | TITLE Blog Updater |
| | CD "%Temp%" |
| |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" reset --hard "origin/master" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" reset --hard "origin/master" |
| ===== Back-up ===== | ===== Back-up ===== |
| |
| * :!: TODO | "notepad.exe" "%SystemDrive%\www\scripts\blog\Back-up.bat" |
| | |
| "notepad.exe" "%SystemDrive%\www\scripts\media\Back-up.bat" | |
| |
| <code> | <code> |
| @echo off | @echo off |
| |
| :: User\Downloads | TITLE Blog Back-up |
| "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" | CD "%Temp%" |
| | |
| | "tar.exe" -czf "D:\Servers\Scheduled Backups\wordpress-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "blog" |
| | "%ProgramFiles%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" --opt -r "D:\Servers\Scheduled Backups\%RANDOM%-wordpress.sql" "wordpress" |
| |
| :: NAS | ::"tar.exe" -czf "%UserProfile%\Downloads\wordpress-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "blog" |
| ::"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" | ::"%ProgramFiles%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" --opt -r "%UserProfile%\Downloads\%RANDOM%-wordpress.sql" "wordpress" |
| |
| :: End</code> | :: End</code> |
| |
| "%SystemDrive%\www\scripts\media\Back-up.bat" | "%SystemDrive%\www\scripts\blog\Back-up.bat" |
| |
| ===== Maintenance ===== | ===== Maintenance ===== |
| |
| TITLE Blog Maintenance | TITLE Blog Maintenance |
| | CD "%Temp%" |
| |
| MKDIR "%SystemDrive%\www\temp\blog" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" gc --aggressive --prune="all" |
| MOVE /Y "%SystemDrive%\www\blog\wp-content\uploads" "%SystemDrive%\www\temp\blog" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" fsck --full --strict |
| COPY /Y "%SystemDrive%\www\blog\wp-config.php" "%SystemDrive%\www\temp\blog" | |
| | |
| CALL "%SystemDrive%\www\scripts\blog\Git Fix.bat" | |
| | |
| MOVE /Y "%SystemDrive%\www\temp\blog\uploads" "%SystemDrive%\www\blog\wp-content" | |
| MOVE /Y "%SystemDrive%\www\temp\blog\wp-config.php" "%SystemDrive%\www\blog\wp-config.php" | |
| RMDIR /S /Q "%SystemDrive%\www\temp\blog" | |
| |
| :: End</code> | :: End</code> |
| ===== Git Fix ===== | ===== Git Fix ===== |
| |
| * :!: ''wp-content\uploads'' needs backed-up and restored (see [[#maintenance|Maintenance.bat]]) | * :!: Set ''user.email'' |
| * :!: [[#wp-configphp|wp-config.php]] needs re-applied afterwards | |
| | |
| * :!: Set email for ''user.email'' | |
| |
| "notepad.exe" "%SystemDrive%\www\scripts\blog\Git Fix.bat" | "notepad.exe" "%SystemDrive%\www\scripts\blog\Git Fix.bat" |
| |
| TITLE Blog Git Fix | TITLE Blog Git Fix |
| | CD "%Temp%" |
| |
| RMDIR /S /Q "%SystemDrive%\www\blog\.git" | ::################## |
| | ::# Content Back-up |
| | ::################## |
| | |
| | MKDIR "%SystemDrive%\www\temp\blog" |
| | MOVE /Y "%SystemDrive%\www\blog\wp-content\uploads" "%SystemDrive%\www\temp\blog" |
| | COPY /Y "%SystemDrive%\www\blog\wp-config.php" "%SystemDrive%\www\temp\blog" |
| |
| | ::################## |
| | ::# WordPress |
| | ::################## |
| | |
| | RMDIR /S /Q "%SystemDrive%\www\blog\.git" |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" init --initial-branch="master" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" init --initial-branch="master" |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" add "." | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" add "." |
| | |
| | ::###################################### |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" config "user.email" "espionage724@x" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" config "user.email" "espionage724@x" |
| | ::###################################### |
| | |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" commit --message="x" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" commit --message="x" |
| |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" remote add "origin" "https://github.com/WordPress/WordPress.git" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" remote add "origin" "https://github.com/WordPress/WordPress.git" |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" pull --depth "1" --recurse-submodules "origin" "master" --rebase | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" pull --depth "1" --recurse-submodules "origin" "master" --rebase |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" reset --hard "origin/master" | |
| |
| | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" reset --hard "origin/master" |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" gc --aggressive --prune="all" | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" gc --aggressive --prune="all" |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" fsck --full --strict | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" fsck --full --strict |
| | |
| | ::################## |
| | ::# Content Restore |
| | ::################## |
| | |
| | MOVE /Y "%SystemDrive%\www\temp\blog\uploads" "%SystemDrive%\www\blog\wp-content" |
| | MOVE /Y "%SystemDrive%\www\temp\blog\wp-config.php" "%SystemDrive%\www\blog\wp-config.php" |
| | RMDIR /S /Q "%SystemDrive%\www\temp\blog" |
| |
| :: End</code> | :: End</code> |
| "%SystemDrive%\www\scripts\blog\Git Fix.bat" | "%SystemDrive%\www\scripts\blog\Git Fix.bat" |
| |
| ====== Shortcuts ====== | ====== Task Scheduler ====== |
| |
| ===== Autostart ===== | ===== PHP-CGI ===== |
| |
| ==== PHP-CGI ==== | * Auto-start |
| |
| "explorer.exe" "%AppData%\Microsoft\Windows\Start Menu\Programs\StartUp" | SCHTASKS /Create /SC "ONLOGON" /TN "Blog PHP-CGI" /TR "%SystemDrive%\www\scripts\blog\PHP-CGI.bat" /F |
| | |
| "%SystemDrive%\www\scripts\blog\PHP-CGI.bat" | |
| | |
| Blog PHP-CGI | |
| | |
| ====== Task Scheduler ====== | |
| | |
| **** | |
| | |
| taskschd.msc | |
| |
| ===== Update ===== | ===== Update ===== |
| |
| * ''2:00:00 AM'' daily | * Daily ''02:00:00 AM'' |
| |
| Blog Update | SCHTASKS /Create /SC "DAILY" /TN "Blog Update" /TR "%SystemDrive%\www\scripts\blog\Update.bat" /ST "02:00" /F |
| | |
| "%SystemDrive%\www\scripts\blog\Update.bat" | |
| |
| ===== Back-up ===== | ===== Back-up ===== |
| |
| * Monthly -> All months -> Days: ''3'' | * Monthly (3rd) ''02:10:00 AM'' |
| * ''2:15:00 AM'' | |
| |
| Blog Back-up | SCHTASKS /Create /SC "MONTHLY" /D "3" /M "*" /TN "Blog Back-up" /TR "%SystemDrive%\www\scripts\blog\Back-up.bat" /ST "02:10" /F |
| | |
| "%SystemDrive%\www\scripts\blog\Back-up.bat" | |
| |
| ===== Maintenance ===== | ===== Maintenance ===== |
| |
| * Monthly -> All months -> Days: ''3'' | * Monthly (3rd) ''02:30:00 AM'' |
| * ''2:30:00 AM'' | |
| |
| Blog Maintenance | SCHTASKS /Create /SC "MONTHLY" /D "3" /M "*" /TN "Blog Maintenance" /TR "%SystemDrive%\www\scripts\blog\Maintenance.bat" /ST "02:30" /F |
| | |
| "%SystemDrive%\www\scripts\blog\Maintenance.bat" | |
| |
| ====== Initial Setup ====== | ====== Initial Setup ====== |
| |
| * https://blog.realmofespionage.xyz | * https://blog.realmofespionage.xyz |
| | * Database Host: ''localhost'' |
| |
| ====== Settings ====== | ====== Settings ====== |
| |
| * https://developer.wordpress.org/advanced-administration/wordpress/update-services/#xml-rpc-ping-services | * Date Format -> Custom: ''Y/m/d'' |
| | * Permalink structure: ''[x]'' Plain |
| |
| ===== wp-config.php ===== | ===== wp-config.php ===== |
| * https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php | * https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php |
| * https://developer.wordpress.org/advanced-administration/wordpress/wp-config/ | * https://developer.wordpress.org/advanced-administration/wordpress/wp-config/ |
| | * ''SCRIPT_DEBUG'' at ''true'' loads non-minified scripts/CSS ([[https://github.com/WordPress/WordPress/blob/master/wp-includes/script-loader.php#L6|source]]) ((2026/01/06: Fixed 2025 theme loading odd buttons in header)) |
| |
| * :!: Change ''DB_PASSWORD'' | * :!: Change ''DB_PASSWORD'' |
| define( 'WP_DEBUG', false ); | define( 'WP_DEBUG', false ); |
| define( 'WP_DEBUG_DISPLAY', false ); | define( 'WP_DEBUG_DISPLAY', false ); |
| | |
| | define( 'SCRIPT_DEBUG', true ); |
| |
| if ( ! defined( 'ABSPATH' ) ) { | if ( ! defined( 'ABSPATH' ) ) { |
| define( 'ABSPATH', __DIR__ . '/' ); | define( 'ABSPATH', __DIR__ . '/' ); |
| } | } |
| |
| // End</code> | // End</code> |
| |
| ====== Files ====== | ====== Backup ====== |
| |
| ===== Backup ===== | ===== Folder ===== |
| |
| **** | **** |
| "tar.exe" -czf "%UserProfile%\Downloads\wordpress-files-manual-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "blog" | "tar.exe" -czf "%UserProfile%\Downloads\wordpress-files-manual-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "blog" |
| |
| ====== Database ====== | ===== Database ===== |
| | |
| ===== Backup ===== | |
| |
| **** | **** |
| |
| CD "%USERPROFILE%\Downloads" && "%PROGRAMFILES%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" -p --opt -r "wordpress.sql" "wordpress" | CD "%USERPROFILE%\Downloads" && "%PROGRAMFILES%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" --opt -r "wordpress.sql" "wordpress" |
| | |
| | ====== Restore ====== |
| |
| ===== Restore ===== | ===== Database ===== |
| |
| * [[#database|Initial set-up]] | * [[#database|Initial set-up]] |
| |
| "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" -p --execute="CREATE DATABASE wordpress" | "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" --execute="CREATE DATABASE wordpress" |
| |
| "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" -p "wordpress" < "%UserProfile%\Downloads\wordpress.sql" | "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" "wordpress" < "%UserProfile%\Downloads\wordpress.sql" |
| |