简体   繁体   中英

Linux execute file using PHP (XAMPP)

This is way harder than it looks like, I think I am encountering some kind of permission problems, but do not know what to do. For testing purposes I'm using 777 permissions for all files.

I want to start an executable file using PHP.

I tried:

<?php
echo system('./FieldTheory');
echo shell_exec('./FieldTheory');
echo exec('./FieldTheory');
?>

but none of them actually execute the file. However I tried executing simple shell script using system('./script.sh'); :

#!/bin/sh
echo "Hello"
/FieldTheory
./FieldTheory
/opt/lampp/htdocs/FieldTheory
./opt/lampp/htdocs/FieldTheory

I see the "hello message" but my file is not being executed.

If I execute the file using terminal command: php testfile.php my program is being started without difficulties.

EDIT : I tried absolute paths with no effect.

Double check you php.ini and make sure the exec functions are not disabled:

May have a line like this:

disable_functions =exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM