I'm setting a new web server. I have NGINX with php-fpm on ubuntu 16.04. Everything works great except one thing: after 2-3 days of correct working PHP can't run any external system command. What do i mean when i say "system command"? For example when i run function shell_exec with argument 'whoami'
echo shell_exec('whoami');
i get the following
Warning: shell_exec(): Unable to execute 'whoami'
And it happens for every Linux command that php script tries to execute
When i trying to send mail using the mail() function i get a similar error
Warning: mail(): Could not execute mail delivery program '/usr/sbin/sendmail -t -i '
It happens only when i run PHP-script from browser. If i try to run it from terminal like so
sudo -u www-data php /path/to/my/script.php
then everything works OK.
Again: the problem appears only after some time of correct working and disappears(for some time) after VDS restart. It appears only when i run a script from browser, that means it served by NGINX.
Please, help me find a solution for my problem.
P.S Logs: Php errors logs
[27-Aug-2016 04:19:37 Europe/Moscow] PHP Fatal error: Uncaught Error: Call to a member function is_logged() on null in /home/serv/www/templates/page_parts/header_tpl.php:6
Stack trace:
#0 /home/serv/www/templates/index_tpl.php(9): require()
#1 /home/serv/www/php_classes/templater_class.php(116): include('/home/serv/www/...')
#2 /home/serv/www/functions.php(827): templater->load_template()
#3 /home/serv/www/functions.php(804): error_wrong_csrf()
#4 /home/serv/www/index.php(16): csrf_check_post('1b46edd81f1563a...')
#5 {main}
thrown in /home/serv/www/templates/page_parts/header_tpl.php on line 6
[27-Aug-2016 04:19:48 Europe/Moscow] PHP Warning: mail(): Could not execute mail delivery program '/usr/sbin/sendmail -t -i ' in /home/serv/www/php_classes/mail_class.php on line 84
[27-Aug-2016 04:27:42 Europe/Moscow] PHP Warning: shell_exec(): Unable to execute 'whoami' in /home/serv/www/test_mail.php on line 29
Syslog:
Aug 27 04:39:01 frankfurt CRON[30551]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean)
Aug 27 04:39:01 frankfurt CRON[30552]: (root) CMD ( test -x /etc/cron.daily/popularity-contest && /etc/cron.daily/popularity-contest --crond)
in php7.0-fpm.log there is nothing from today