| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| servers:windows:nginx:wordpress [2025/02/16 17:00] – 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:11_ltsc|Windows 11]] | * [[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)]] |
| | * [[programs;windows;git|Git]] |
| | * [[servers;windows;mariadb|MariaDB]] |
| |
| ====== Dependencies ====== | ====== Dependencies ====== |
| * https://wordpress.org/about/requirements/ | * https://wordpress.org/about/requirements/ |
| * https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions | * https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions |
| |
| ===== Git ===== | |
| |
| * https://www.git-scm.com/download/win | |
| * Last tested: ''Git-2.48.1-64-bit.exe'' | |
| |
| * Git from the command line and also from 3rd-party software | |
| |
| ===== MariaDB Server ===== | |
| |
| * https://mariadb.org/download/ | |
| * Last tested: ''mariadb-11.7.2-winx64.msi'' | |
| |
| * No Development components or Third party tools | |
| * Use UTF8 as default server's character set | |
| * [x] Enable Networking | |
| |
| ====== Download Source ====== | ====== Download Source ====== |
| |
| "%ProgramFiles%\Git\bin\git.exe" clone --branch "master" --depth "1" --recurse-submodules "https://github.com/WordPress/WordPress.git" "%SystemDrive%\www\blog" | "%ProgramFiles%\Git\bin\git.exe" clone --branch "master" --depth "1" --recurse-submodules "https://github.com/WordPress/WordPress.git" "%SystemDrive%\www\blog" |
| |
| "explorer.exe" "%SystemDrive%\www\blog" | |
| |
| ====== Database ====== | ====== Database ====== |
| |
| "%ProgramFiles%\MariaDB 11.7\bin\mariadb.exe" -u "root" -p | "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" |
| |
| CREATE DATABASE wordpress; | CREATE DATABASE wordpress; |
| GRANT ALL PRIVILEGES ON wordpress.* to 'wordpress'@'localhost'; | GRANT ALL PRIVILEGES ON wordpress.* to 'wordpress'@'localhost'; |
| |
| FLUSH PRIVILEGES; | FLUSH PRIVILEGES;EXIT; |
| | |
| EXIT | |
| |
| ====== Environment ====== | ====== Environment ====== |
| <code> | <code> |
| [PHP] | [PHP] |
| ; Modules | |
| extension_dir = ".\ext" | extension_dir = ".\ext" |
| extension = "curl" | extension = "curl" |
| extension = "openssl" | extension = "openssl" |
| extension = "sodium" | extension = "sodium" |
| zend_extension = "opcache" | |
| |
| ; Settings | log_errors = "Off" |
| error_reporting = "E_ERROR" | error_reporting = "~E_ALL" |
| display_errors = "Off" | display_errors = "Off" |
| | display_startup_errors = "Off" |
| | html_errors = "Off" |
| |
| [Date] | [Date] |
| |
| ===== PHP-CGI ===== | ===== PHP-CGI ===== |
| |
| * :!: ''fastcgi_params'' include hard-coded to nginx version path | |
| |
| "notepad.exe" "%SystemDrive%\www\nginx\default.d\blog.conf" | "notepad.exe" "%SystemDrive%\www\nginx\default.d\blog.conf" |
| |
| <code> | <code> |
| # PHP-CGI | location "~" "\.(php)(/.*)?$" { |
| location ~ \.(php)(/.*)?$ { | fastcgi_split_path_info "^(.+\.(?:php))(/.*)$"; |
| fastcgi_split_path_info ^(.+\.(?:php))(/.*)$; | fastcgi_intercept_errors "on"; |
| fastcgi_intercept_errors "on"; | fastcgi_index "index.php"; |
| fastcgi_index "index.php"; | include "C:/www/nginx/conf/fastcgi_params"; |
| include "C:/nginx-1.27.4/conf/fastcgi_params"; | fastcgi_param "SCRIPT_FILENAME" "$document_root$fastcgi_script_name"; |
| fastcgi_param "SCRIPT_FILENAME" $document_root$fastcgi_script_name; | fastcgi_param "PATH_INFO" "$fastcgi_path_info"; |
| fastcgi_param "PATH_INFO" $fastcgi_path_info; | fastcgi_param "HTTPS" "on"; |
| fastcgi_param "HTTPS" "on"; | |
| fastcgi_pass "127.0.0.1:9004"; | fastcgi_pass "127.0.0.1:9004"; |
| } | } |
| |
| # End</code> | # End</code> |
| |
| ===== Server Block ===== | ===== Themes Deny ===== |
| |
| "notepad.exe" "%SystemDrive%\www\nginx\vhosts.d\blog.conf" | * 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" |
| |
| <code> | <code> |
| server { | location "~" "/wp-content/themes/(twentyeleven|twentyfifteen|twentyfourteen|twentynineteen|twentyseventeen|twentysixteen|twentyten|twentythirteen|twentytwelve|twentytwentyfour|twentytwentyone|twentytwentythree|twentytwentytwo|twentytwenty)/" { |
| listen "443" "ssl"; | deny "all"; |
| http2 "on"; | } |
| server_name "blog.realmofespionage.xyz"; | |
| root "C:/www/blog"; | |
| index "index.php"; | |
| |
| include C:/www/nginx/default.d/blog.conf; | # End</code> |
| include C:/www/nginx/default.d/headers.conf; | |
| |
| client_max_body_size "10M"; | ===== Server Block ===== |
| |
| # add_header Content-Security-Policy "default-src "self"; script-src "self" "unsafe-inline" "unsafe-eval"; style-src "self" "unsafe-inline"" always; | "notepad.exe" "%SystemDrive%\www\nginx\vhosts.d\blog.conf" |
| | |
| | <code> |
| | server { |
| | listen "443" "ssl"; |
| | http2 "on"; |
| | server_name "blog.realmofespionage.xyz"; |
| | root "C:/www/blog"; |
| | index "index.php"; |
| |
| # access_log logs/blog-access.log; | include "C:/www/nginx/default.d/blog.conf"; |
| # error_log logs/blog-error.log; | include "C:/www/nginx/default.d/headers.conf"; |
| | include "C:/www/nginx/default.d/wp-themes-deny.conf"; |
| |
| location / { | # access_log "logs/blog-access.log"; |
| try_files $uri $uri/ /index.php?$args; | # error_log "logs/blog-error.log"; |
| } | |
| |
| rewrite /wp-admin$ $scheme://$host$uri/ permanent; | location "/" { |
| | try_files "$uri" "$uri/" "/index.php?$args"; |
| | } |
| |
| location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { | rewrite "/wp-admin$" "$scheme://$host$uri/" "permanent"; |
| access_log off; log_not_found off; expires max; | |
| } | |
| } | } |
| |
| |
| <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" "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> |
| ===== Update ===== | ===== Update ===== |
| |
| * https://github.com/WordPress/WordPress/commits/master/ | "notepad.exe" "%SystemDrive%\www\scripts\blog\Update.bat" |
| | |
| notepad "%SystemDrive%\www\scripts\blog\Update.bat" | |
| |
| <code> | <code> |
| @echo off | @echo off |
| |
| "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" reset --hard | 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" pull origin "master" --rebase | "%ProgramFiles%\Git\bin\git.exe" -C "%SystemDrive%\www\blog" pull origin "master" --rebase |
| | |
| | :: End</code> |
| | |
| | "%SystemDrive%\www\scripts\blog\Update.bat" |
| | |
| | ===== Back-up ===== |
| | |
| | "notepad.exe" "%SystemDrive%\www\scripts\blog\Back-up.bat" |
| | |
| | <code> |
| | @echo off |
| | |
| | TITLE Blog Back-up |
| | 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" |
| | |
| | ::"tar.exe" -czf "%UserProfile%\Downloads\wordpress-files-auto-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "blog" |
| | ::"%ProgramFiles%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" --opt -r "%UserProfile%\Downloads\%RANDOM%-wordpress.sql" "wordpress" |
| | |
| | :: End</code> |
| | |
| | "%SystemDrive%\www\scripts\blog\Back-up.bat" |
| | |
| | ===== Maintenance ===== |
| | |
| | "notepad.exe" "%SystemDrive%\www\scripts\blog\Maintenance.bat" |
| | |
| | <code> |
| | @echo off |
| | |
| | TITLE Blog Maintenance |
| | CD "%Temp%" |
| |
| "%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" |
| :: End</code> | :: End</code> |
| |
| "%SystemDrive%\www\scripts\blog\Update.bat" | "%SystemDrive%\www\scripts\blog\Maintenance.bat" |
| |
| ====== Shortcuts ====== | ===== Git Fix ===== |
| |
| ===== Desktop ===== | * :!: Set ''user.email'' |
| |
| "%SystemDrive%\www\scripts\blog\Update.bat" | "notepad.exe" "%SystemDrive%\www\scripts\blog\Git Fix.bat" |
| |
| Blog Update | <code> |
| | @echo off |
| |
| ===== Autostart ===== | TITLE Blog Git Fix |
| | CD "%Temp%" |
| |
| "explorer.exe" "%AppData%\Microsoft\Windows\Start Menu\Programs\StartUp" | ::################## |
| | ::# Content Back-up |
| | ::################## |
| |
| "%SystemDrive%\www\scripts\blog\PHP-CGI.bat" | 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" |
| |
| Blog PHP-CGI | ::################## |
| | ::# 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" add "." |
| | |
| | ::###################################### |
| | "%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" 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" 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" 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> |
| | |
| | "%SystemDrive%\www\scripts\blog\Git Fix.bat" |
| | |
| | ====== Task Scheduler ====== |
| | |
| | ===== PHP-CGI ===== |
| | |
| | * Auto-start |
| | |
| | SCHTASKS /Create /SC "ONLOGON" /TN "Blog PHP-CGI" /TR "%SystemDrive%\www\scripts\blog\PHP-CGI.bat" /F |
| | |
| | ===== Update ===== |
| | |
| | * Daily ''02:00:00 AM'' |
| | |
| | SCHTASKS /Create /SC "DAILY" /TN "Blog Update" /TR "%SystemDrive%\www\scripts\blog\Update.bat" /ST "02:00" /F |
| | |
| | ===== Back-up ===== |
| | |
| | * Monthly (3rd) ''02:10:00 AM'' |
| | |
| | SCHTASKS /Create /SC "MONTHLY" /D "3" /M "*" /TN "Blog Back-up" /TR "%SystemDrive%\www\scripts\blog\Back-up.bat" /ST "02:10" /F |
| | |
| | ===== Maintenance ===== |
| | |
| | * Monthly (3rd) ''02:30:00 AM'' |
| | |
| | SCHTASKS /Create /SC "MONTHLY" /D "3" /M "*" /TN "Blog Maintenance" /TR "%SystemDrive%\www\scripts\blog\Maintenance.bat" /ST "02:30" /F |
| |
| ====== 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 ===== |
| |
| * Add around line 90 ((convenient ''Add any custom values between this line and the "stop editing" line.'')) | * https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php |
| | * 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'' |
| | |
| | "notepad.exe" "%SystemDrive%\www\blog\wp-config.php" |
| | |
| | <code> |
| | <?php |
| | |
| | define( 'DB_NAME', 'wordpress' ); |
| | define( 'DB_USER', 'wordpress' ); |
| | define( 'DB_PASSWORD', 'x' ); |
| | define( 'DB_HOST', 'localhost' ); |
| | define( 'DB_CHARSET', 'utf8mb4' ); |
| | $table_prefix = 'wp_'; |
| | |
| | define( 'AUTOMATIC_UPDATER_DISABLED', true ); |
| | define( 'WP_DEBUG', false ); |
| | define( 'WP_DEBUG_DISPLAY', false ); |
| | |
| | define( 'SCRIPT_DEBUG', true ); |
| | |
| | if ( ! defined( 'ABSPATH' ) ) { |
| | define( 'ABSPATH', __DIR__ . '/' ); |
| | } |
| | |
| | require_once ABSPATH . 'wp-settings.php'; |
| | |
| | // End</code> |
| | |
| | ====== Backup ====== |
| | |
| | ===== Folder ===== |
| | |
| | **** |
| | |
| | "tar.exe" -czf "%UserProfile%\Downloads\wordpress-files-manual-%RANDOM%.tar.gz" -C "%SystemDrive%\www" "blog" |
| | |
| | ===== Database ===== |
| | |
| | **** |
| | |
| | CD "%USERPROFILE%\Downloads" && "%PROGRAMFILES%\MariaDB 12.2\bin\mariadb-dump.exe" -u "root" --opt -r "wordpress.sql" "wordpress" |
| | |
| | ====== Restore ====== |
| | |
| | ===== Database ===== |
| | |
| | * [[#database|Initial set-up]] |
| |
| notepad "%SystemDrive%\www\blog\wp-config.php" | "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" --execute="CREATE DATABASE wordpress" |
| |
| <code>define( 'WP_AUTO_UPDATE_CORE', false );</code> | "%ProgramFiles%\MariaDB 12.2\bin\mariadb.exe" -u "root" "wordpress" < "%UserProfile%\Downloads\wordpress.sql" |
| |