Sh: Php Command Not Found When Trying to Execute File from Web Broeser

I have one file with code

shell_exec (php test.php)

When I run this file from command prompt, It run successfully and when same file I am trying to run through web browser this will give error as

sh: php command not found.

what can be the issue?

2

1 Answer

Most likely the path for php isn't in the $PATH environment variable used for shell_exec when you are running it from the web server.

Use the full path for the php command, like

shell_exec (/usr/bin/php test.php)

You can use the which command on the command prompt to find the full path for php

which php
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest