brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp server runs a WordPress site on PHP's built-in web server

WordPress
~/tips/tip-wordpress-wp-server-local

wp server --host=127.0.0.1 --port=8080

Starts a quick local web server for a WordPress folder without Apache or nginx.

For a quick look at a local copy of a site, setting up a web server feels like overkill to me. PHP has one built in, and WP-CLI wraps it.

From the WordPress folder:

wp server --host=127.0.0.1 --port=8080

Open http://127.0.0.1:8080 and the site is there. Stop it with Ctrl+C. Port 8080 and localhost are the defaults, so plain wp server works too. --docroot points it at another folder, and --config loads a php.ini of your own for things like a higher upload limit.

The database still has to exist and wp-config.php has to point at it. Also check siteurl and home: if they say https://www.example.com, WordPress redirects you there. For a local copy, set them with wp option update, or define WP_HOME and WP_SITEURL in the config.

I’d keep this server to development only. It runs one PHP process, it ignores .htaccess, and it was never meant to face the internet. Binding to 0.0.0.0 makes it reachable from your whole network, so stick to 127.0.0.1 unless you really want that.

Further reading: wp server, PHP built-in web server

Going deeper: Guide: let git bisect find the commit that broke your code

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link