Chapter 11: Application Hosting — WordPress, Flask and Express
11.1 WordPress
In short: WordPress is an open-source content management system (CMS) written in PHP that uses MySQL/MariaDB.
Quick answer: the short, self-contained version of this lesson is the guide How to Install WordPress on AWS EC2 (Amazon Linux 2023).
Why and what
Friends, WordPress is a CMS that runs on PHP and MySQL. Once your blog is on WordPress, posts can be published without writing code.
मित्रांनो, WordPress म्हणजे PHP आणि MySQL वर चालणारा CMS. तुमचा ब्लॉग एकदा WordPress वर आला की कोड न लिहिता पोस्ट्स टाकता येतात.
दोस्तों, WordPress मतलब PHP और MySQL पर चलने वाला CMS. आपका ब्लॉग एक बार WordPress पर आ गया तो बिना कोड लिखे पोस्ट्स डाल सकते हैं.
WordPress is an open-source content management system (CMS) written in PHP that uses MySQL/MariaDB. It powers a very large share of all websites — blogs, college department sites, small business and news portals. Hosting it yourself teaches the complete LAMP/LEMP workflow.
Browser ─► Apache/Nginx :80 ─► PHP (mod_php / PHP-FPM) ─► WordPress PHP files (/var/www/wordpress)
│
▼
MariaDB/MySQL database "wordpress"
Requirements: WordPress currently recommends PHP 8.3 or later, MariaDB 10.11 or later or MySQL 8.4 or later, and HTTPS support. Check the current requirements, OS repository, PHP handler and plugin compatibility for the chosen deployment.
Step 1 — Install the stack
Come on, first plan a WordPress install in a dedicated training environment. Choose a supported PHP and database combination for your OS and test it before opening any public route.
चला, आधी वेगळ्या सरावाच्या वातावरणात WordPress सेटअपची तयारी करा. तुमच्या OS साठी समर्थित PHP आणि database आवृत्ती निवडा. सार्वजनिक मार्ग सुरू करण्याआधी तपासून घ्या.
चलो, पहले अलग अभ्यास वातावरण में WordPress सेटअप की तैयारी करो. अपने OS के लिए समर्थित PHP और database संस्करण चुनो. सार्वजनिक रास्ता खोलने से पहले जाँचो.
Ubuntu (Apache):
On a dedicated Ubuntu setup, choose the supported repository packages for Apache, your selected PHP handler and extensions, and a compatible database or database client. The CLI PHP version can differ from the web handler. Verify the exact running handler and supported versions before installing WordPress.
Amazon Linux 2023 (Apache):
On Amazon Linux 2023, use DNF to inspect the package set available for your repository release. Confirm the selected versioned PHP branch and database meet the desired WordPress requirements. If using a separate managed database, install only what this application host needs.
CentOS Stream 9 (Apache):
On CentOS Stream, verify the available application packages and the effective PHP handler. Check extensions, package support and any enforcing SELinux policy before using the candidate to serve a site. The local Playground lab requires no Linux service installation.
Follow the chosen database’s supported post-installation procedure, account design and network settings for the dedicated host. Keep database access limited to the application and approved administrators.
Step 2 — Create the WordPress database
Create a separate database and dedicated application account, limited to the database and intended connection source. The site needs the privileges chosen for its installation and operation. Use a unique secret delivered through the approved process. Do not share a database administrator identity or a sample password.
Step 3 — Download and extract WordPress
Download the selected release from WordPress.org and extract it in a dedicated candidate directory. Confirm the intended files and configured document root before promoting anything. The practice lab below uses a temporary directory and removes it after testing.
Step 4 — Configure wp-config.php
Start with the packaged configuration template in your candidate and populate its database settings with the approved values. Restrict access to the configuration. Validate the application connection without printing the database password or placing it in shell history.
Use unique WordPress authentication keys and salts through the site’s secret handling workflow.
Keep the configuration’s database passwords and authentication material out of logs, version control and public backup paths.
Step 5 — Ownership and permissions
Friends, check which process handles PHP for this site and which paths it needs to read or write. The account can differ by package and pool configuration.
मित्रांनो, या साइटसाठी PHP कोणत्या खात्याने चालतं आणि त्याला कोणत्या फाइल वाचायच्या किंवा लिहायच्या आहेत ते तपासा. हे खाते package आणि pool नुसार बदलू शकतं.
दोस्तों, देखो कि इस साइट का PHP किस खाते से चलता है और किन फाइलों को पढ़ना या लिखना है. यह खाता package और pool के अनुसार बदल सकता है.
Keep file ownership with the intended deploy account and grant the actual PHP worker only the access it requires. In a managed release workflow, writable paths can include the site’s local uploads while deployed code remains controlled by the deploy account. Check the configuration’s read scope separately.
SELinux: Where it is enforcing, inspect the policy and denial evidence for the exact process, file context or connection that failed. Use a targeted change agreed with the host owner.
Step 6a — Apache virtual host
Apache example. Put the named configuration in the site’s approved include path. The excerpt assumes an existing matching Listen directive, PHP handler and appropriate module configuration. Replace the reserved hostname and example root for the approved setup.
<VirtualHost *:80>
ServerName blog.dairy.example.test
DocumentRoot /var/www/wordpress-example
DirectoryIndex index.php index.html
<Directory /var/www/wordpress-example>
AllowOverride FileInfo
Require all granted
</Directory>
<Files "wp-config.php">
Require all denied
</Files>
</VirtualHost>The same directives can be used in a matching Apache deployment on another OS. Verify where that service reads site configuration and how it invokes PHP before using the example.
Verify that the required rewrite features are loaded and the intended rewrite rules are permitted. The example allows the FileInfo class of overrides for the site. Use a controlled virtual host rule or a more specific override list where appropriate.
Step 6b — Or use Nginx instead of Apache (LEMP)
If Nginx is the site’s frontend, use its named configuration and the actual matching PHP-FPM pool. The excerpt illustrates the routing logic and assumes an appropriate fastcgi_params include, site root and private socket. Test the candidate and preserve other virtual hosts.
server {
listen 80;
server_name blog.dairy.example.test;
root /var/www/wordpress-example;
index index.php index.html;
location = /wp-config.php { return 404; }
location ~ /\.ht { return 404; }
location ~* ^/wp-content/uploads/.*\.php(?:/|$) { return 404; }
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/path/to/approved-site-php-fpm.sock;
}
}PHP-FPM user with Nginx
Find the user and group of the PHP-FPM pool that actually serves this site. The examples above use the lab defaults. For a production site, keep WordPress core and deployed code owned by the deploy account and allow the PHP worker to write only the paths needed at runtime, such as uploads. Use a controlled update process for plugins and themes.
Ravindra Bagale's Tip
Set the intended canonical site URL before using the installer. A literal temporary IP can become part of stored links and redirects. A stable domain can work across an endpoint move when DNS and the frontend are configured for it.
Ravindra Bagale's Tip – मराठी
Installer वापरण्याआधी अधिकृत site URL ठरवा. तात्पुरता IP जर URL म्हणून वापरला तर तो काही links आणि redirects मध्ये राहू शकतो. योग्य DNS व frontend असल्यास स्थिर domain नाव सर्व्हर बदलल्यानंतरही वापरता येतं.
Ravindra Bagale's Tip – हिंदी
Installer खोलने से पहले साइट का आधिकारिक URL तय करो. अस्थायी IP को URL बनाने पर वह links और redirects में रह सकता है. सही DNS और frontend होने पर स्थिर domain नाम सर्वर बदलने के बाद भी काम कर सकता है.
Step 7 — Finish installation in the browser
Open the approved preparation route to finish installation, or use the intended verified HTTPS URL when publishing the real site. Choose a unique administrator password, review the configured site addresses, and verify the named page and administrator login.
WordPress and changing IPs
When the site was installed using a literal IP URL, stored links or redirects can retain it. Review the WordPress Address, Site Address and separate stored references. Back up the site and rehearse a documented migration, including serialization-aware changes where needed. A stable domain does not have to change when its address changes.
WordPress hardening checklist
Friends, the work isn't over once it's installed. Complete this checklist after every install – security is not a one-time job, it's a habit.
मित्रांनो, इन्स्टॉल झालं म्हणजे काम संपलं नाही. ही चेकलिस्ट प्रत्येक इन्स्टॉलनंतर पूर्ण करा – सिक्युरिटी एकदा करायचं काम नाही, ती सवय आहे.
दोस्तों, इंस्टॉल हो गया मतलब काम ख़त्म नहीं हुआ. ये चेकलिस्ट हर इंस्टॉल के बाद पूरी करो – सिक्योरिटी एक बार का काम नहीं, ये आदत है.
- Use a unique strong administrator password and approved account protection. Use appropriately limited roles for routine publishing.
- Keep WordPress core, themes and plugins updated; delete unused ones.
- Restrict access to
wp-config.phpaccording to the actual runtime account and deployment policy. ConsiderDISALLOW_FILE_EDITto disable dashboard theme and plugin editing if the release workflow manages code. - Configure HTTPS on the actual public TLS listener and verify each advertised hostname. Choose its certificate management process based on the hosting architecture.
- Back up the database and files as a consistent recovery set. Include the relevant uploads and protected configuration, then test restore separately. A snapshot of the web server cannot capture an independently hosted database.
- Compare the web server, serving PHP runtime and application upload limits. Test with a harmless file from the actual web path and adjust only the targeted settings in an approved deployment.
Ravindra Bagale's Tip
If a post permalink returns 404, verify the named site and that the post exists. Check the active Apache rewrite configuration or the Nginx fallback to WordPress. Check scoped site rules before changing unrelated server defaults.
Ravindra Bagale's Tip – मराठी
Post च्या permalink वर 404 आला तर योग्य site आणि post अस्तित्वात आहेत का ते तपासा. मग Apache मधले सक्रिय rewrite नियम किंवा Nginx चा WordPress fallback तपासा. इतर sites चे defaults बदलू नका.
Ravindra Bagale's Tip – हिंदी
Post के permalink पर 404 आए तो सही साइट और post मौजूद हैं या नहीं, यह जाँचो. फिर Apache के सक्रिय rewrite नियम या Nginx का WordPress fallback देखो. दूसरी sites के defaults मत बदलो.
Lab
Run the temporary WordPress Playground exercise below. Publish a synthetic pickup notice and write a small test upload. Observe what stays available while the file is withheld, then verify the restored bytes.
Got it? Stack, database, wp-config.php, ownership, vhost and the browser install – these are the six stages of WordPress. Now let's move on to running a Python app in production.
समजलं का? स्टॅक, डेटाबेस, wp-config.php, ओनरशिप, vhost आणि ब्राउझर इन्स्टॉल – हेच WordPress चे सहा टप्पे. आता पुढे जाऊया Python ॲप प्रॉडक्शनमध्ये चालवायला.
समझ आया? स्टैक, डेटाबेस, wp-config.php, ओनरशिप, vhost और ब्राउज़र इंस्टॉल – यही WordPress के छह पड़ाव हैं. अब आगे चलते हैं Python ऐप को प्रोडक्शन में चलाने.
Give the dairy team a way to publish without editing the server
Mauli Dairy publishes its pickup hours on a web page. When a pickup point closes for a holiday, the cashier has to ask a developer to edit the page and put a new copy on the server. This works when the changes are rare. It is frustrating when the hours and announcements change every week. The dairy wants an editor to prepare, preview and publish a notice from a browser. It also needs the published information and the pictures to survive a server change.
WordPress is a content management system, or CMS. It supplies the editor, user roles, publishing workflow and a public website that displays the stored content. An editor can create a draft, review it, and publish it without building a new server or editing its configuration. The person hosting the site still has responsibilities. They prepare the application environment, connect it to a database, decide how updates are installed, and preserve the data that an editor creates.
Follow one example through this lesson. An editor posts “Pickup counter closes at four” and adds a small notice file. A visitor comes to read the post. Part of what the visitor sees comes from records in the WordPress database, and part comes from a file stored with website uploads or in another configured storage service. A backup that captures one part may leave the restored visitor journey incomplete. The lab will write a real post and a test upload in WordPress Playground and show that the two can be lost or recovered separately.
Keep the systems separate in your notes. A web server accepts visitors’ requests and selects the intended website. PHP is the language runtime executing WordPress. MySQL or MariaDB stores the usual self-hosted WordPress database. A separate editing workflow uses WordPress accounts to control who may publish. These components need different evidence when the website stops working. A green screen from the web server alone does not establish that a new notice was published.
Trace a published notice from browser to content store
Start at the public address the dairy prints. DNS gives the browser a way to find the intended endpoint, and the HTTPS listener uses certificate material that is acceptable for that exact host. The frontend selects the web configuration for that hostname. A virtual host or server block is the set of rules for a specific site or listener. The document root is the approved folder where the web server seeks the site’s files. Files from another site using the same machine belong to a different configuration.
If the request is for an existing CSS file or a public upload, the frontend may be able to return the file directly. CSS is the set of rules a browser uses to lay out and style a page. If the request is for a published post path such as /pickup-counter-closes-at-four/, that path usually does not name a folder containing a separate HTML file. The web configuration sends the applicable request to the PHP entry point, normally WordPress’s index.php. WordPress interprets the path and decides which content and theme to use.
With Nginx this typically involves FastCGI and PHP-FPM. FastCGI is the protocol a web server can use to pass a request to a program that executes PHP. PHP-FPM manages a pool of PHP worker processes. Nginx can connect to the intended workers through a Unix socket on the same system or a permitted configured network endpoint. Apache can also run PHP through an appropriate module or FastCGI setup. The web server, PHP worker pool and application code need to agree about the script path and who can read it.
The PHP process loads WordPress, reads its controlled configuration, and asks the database for the records needed to display the notice. The database returns data such as the title and body. WordPress combines it with theme code that decides how to present it. If a displayed page contains a photo URL, the browser typically makes another request for the image. That second request can fail even though the first correctly returned the post text. Look at both when you test a publishing workflow or a restore.
Try drawing individual arrows on paper. Browser to public frontend. Frontend to PHP. PHP to database. Browser to uploaded media. Label the identity and permission required on each arrow. The public visitor should not have network access to the database simply because WordPress does. PHP needs access to just the website resources it uses. A direct application database connection, a PHP worker health indicator and a complete browser result establish different parts of the picture.
For a cache-enabled deployment, a homepage response might be served from a cached copy without going through the same PHP work on each visit. Keep a controlled way to verify the newest content. For example, after the editor publishes the pickup notice, check the exact public permalink and a unique content marker through the intended browser path. If the edit is visible to the logged-in editor but old content remains for anonymous visitors, compare the cache and request context before recreating the post.
Plan versions, files, data and people separately
Start a deployment inventory with the software and its owner. WordPress supplies PHP application files. The active theme describes layout and presentation. Plugins add features and run code within the site. Uploaded files are data created by site users or by the media workflow. The database holds entries, roles, settings and other records. A WordPress user with the editor role is distinct from a Unix account running PHP or a database account reading and writing a schema.
Check support from the actual WordPress requirements page before provisioning. At the time of this lesson, WordPress recommends PHP 8.3 or newer, MariaDB 10.11 or newer or MySQL 8.4 or newer, and HTTPS support. Those are recommendations for a modern hosting environment. An old tutorial finishing installation on much older versions is not a recommendation to use them on a public site. Compare the official release guidance and the compatibility of the actual theme and required plugins. Record specific runtime and extension versions that you intend to support.
Check package availability for your exact operating system and configured repositories. An unversioned package can track a different branch on Ubuntu than on Amazon Linux 2023 or a CentOS-compatible system. The local command php -v tells you the version of the command-line PHP program you invoked. The PHP service handling web requests can use a separately installed version or configuration. Inspect the actual active PHP handler and pool on an authorized host before accepting the CLI display as proof of its version or extensions.
Separate persistent data from deployable code. WordPress core is the packaged application. Themes and plugins may be deployed from a known release inventory. For the typical standard installation, wp-content/uploads contains files created by content workflows, and the database contains media records referring to them. Some deployments store media separately. Inventory where the bytes really live and how the application refers to them. Replacing a site directory without knowing which parts are writable and persistent can remove content the editor created after yesterday’s release.
Place the database with an intentional access boundary. A small training VM can run the application and database together. A production design may use a managed database and private connectivity. The PHP worker then needs the intended hostname, port, authentication and policy for transport verification, and it can use a dedicated application database account scoped to its site database. Avoid using the database administrator account for routine WordPress requests. Plan which identity can change tables during supported installs or upgrades and which actions belong to the database operator.
Prepare the database and application configuration
In a dedicated approved environment, first write the installation goal. Record the intended host and verified HTTPS endpoint, the WordPress release, PHP and web server path, site document root, database product and version, and the owners of release and content. An installation wizard exposed on an unknown public IP can become accessible before you have prepared the new site. Keep the preparation behind the intended access boundary until setup and verification are complete. For a shared host, preserve existing sites and service configuration.
Fetch WordPress from its official distribution and keep a verified release record. Extract files in a controlled candidate directory before deciding which directory the public listener will serve. If you operate the infrastructure, choose supported PHP and database packages for the actual repository and release. Site ownership, service accounts, installed modules and process managers differ by distribution. Do not paste shutdown commands for an unrelated server. Determine the site you intend to operate and what would happen to other virtual hosts before applying a change.
Create a dedicated database and database user according to the database and hosting instructions. An account name and allowed connection source both matter. A MySQL account defined for local use may not be the intended account when PHP connects from a separate private instance. Use a host-specific design and approved credentials. Test the app connection through the same intended path and identity when possible. A root login to the database is an administrative action and tells you little about whether the website account can read its own schema.
The WordPress configuration normally contains database identification and connection details, table prefix and authentication material. wp-config.php is application configuration, so its loading path and file access are part of deployment. The database password and salts should stay out of Git, command history, shared screenshots and unredacted troubleshooting output. An account designed to deploy the app can populate approved secrets through the site's chosen management process. Verify the needed variable names and test connectivity without printing secret values.
When the site is designed behind a proxy, decide who tells WordPress what public scheme and hostname users requested. If a proxy terminates HTTPS and forwards traffic to a private backend, the backend can otherwise mistakenly generate HTTP URLs or redirect repeatedly. Follow the WordPress instructions for the deployment topology and accept forwarded information only through a trusted, controlled proxy path. Do not configure the application to accept arbitrary forwarded scheme or client-address values from any direct network source.
Before opening the installation page, confirm the intended canonical addresses. WordPress’s configured site address and application address can have different purposes in an advanced layout. For a basic installation at the web root, record the intended public hostname and path. Avoid creating absolute links under a temporary public IP when the site is meant to use a stable domain. A managed load balancer or a stable DNS name can be the right architecture without allocating an Elastic IP to the application instance.
Grant the WordPress worker only the access it needs
A permissions problem is a disagreement about which process needs to read or write something. Identify the Unix account and group of the PHP worker handling this site. Ubuntu, Amazon Linux and other distributions can use different defaults, and one server can deliberately use a separate PHP-FPM pool and identity for each site. A process listed as a system administrator is not necessarily the unprivileged worker that handles the request. Read the configured pool and applicable process information before deciding which file owner to change.
The worker generally needs to read core, theme and plugin assets and execute PHP in the intended locations. An approved deployment account may own those files. The application needs write access where the day-to-day workflow creates files, such as its uploads directory if storage is local. Some installations deliberately let WordPress perform updates through a different arrangement, while others publish reviewed updates from a release workflow. Decide the ownership model first. Making the worker owner of all application code turns a file-write problem into a larger permission change.
Electrical switches are an easy analogy. Give the editor a switch for publishing an article and give the runtime access to the storage it needs. Neither role automatically needs the key to the whole building. A world-writable permission mode can mask a specific failed write without showing which account, path or policy was wrong. If uploads fail, check ownership and access on that exact path, parent directory traversal, disk space, upload size limits, and security-policy diagnostics where relevant.
Keep the configuration and recovery artifacts outside public download paths or otherwise explicitly denied by the web configuration. If the frontend serves PHP source as a download because its handler is missing, even a mode that seems appropriate for PHP can lead to exposure through the web process. Test that your actual frontend executes valid scripts through the private handler and does not return sensitive configuration, directory listings or forgotten backups. When loading PHP through Nginx, configure script existence checks and control which paths can run PHP. Treat uploaded user content as data rather than new application code.
SELinux is a separate access decision on distributions and configurations that enforce it. A file can look writable under traditional permissions while SELinux denies a particular labeled process action. Check the configured policy and actual denial evidence. Use the distribution’s supported file context and service policy for the required paths or connections, with authorized and minimal changes. Disabling enforcement or enabling a broad network permission to see whether the page loads makes it harder to explain the intended access later.
Connect WordPress and test the canonical hostname
For Apache, establish the intended host, port, document root and PHP handler. Enable or configure the approved rewrite behavior for pretty permalinks. A rewrite can run in the server configuration or under the limited relevant directory overrides that the administrator has allowed. Apache reads .htaccess only under its active configuration. Giving arbitrary directives permission across the entire shared site is a separate and wider decision. Test the actual configuration and the route selected for the hostname before the approved reload.
For Nginx, establish equivalent name selection, an actual PHP-FPM socket or endpoint, and the intended check for static paths followed by WordPress’s entry point. The web configuration can try the path as a file or directory, then hand the applicable request to index.php and preserve the query. The PHP mapping needs the script filename under the current site root. A copied socket name that is absent on the actual host will fail at the gateway even though the Nginx syntax itself is valid.
Take one practical sequence through the installation. Use the intended private preparation or approved HTTPS path. Supply a strong unique administrator credential and save it under the organization’s control. Create an editor account appropriate for the publishing task. Confirm the home page, a draft preview from an authorized account, an approved post and its public permalink, and a media file. Check an intended anonymous view separately to establish that it displays only what should be public.
A permalink is a planned stable link to a resource such as a post. If the home page works but a new pretty permalink returns 404, compare that exact URL with a simpler supported request for the same post and the logs of the actual frontend. The post might exist while the web server fails to send the pretty path to WordPress. Check which host is in use, then Apache rewrite handling or Nginx fallback according to the architecture. A missing database post, a broken lookup, and a server rule returning a 404 have different evidence.
If the browser redirects to an unintended hostname, inspect the actual redirects and WordPress’s configured addresses. A direct IP change leaves a correctly configured domain URL intact if DNS and hosting still route the domain appropriately. A site initially installed with an IP as its literal public address can still generate links to that old address if the configuration and content were not migrated. Change addresses through the documented WordPress migration procedure using a rehearsal and backup. When doing a database replacement, use a tool that understands serialized PHP data and scope it to the intended tables. A configuration override alone cannot rewrite every stored content link.
For application settings involving uploads, first learn which layer rejects the request. A web listener can enforce a body-size limit before PHP sees the request. PHP can apply both an individual-file and an overall request limit. WordPress or another delivery layer can impose its own policies. Test a harmless file within the intended limit and an intentional larger control case in the approved environment. Verify the actual web handler configuration, because a CLI PHP display might use another file.
Restore the post and its media as one expected experience
Imagine the application host is rebuilt overnight. You have an archive of yesterday’s WordPress files but no current database export. Themes and uploads might be available, yet the editor’s newest notice and settings may be missing. If you instead have the database but have lost the upload storage, the database can tell WordPress what it should display while the corresponding file request fails. A typical full restore needs both sides of that state.
Write down what belongs together. Track a consistent database backup and the relevant files, including required uploads, deployed versions, and protected configuration. If using an external object store, account for that source too. A provider snapshot can help if you understand which volumes or services it covers and how consistency is achieved. A snapshot of the web instance does not automatically capture a separate managed database. Protect backups that contain user data, configuration or secrets with the correct ownership and access settings.
Try the recovery in a separate approved environment and keep the public production route unchanged while rehearsing. Restore the relevant files to the intended location and import the database into the intended matching database deployment. Verify target database and site identity before any import. Check active plugin and theme versions, a selected article, a user flow, a permalink, and its referenced media. A file listing alone cannot tell you whether content, paths and permissions work together. Record the backup timestamps and result from the recovery tests.
Distinguish removing a bad release from rolling back data. Rolling back theme or application files might restore layout without reverting newly published posts. Some upgrades can apply database schema changes, so older code may no longer work with the current data. Restoring a previous database snapshot can also discard changes made after that snapshot. Choose the recovery action based on the outage and the organization’s acceptable data-loss window. Test a compatible rollback or forward fix in a controlled environment before relying on it.
The dairy can turn this into an evidence checklist. Find the latest approved pickup notice by the permalink the editor recorded. Check that the title and text are present, the file the notice links to can be opened, and an authorized editor can preview a draft. Check that a previously public path remains correct after restore. Record who can access and restore the backup without sharing it with unauthorized readers. Assign a later test so recovery continues to be a practiced process after launch.
Publish a real test post and recover its separate upload
Use this local WordPress Playground lab if you have the supported Node.js and WordPress Playground CLI indicated by their official documentation, plus Bash, curl, OpenSSL, awk and tar. The runnable version was designed for Playground CLI 3.1.66, PHP 8.3 in the Playground runtime and the official WordPress 7.1.5 release archive. These versions describe a classroom replay. Check the current WordPress release and official requirements when choosing software for an actual deployment. Carry out the local test in a workspace where a third-party practice runtime is approved.
Playground opens a real WordPress environment inside a PHP WebAssembly and SQLite-backed sandbox. This is a way to observe WordPress’s post and upload behavior without configuring a public web server or MySQL/MariaDB. It is distinct from the production stack explained earlier. The CLI command below runs a blueprint without starting an HTTP listener. A blueprint is the file that tells Playground which operations to perform in its temporary WordPress environment.
Before running the block, predict three results. The article and test upload should initially be present. When the test file is withheld, the article's text should remain available from the database. After restoring the same bytes, the file should be readable again without republishing the article. Use only the lab’s synthetic notice. The scratch directory is created just for this run and removed when the shell block finishes.
(
set -eu
umask 077
lab=$(mktemp -d "${TMPDIR:-/tmp}/wp-classroom.XXXXXX")
trap 'rm -rf -- "$lab"' EXIT
mkdir "$lab/evidence" "$lab/runtime"
# Use the pinned classroom archive, with an optional already-downloaded copy.
if [ -n "${WP_LAB_ARCHIVE:-}" ]; then
cp -- "$WP_LAB_ARCHIVE" "$lab/wordpress.tar.gz"
else
curl -q --fail --silent --show-error --location --retry 2 \
--connect-timeout 15 --max-time 180 \
https://wordpress.org/wordpress-7.1.5.tar.gz -o "$lab/wordpress.tar.gz"
fi
expected_sha=053857d980eaee8702c617c685948becb9be2523ba0dcbc98e4dbb2300367c79
actual_sha=$(openssl dgst -sha256 "$lab/wordpress.tar.gz" | awk '{print $NF}')
if [ "$actual_sha" != "$expected_sha" ]; then
printf '%s\n' 'The archive did not match the pinned classroom release.' >&2
exit 1
fi
tar -xzf "$lab/wordpress.tar.gz" -C "$lab"
cat > "$lab/evidence/check.php" <<'PHP'
<?php
require '/wordpress/wp-load.php';
$post_id = wp_insert_post([
'post_title' => 'Dairy pickup rehearsal',
'post_content' => 'DAIRY_PICKUP_LAB',
'post_status' => 'publish',
], true);
if (is_wp_error($post_id) || !$post_id) {
throw new RuntimeException('Post write failed');
}
$upload = wp_upload_bits('pickup-notice.txt', null, "PICKUP_AT_FOUR\n");
if ($upload['error']) {
throw new RuntimeException('Upload write failed');
}
$file = $upload['file'];
if (get_post($post_id)->post_content !== 'DAIRY_PICKUP_LAB' ||
file_get_contents($file) !== "PICKUP_AT_FOUR\n") {
throw new RuntimeException('Initial read failed');
}
if (!rename($file, $file . '.hold') || file_exists($file)) {
throw new RuntimeException('Could not withhold test upload');
}
if (get_post($post_id)->post_content !== 'DAIRY_PICKUP_LAB') {
throw new RuntimeException('Expected post without its upload');
}
if (!rename($file . '.hold', $file) ||
file_get_contents($file) !== "PICKUP_AT_FOUR\n") {
throw new RuntimeException('Upload restore failed');
}
file_put_contents('/lesson-evidence/result.txt',
"published post: present\n" .
"withheld upload: absent, post still present\n" .
"restored upload: original bytes\n");
PHP
cat > "$lab/blueprint.json" <<'JSON'
{
"steps": [
{ "step": "runPHP", "code": "<?php require '/lesson-evidence/check.php';" }
]
}
JSON
TMPDIR="$lab/runtime" wp-playground-cli run-blueprint --blueprint="$lab/blueprint.json" --php=8.3 \
--mount-dir-before-install "$lab/wordpress" /wordpress \
--wordpress-install-mode install-from-existing-files \
--mount-dir "$lab/evidence" /lesson-evidence
test -f "$lab/evidence/result.txt"
cat "$lab/evidence/result.txt"
)
The shell block downloads an official archive into a new directory, verifies its pinned classroom replay checksum, and gives Playground its own extracted WordPress tree. If downloading is slow, first obtain the exact archive from the official release link and set WP_LAB_ARCHIVE to its absolute path before running the block. The checksum is for this specific archived replay. wp_insert_post creates the published entry. wp_upload_bits creates a separate, small temporary file through WordPress’s upload folder handling. This lab does not create a full Media Library attachment record. A real attachment workflow adds metadata and can generate image variants, which further increases the importance of understanding what must be restored.
Notice which check moves the file. The post is fetched through WordPress’s data access code before and after the file is taken away. When the file is restored from its held path, the expected bytes can be read again. The three printed lines are evidence of those assertions. They do not mean a public endpoint, TLS listener, Apache rewrite, or MySQL production backup was tested. Record those as separate tests for the actual hosting plan. The temporary runtime and evidence are removed at the end, so copy your three-line result into notes if you want to compare it with another group.
If the CLI cannot be found, open the official installation guidance and check the supported Node and package manager versions for that CLI release. Use the actual wp-playground-cli executable in your shell path. A local npm install into your own training directory can put the executable under that directory’s node_modules/.bin. Package downloads can be large and need network access. A download failure does not indicate that WordPress failed to write a post. Read which step stopped and verify the tool and archive are available before changing the PHP checks.
If you prefer a browser, use the official WordPress Playground quick start with a disposable site. Create a post with the lesson marker and upload a harmless photo so you can inspect both in the admin. Preview the post and visit its link while the specific Playground remains open. Follow the documented export and import workflow if you want to recover the exercise in a fresh disposable Playground. This uses a local practice-style environment in the browser. Do not sign into your production site for the exercise, give it real credentials, or assume that exporting this sandbox reproduces a MySQL and file restore for a public deployment.
Try one diagnostic variation in the script after you have seen the expected result. Change the expected upload bytes in the final assertion but leave the originally written text and restored bytes unchanged. Predict that the upload restore test should fail without changing the post. Run the original again so you have a clean result. This makes the content assertion meaningful. A script that always prints “recovery complete” would not detect that error.
Choose the next test from the first failed part of the site
Suppose a new deployment displays the default Apache or Nginx page instead of the dairy catalog. Begin with the full URL, the frontend chosen by normal DNS, and the virtual host associated with that name. Check which document root is actually in use and whether the response matches an unrelated site. Do not modify every configuration file on the host just to make the default page disappear. Preserve the public control routes and test the intended named candidate.
If the frontend returns an upstream error, check which handler is selected and whether it can connect to the PHP-FPM address or socket. A configured Unix socket path is a file-like endpoint to reach the running PHP worker. The path used by Nginx must match the active pool address and its allowed access. A Unix account being able to run a CLI php command does not answer that question. Read the actual web and service logs around the first failure, and do not put material containing credentials on a public troubleshooting page.
If WordPress itself reports a database connection error, confirm that this particular configuration intends to use the database and credentials you are testing. A failed DNS lookup for the database endpoint, a connection refusal, the wrong authentication data and missing database permissions are different problems. Test with the intended application account and connection path in an approved environment, then confirm it can read the database meant for this site. Seeing another database respond with the administrator account does not establish proper service.
If a pretty permalink returns 404 but the post can be loaded by a supported direct URL, inspect the frontend rewrite or fallback. If both return an incorrect post, compare the database the site uses, whether the post is published, and what the route asks for. If the text is present and a file is not, read the actual media URL and its status, then investigate the configured media store. Check which part transfers with the application and which part persists elsewhere before restoring the whole installation.
When an editor can view the post and ordinary visitors cannot, compare permissions, post visibility and cache behavior. A draft or private post is supposed to appear differently according to the kind of request and the signed-in user. If the article is definitely published, inspect the real returned body, cache headers where available and the sequence of the reader’s links. Refreshing one internal browser through an admin session does not establish that the anonymous public path is current.
Show the support team how to describe the recovery. Record the known test article URL, exact title marker, screenshot or response for the harmless upload, and whether the user role or browser path is part of the check. For an upload failure note approximate size and the expected application policy rather than spamming retries with different files. If the issue appeared just after a change, record the candidate software, configuration and data versions. Compare with the last known working state before selecting the narrowest change.
Plan updates and recovery that another operator can repeat
Write one row for the owner of core updates, the owner of plugin and theme selection, and the person empowered to publish. Every plugin installed becomes part of the site’s executable environment. Review the source and supported versions for required plugins, keep them current, and retire unused ones under the approved process. A powerful account should not be the routine authoring identity when a narrower role already meets the publishing need. Use unique strong passwords and organization-approved additional authentication where appropriate.
Separately assign backup, restore and update checks. Put the latest reliable backup time and storage location in the site operating notes with restricted access. Before a plugin or major core update, rehearse with a matching site and representative content. Check the admin screen, a public permalink and one file actually created by the site. A snapshot can restore file blocks, but the complete service may depend on external DNS, certificates, database, media and account settings that each have another owner.
Choose which changes a request authorizes. Publishing a post does not authorize modifying nginx, stopping Apache or changing how an unrelated domain resolves. A site release on a shared host should include before-state backups, named configuration verification and a control check for other approved routes. Preserve in-scope configurations and track how to undo just the relevant change. If a reader’s path fails, choose evidence that helps you restore it without expanding the blast radius.
Produce a small handoff for the next operator. It should state how to know which version is handling requests, which public URL confirms the approved site, how the PHP process reaches the right database, and which restore proves the content is complete. Include a private place for protected recovery references rather than pasting credentials into the handoff. Give a second student the document and ask them to identify the public listener, the PHP worker and the persistent stores. If they confuse any two, clarify those responsibilities before calling the deployment plan ready.
Explain the deployment in an interview
What makes WordPress different from copying static HTML to a server?
WordPress runs an application that can accept edits, store content and assemble a response using PHP, database records and themes. Static assets can still be served directly. I would compare a literal file request with a named permalink and identify which parts of the site depend on the application and persistent state.
Would an archive of the application directory restore a WordPress website?
It can supply files such as code, configuration and uploads. In a conventional setup, the database is stored separately and needs its own consistent backup. I would restore both in an approved environment, then check a known published post and its media to prove that links, permissions and data agree.
Why does the site show a gateway error when Nginx configuration testing passed?
A syntax check establishes that the candidate configuration can be parsed. The actual PHP-FPM pool might be stopped, listening on another socket, or inaccessible to the Nginx process. I would read the configured endpoint, confirm the pool and permissions, and compare the web and PHP logs for the same request.
Why does an old site redirect to its former IP after a move?
It may have been installed under a literal IP saved as one of its URLs. I would confirm the active site addresses and the source of the redirect, then use the documented migration method and a suitable serialization-aware tool for applicable stored URLs. I would also test the proper public domain. An address change by itself does not break a stable domain configured as the canonical URL.
How would you give the PHP worker permission to accept uploads?
Identify the exact worker and storage path. Permit necessary writes to that area with the deployment’s intended ownership and security policy. Keep code and configuration protected. Test a harmless upload through the permitted workflow and confirm which other path or limits would be relevant if it still failed.
Decide which evidence belongs to each problem
The post title loads and a linked image returns 404. Which two observations should you collect?
Answer and reasoning
Verify the expected post content and its actual media URL first. Then confirm the intended storage location has the file and the web path can serve it. Database content and file data can be independently available.
Does CLI
php -vestablish the version serving your site?Answer and reasoning
It identifies the CLI executable. Inspect the actual PHP module or FPM pool serving requests to verify its runtime and configuration. They can differ when multiple PHP versions or modes are installed.
What does the application need to safely access the database from another host?
Answer and reasoning
An authorized private route or other intended service path, appropriate connection transport and a dedicated database identity with the needed permissions, plus correct site configuration. The browser should not connect directly to that database to display a WordPress page.
WordPress is correctly redirected from an old domain to a new one, but the public upload links still use the old value. Will a site-address override repair all media links?
Answer and reasoning
It can affect generated site URLs but cannot be assumed to rewrite every stored reference. Inspect the media references and use an approved backup and compatible migration method to change in-scope stored data.
Why rehearse a restore before relying on it?
Answer and reasoning
It proves the files, database, credentials, routes and compatible application can work together for the intended content. A successful backup job or a directory listing cannot verify a usable site on its own.
Cards for the WordPress operating notes
Frontend, PHP, database
The public frontend selects the site. The PHP runtime executes WordPress. The database supplies content and settings for the request.
Posts and files are separate
Posts live in the database. A deployed site can also depend on uploaded bytes and media metadata that must agree after restore.
Permission belongs to a process
Check the actual worker identity and intended path. Keep write access limited to the locations and operations the deployment requires.
Permalink as a concrete test
Test the real named route and known post marker. A pretty path can fail at the web rewrite stage while the stored post remains.
Verify a restore
Use a compatible backup set and a separate rehearsal environment. Check the actual article, referenced media and a representative editing workflow.
Official references
- WordPress hosting requirements
- Official WordPress releases
- WordPress installation and database setup
- WordPress site configuration and URLs
- WordPress hardening and permissions
- WordPress files and database backups
- WordPress migrations and URLs
- WP-CLI serialized data search and replace
- WordPress with Nginx
- PHP-FPM pool configuration
- WordPress Playground for local browser practice
- WordPress Playground CLI
- WordPress Playground blueprint steps
- WordPress insert-post API
- WordPress upload-file API