nginx - Unable to execute command with PHP


This is my php (turnOn.php) :

    system('codesend 6984294');

I have nginx, when I access to it via a web browser the system() does not launch (if I addecho 'something' in the php file it works though). However when I shell this :php turnOn.php it does work.

I thought it was a user privilege issue so I edited my sudoers file with visudo and added this :


I know it's unsafe but it does not work either. I don't know where it can come from.

Any help is greatly appreciated.




I figured out how to solve this.

Thanks to Nic3500 I was able to see that codesend needed to access root commands so I just added sudo before my command :

system('sudo /var/www/html/rf/433Utils/RPi_utils/codesend 6984302');

I finally allowed the right directory in the sudoers file :

www-data ALL=NOPASSWD: /var/www/html/rf/433Utils/RPi_utils/codesend

People are also looking for solutions to the problem: Nginx + php-fpm always returns http 500


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.