3

How to run php cli right in Ubuntu 16.04?

When I enter the command php file.php always out the error

Could not open input file: file.php

How can I fix it?

sotirov
  • 4,379

1 Answers1

1

You run php files files by invoking the interpreter which is php.

So in your example it would be:

php file.php

You can also have a look at the php which you have available:

update-alternatives --list php

This also shows you the direct path to all your php version which you can also use to run your php scripts.

Also make sure you have read rights on that file as the user you run php with.

chmod a+r file.php

You can alternativly also add a shebang to the php file. In the first line of your file add this:

#! /usr/bin/php

Then make the file executable and run it without php.

./file.php
Ziazis
  • 2,184