简体   繁体   中英

How can i set up a node js script to run in a PHP cURL ?

My problem:

I have a live website in Wordpress(php) and i want to given a user action, i will send a data for a node.js script to run and return the results. So i have this: User Event -> jQuery -> PHP CURL -> NODE.JS -> NODE.JS ANSWER TO CONTINUE PHP SCRIPT.

my question is how i set up a node.js server to run only this specific script, can i do it in my current wordpress server(apache)? or i have to hire a new hosting to have it ?

Please any resource is valid, i don't known if i'm doing the right question on my google search..

Thank you!

Node.js doesn't need dedicated web server like Apache. You should just create a node.js app and then just start it from command line on specific port, for ex. 8080 or 3000.

You need to have ssh for setting up nodejs. If you are using shared hosting, it might be unavailable. In this case you will need to get VPS/VDS server for it.

You can check this guide for start: https://nodejs.org/en/docs/guides/getting-started-guide/

You could use a AWS Lambda with or without API Gateway for this. Your PHP makes a HTTP request, or you can use AWS Sdk to invoke the Lambda function.

No servers, you are only billed when your script is running.

Another alternative might be spinning up a docker container running node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM