Node.js serves wordpress blog

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

However, I would like to start a Wordpress blog. The only way to serve the blog is through apache (or nginx).

Is there a way to start my Wordpress blog from node.js app itself?

+6
source share
5 answers

You need a server running PHP. Node is JavaScript.

If it is apache or nginx / php-fpm or just php-fpm, you need to actually run something in Wordpress code and then use the same proxy system that you are using now.

+4
source

One option is to continue using Wordpress as usual, but instead of writing templates for HTML output, you make them JSON output. With this little trick, you suddenly created your own API to display your content in Wordpress. Unlike modules that provide a complete set of wordpress methods, this will create your very specific result tailored to your needs.

To use your JSON output, you set up a small nodejs server that forwards every call directly to your Wordpress solution, accepts a response (JSON) and combines it with your html using any JavaScript template engine. You also get speed, since you can easily cache the JSON result on the node side and manage.

I wrote a blogpost about this if you like reading more, and also created nodejs express middleware to help set up the node side.

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

+2
source

I found this node module while searching for Wordpress + Node:

https://github.com/scottgonzalez/node-wordpress

I have not tried, though, but if you know what you are doing, you may want to give it away.

+1
source

Recently, I needed to get a server in an electronic application for servicing PHP. I started with grunt-php from Sindre Sorhus. The main change I made was to remove the code that kills the server process when grunt is executed, instead instantiating the PHP class from JS and calling the process as necessary. Ultimately, it was very easy to adapt grunt-php to enable PHP on node.js.

0
source

You can try express-php-fpm package.

It combines Express (Node.js server) and FastCGI gateway for serving php requests.

0
source

Source: https://habr.com/ru/post/922123/


All Articles