PHP- proc_open, getting permission deny when running node command

I know PHP proc_open was in disable function by default, but I enable it and function is available to me. But when I try to run node /htmltopdf.js file which use puppeteer to make PDF file I am getting Permission denied function.

  • I run the command directly on server Shell and it works fine, so I know command is working,
    Now my best guess is SELinux like stuff or some safety feature is avoid it. I am no expert in server so I don’t want to disable any security feature without knowing it.

Can someone please guide me where I should look and for what process/setting

But did you enabled it in both php (fpm and cli)? because I suppose node is using cli. Also, double check the php version used by node, because maybe you enabled proc_open for fpm version 8.3 but node is using php cli default version that is 8.2.

I enable for FPM as I run this in Web browser only using Symphony’ Process library, and if proc_open is not available the library show the same. (that is how I know it is disable) … and proc_open is failing so it is surely executing.

So, it is just that php is in some safe mode or it is not loading the node path.

I woult test enabling it in php cli. Also, check where it is disabled:

grep -r '^disable_functions.*proc_open' /etc/php/

It is enable in both… still same error, and yes I have version 8.3 in command line as well as for web. and PHP info reflect the same (i.e. proc_open is not in disable list) … as I said the function is working otherwise PHP say ‘function not found’ not permission denied to execute command.

What is next step?

Okay, I figure it out. the Node command I was running was in /root folder. and PHP doesn’t have access outside of web root. Even php -v command won’t run.

so I copy the node binaries in accessible path and use the full path to command. it all works now. I secure my binary using htaccess and stuff so I guess I am good for now

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.