node.js serve a wordpress blog

I am using node.js on my rackspace server to serve my various applications. (Using node-http-proxy).

However, i would like to start a wordpress blog. The only way to serve the blog is via apache (or nginx).

Read More

Is there a way to server my wordpress blog from a node.js application itself?

Related posts

Leave a Reply

6 comments

  1. 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.

  2. 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/

  3. I recently needed to get a server within an electron app to serve PHP.
    I started with grunt-php by Sindre Sorhus. The main change I made was to remove the code that kills the server process when grunt is done, instead instantiating the PHP class from JS and calling the process as needed.
    Ultimately, it was very easy to adapt grunt-php to enable PHP on a node.js server.

  4. WordPress now has an “official” (to be precise: open source, under Automattic’s github repo) way to do this: wpcom.js. From that github page:

    Official JavaScript library for the WordPress.com REST API. Compatible with Node.js and web browsers.

    The essence is to call the WordPress REST API from JS.