简体   繁体   中英

Execute node script in php from remote server

I have a web application that interacts with API. In html file is an element with onclick property for this function:

function executePHP() {
   $.ajax({
       type: "POST",
       url: 'index2.php',
   });

}

Then index2.php has written only this code:

<?php exec("/usr/local/bin/node script.js"); ?>

The script.js is just a file which is executed. Everything works fine on my maschine when using MAMP. However when I upload it on real server and open the website the script.js isn't executed. And I didn't forget to change the url for the real one once I was testing it. Any clues where the problem is?

Basically, I just need to execute node script.js when the button is clicked

After the discussion with an expert in this field I can answer my question. This code can't be executed on basic shared server, therefore VPS (virtual private server) is needed.

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