0

I'm trying to execute a nodejs file from php on a Centos server. When the command is executed from the terminal it works fine (also after switching to apache user with the following command su -s /bin/bash apache), but when the code is executed while browsing the file it throws the following exception:

["","","#","# Fatal error in , line 0","# Check failed: SetPermissions(protect_start, protect_size, PageAllocator::kReadExecute).","#","#","#","#FailureMessage Object: 0x7fffd9b37760"]

  • I have changed also to absolute path, but no luck.
  • Gave 777 permission to index.js file.
  • Testet from terminal and works fine:

php -r 'echo exec("/usr/bin/node /var/www/html/index.js /var/www/html/source_files/ 2>&1");'

 <?php
 try {
       exec("/usr/bin/node /var/www/html/index.js /var/www/html/source_files/ 2>&1", $out, $err);

        if ($err == 0) {
            return 1;
        } else {           
            return 0;
        }
    } catch (Exception $e) {
        error_log($e);
        return 0;
    }
?>

1 Answer 1

2

If you are using selinux, try disabling it temporary:

setenforce 0

Try to run your node.js script. If it run, you probably need to change selinux httpd settings. Do following command to list all selinux settings for httpd service:

/usr/sbin/getsebool -a | grep httpd

You will see two relevant settings httpd_ssi_exec and httpd_execmem. Set them on with:

setsebool -P httpd_ssi_exec=1
setsebool -P httpd_execmem=1

After that try to enable selinux again and run your node.js script to see if the change helped:

setenforce 1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.