====== Information ====== * WordPress ((https://wordpress.org)) * [[Information:Realm of Espionage]] * https://blog.realmofespionage.xyz ===== Prerequisites ===== * [[windows;11_ltsc_server|Windows 11 (24H2)]] * [[servers;windows;nginx_php_php-cgi|nginx + PHP + PHP-CGI]] * [[servers;windows;nginx;lets_encrypt|Certbot (Let's Encrypt)]] * [[programs;windows;git|Git]] * [[servers;windows;mariadb|MariaDB]] ====== Dependencies ====== * https://wordpress.org/about/requirements/ * https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions ====== Download Source ====== * https://github.com/WordPress/WordPress/commits/master/ "%ProgramFiles%\Git\bin\git.exe" clone --branch "master" --depth "1" --recurse-submodules "https://github.com/WordPress/WordPress.git" "%SystemDrive%\www\blog" ====== Database ====== "%ProgramFiles%\MariaDB 12.0\bin\mariadb.exe" -u "root" -p CREATE DATABASE wordpress; CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'x'; GRANT ALL PRIVILEGES ON wordpress.* to 'wordpress'@'localhost'; FLUSH PRIVILEGES; EXIT ====== Environment ====== ===== PHP ===== "notepad.exe" "%SystemDrive%\www\php\blog.ini" [PHP] ; Modules extension_dir = ".\ext" extension = "curl" extension = "exif" extension = "fileinfo" extension = "gd" extension = "intl" extension = "mbstring" extension = "mysqli" extension = "openssl" extension = "sodium" zend_extension = "opcache" ; Settings error_reporting = "E_ERROR" display_errors = "Off" [Date] date.timezone = "America/New_York" ; End "php.exe" -c "%SystemDrive%\www\php\blog.ini" -m ====== nginx + PHP-CGI Configuration ====== ===== PHP-CGI ===== "notepad.exe" "%SystemDrive%\www\nginx\default.d\blog.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" $document_root$fastcgi_script_name; fastcgi_param "PATH_INFO" $fastcgi_path_info; fastcgi_param "HTTPS" "on"; fastcgi_pass "127.0.0.1:9004"; } # End ===== Themes Deny ===== * https://github.com/WordPress/WordPress/tree/master/wp-content/themes * Deny all except ''twentytwentyfive'' "notepad.exe" "%SystemDrive%\www\nginx\default.d\wp-themes-deny.conf" location ~ /wp-content/themes/(twentyeleven|twentyfifteen|twentyfourteen|twentynineteen|twentyseventeen|twentysixteen|twentyten|twentythirteen|twentytwelve|twentytwentyfour|twentytwentyone|twentytwentythree|twentytwentytwo|twentytwenty)/ { deny all; } # End ===== Server Block ===== "notepad.exe" "%SystemDrive%\www\nginx\vhosts.d\blog.conf" server { listen "443" "ssl"; http2 "on"; server_name "blog.realmofespionage.xyz"; root "C:/www/blog"; index "index.php"; include C:/www/nginx/default.d/blog.conf; include C:/www/nginx/default.d/headers.conf; include C:/www/nginx/default.d/wp-themes-deny.conf; client_max_body_size "10M"; # add_header Content-Security-Policy "default-src "self"; script-src "self" "unsafe-inline" "unsafe-eval"; style-src "self" "unsafe-inline"" always; # access_log logs/blog-access.log; # error_log logs/blog-error.log; location / { try_files $uri $uri/ /index.php?$args; } rewrite /wp-admin$ $scheme://$host$uri/ permanent; } # End "%SystemDrive%\www\scripts\nginx\Reload.bat" ====== Scripts ====== **** MKDIR "%SystemDrive%\www\scripts\blog" ===== PHP-CGI ===== "notepad.exe" "%SystemDrive%\www\scripts\blog\PHP-CGI.bat" SET "PHP_FCGI_MAX_REQUESTS=0" SET "PHP_FCGI_CHILDREN=1" START "Blog PHP-CGI" "php-cgi.exe" -b "127.0.0.1:9004" -c "%SystemDrive%\www\php\blog.ini" -q :: End "%SystemDrive%\www\scripts\blog\PHP-CGI.bat" ===== Update ===== "notepad.exe" "%SystemDrive%\www\scripts\blog\Update.bat" @echo off "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" reset --hard "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" pull origin "master" --rebase "%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 :: End "%SystemDrive%\www\scripts\blog\Update.bat" ====== Shortcuts ====== ===== Desktop ===== ==== Update ==== "%SystemDrive%\www\scripts\blog\Update.bat" Blog Update ===== Autostart ===== ==== CGI ==== "explorer.exe" "%AppData%\Microsoft\Windows\Start Menu\Programs\StartUp" "%SystemDrive%\www\scripts\blog\PHP-CGI.bat" Blog PHP-CGI ====== Task Scheduler ====== **** taskschd.msc ===== Update ===== * ''01:30:00 AM'' daily Blog Update "%SystemDrive%\www\scripts\blog\Update.bat" ====== Initial Setup ====== * https://blog.realmofespionage.xyz ====== Settings ====== * https://developer.wordpress.org/advanced-administration/wordpress/update-services/#xml-rpc-ping-services ===== wp-config.php ===== * Add around line 90 ((convenient ''Add any custom values between this line and the "stop editing" line.'')) "notepad.exe" "%SystemDrive%\www\blog\wp-config.php" define( 'WP_AUTO_UPDATE_CORE', false ); ====== Files ====== ===== Backup ===== **** "tar.exe" -czf "%UserProfile%\Downloads\wordpress-files-manual-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "blog" ====== Database ====== ===== Backup ===== **** CD "%USERPROFILE%\Downloads" && "%PROGRAMFILES%\MariaDB 12.0\bin\mariadb-dump.exe" -u "root" -p --opt -r "wordpress.sql" "wordpress" ===== Restore ===== * [[#database|Initial set-up]] "%ProgramFiles%\MariaDB 12.0\bin\mariadb.exe" -u "root" -p --execute="CREATE DATABASE wordpress" "%ProgramFiles%\MariaDB 12.0\bin\mariadb.exe" -u "root" -p "wordpress" < "%UserProfile%\Downloads\wordpress.sql" ====== Quick Commands ====== ===== Scripts ===== **** "explorer.exe" "%SystemDrive%\www\scripts\blog" ===== Bookmarks ===== * https://github.com/WordPress/WordPress/commits/master/