1

I'm trying to be able to run php scripts on my vps. I do have php5 installed but when I run the php file it says

/usr/bin/php: bad interpreter: No such file or directory

so I typed whereis php5

and the output is:

php5: /etc/php5 /usr/lib/php5 /usr/share/php5

Question is: what do I do at this point to make a php file run?

the top of my php file, what should i have? #!/etc/php5?

dukevin
  • 22,384
  • 36
  • 82
  • 111
  • Use `which php5` for finding the interpreter. It also can just be called `php` or `php-cgi` or `php-cli`. And it's not present if you have only the `mod_php` version installed. – mario May 15 '11 at 08:40
  • @mario when i type `which php5` i get no output – dukevin May 15 '11 at 08:42

1 Answers1

4

Then you don't have it installed. The commandline or CGI version can be installed with:

sudo apt-get install php5-cgi

Or -cli if it's only for console scripts, and you already have mod_php running for Apache.

mario
  • 144,265
  • 20
  • 237
  • 291
  • I think it does not create a default symlink in the Debian package. The binary will be called `/usr/bin/php5-cgi`. It's only the `php5-cli` package which provides `/usr/bin/php5` sans extension. – mario May 15 '11 at 08:49
  • ok so on top of my php file I'd like to run, I have `#!/usr/bin/php5-cgi` ? – dukevin May 15 '11 at 08:51
  • Yes, that would do. For parity with the CLI version, you'd use `#!/usr/bin/php5-cgi -qC` however. – mario May 15 '11 at 08:53
  • It works good execpt one thing; it gets stuck and displays a bunch of weird messages: http://pastebin.com/1Snn1egW is it because I am using cli? should i use something else? – dukevin May 15 '11 at 09:10
  • That's indeed odd. Never seen anything like that. Try installing the php5-cli package then alternatively. – mario May 15 '11 at 09:22