node.js serve a wordpress blog node.js serve a wordpress blog wordpress wordpress

node.js serve a wordpress blog


You need some server running to execute the PHP. Node is JavaScript.

Whether that's apache, or nginx/php-fpm or just php-fpm, you need something to actually run the wordpress code, then use the same proxying system you are using now.


One option is to continue to use Wordpress as you normally do, but instead of writing the templates to output HTML, you make them output JSON. With this minor trick, you suddenly have created your own API to output your wordpress content. In contrast with the modules that expose wordpress complete set of methods, this will create your very specific output, tailored after your needs.

To consume your JSON output, you set up a small nodejs server that forwards each call directly to your Wordpress solution, takes the response (JSON) and merges it with your html using whatever javascript template engine you like. You also gain speed, since you can cache the JSON result pretty easily on the node side, and control.

I've written a blogpost about this if you like to read more, and also created a nodejs express middleware to help setting up the node side.

http://www.1001.io/improve-wordpress-with-nodejs/


You can try express-php-fpm package.

It combines Express (Node.js server) and FastCGI gateway to serve php requests.