Jump to content

php exec() works via cli, not in production

I am writing a Wordpress plugin, and everything has been going smoothly so far.

 

My problem is if i execute "temp.php" in cli it works perfectly. 

<?phpexec("cd /var/www/{lots of layers deep}/; screen -dmS {screen name} ./start.sh");echo "program started!";?>

However, in the production environment (calling temp.php via AJAX) I get the return "program started!" but the screen is never created or the program executed.

 

Does anyone know what i am doing wrong?

 

Thanks,

 

~Judah

~Judah

Link to comment
https://linustechtips.com/topic/243687-php-exec-works-via-cli-not-in-production/
Share on other sites

Link to post
Share on other sites

Try using backslashes when specifying a path.

 

 

I tried this, it didn't work.

 

After more testing, i learned that NOTHING requested from web worked. For example:

Going to */temp.php in firefox fails,

using cli to execute temp.php works.

 

I made sure to turn safe-mode off, and i double checked the permissions of all the files.

Does anyone know of anything else that may be stopping the exec() command from working?

~Judah

Link to post
Share on other sites

I think you can't execute it because of the permissions.

 

If you're running the server as admin, then you can only use directories for the user admin. Also, if the user is being run as root, then (if you're using apache) it will not serve it. (It will throw an error if you try a root user). You can edit the user in the httpd.conf file.

 

If for some reason you need apache to run as root, set the environment variable: env CFLAGS=-DBIG_SECURITY_HOLE

 

(Rebuild if you changed the variable)

 

=====

 

You said that you checked some permissions. What permissions did you check?

I'm probably playing a game right now...

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×