How to execute PHP scripts via CLI?
February 17, 2013 01:15PM
On my Raspberry Pi with Raspbian OS (Debian optimized for Raspberry Pi) I've installed Nginx + MySQL + PHP.
Nginx + PHP (using php5-fpm) seem to work well as I can retrieve HTML / PHP files from my browser.

At another machine with Debian & Apache, I can run PHP scripts from the command line using the command:
$ php /var/www/myscript.php
When I want to add that script to crontabs I have to include the path to PHP:
/usr/bin/php /var/www/myscript.php

On my Raspberry Pi when I try
$ php /var/www/myscript.php
I get the error "-bash: php: command not found" and with
$ sudo php5-fpm /var/www/myscript.php
I get the help screen of php5-fpm

How can I start PHP scripts from the command line?
Do I have to find the full path to PHP?
Or do I have to include some configuration settings for CLI to my /etc/nginx/sites-available/default ?

Thanks in advance!

-------------------------------------------------------------------
Peter Martin, Joomla specialist www.db8.nl
Raspberry Pi with Raspbian Linux + Nginx + PHP (with php5-fpm) + MySQL
Re: How to execute PHP scripts via CLI?
February 17, 2013 02:33PM
Nevermind...

I discovered that I hadn't installed "php5-cli", and fixed it with:
$ sudo apt-get install php5-cli

-------------------------------------------------------------------
Peter Martin, Joomla specialist www.db8.nl
Raspberry Pi with Raspbian Linux + Nginx + PHP (with php5-fpm) + MySQL
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 119
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready