How can I debug exec() problems?

后端 未结 4 711
情深已故
情深已故 2020-11-22 00:47

The exec command doesn\'t work on my server, it does not do anything, I\'ve had safe_mode off, and verified that all the console commands are working, I\'ve tried with absol

4条回答
  •  面向向阳花
    2020-11-22 01:12

    have a look at /etc/php.ini , there under:

    ; This directive allows you to disable certain functions for security reasons.
    ; It receives a comma-delimited list of function names. This directive is
    ; *NOT* affected by whether Safe Mode is turned On or Off.
    ; http://www.php.net/manual/en/ini.sect.safe-mode.php#ini.disable-functions
    disable_functions =
    

    make sure that exec is not listed like this:

    disable_functions=exec
    

    If so, remove it and restart the apache.

    For easy debugging I usually like to execute the php file manually (Can request more errors without setting it in the main ini). to do so add the header:

    #!/usr/bin/php
    ini_set("display_errors", 1);
    ini_set("track_errors", 1);
    ini_set("html_errors", 1);
    error_reporting(E_ALL);
    

    to the beginning of the file, give it permissions using chmod +x myscript.php and execute it ./myscript.php. It's very heedful especially on a busy server that write a lot to the log file.

    EDIT

    Sounds like a permissions issue. Create a bash script that does something simple as echo "helo world" and try to run it. Make sure you have permissions for the file and for the folder containing the file. you chould just do chmod 755 just for testing.

提交回复
热议问题