3

Here is my code:

<?php
$output = exec('/bin/bash /var/www/html/test.sh');
echo "<pre>$output</pre>";
?>

Here is what i have in test.sh:

#!/bin/bash
export DISPLAY=:0
google-chrome
echo "Starting Chrome"

When i execute ./test.sh google-chrome is started and then i see in my terminal the text Starting Chrome.

However when i execute the php script i see only the text Starting Chrome. Why google-chrome does not start when the test.sh is called by apache2 ?

I think there is something regarding permissions.

Is it even possible to achieve such thing somehow ?

5
  • 1
    Remember, Apache does not run under your account, it has its own. Commented Jun 22, 2017 at 8:12
  • If i switch apache to run with my account is it going to start it ? Commented Jun 22, 2017 at 8:13
  • No you need to make sure the Apache account can launch Chrome. The apache account is normally very restrictive, for obvious security reasons Commented Jun 22, 2017 at 8:16
  • Executing a Bash script from a PHP script Commented Jun 22, 2017 at 8:20
  • Is google-chrome a function or an executable? Commented Jun 22, 2017 at 12:20

1 Answer 1

0

Use this exec("google-chrome https://www.google.com");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.