Ejecute el archivo php a través de la línea de comando en un servidor ubuntu linux

I am trying to run a php file on a ubuntu linux server but get a 'command not found' error when i run "php file_name.php"

Searching online, i found an article that suggested I run "sudo aptitude install php5-cli" which I did and restarted apache afterwards but I still get this error.

¿Cómo puedo solucionar esto?

preguntado el 28 de agosto de 12 a las 11:08

Please paste output of following commands: "dpkg -L php5-cli" and "update-alternatives --list php" -

Package 'php5-cli' is not installed while the update-alternatives gave error no alternatives for php -

That means you do not have PHP installed. What were you expecting to happen? -

3 Respuestas

Try this once,

Ve a la terminal.

whereis php

It will show where is php installed.

Export that path to environment variable using following command

export PATH=$PATH;/path/to/php's/bin directory

Then execute required file..

Como sigue,

php file_to_execute.php

Respondido 28 ago 12, 11:08

first make sure that you've installed following packs:

  • php5
  • php5-cli
  • php-pera

Me gusta esto:

sudo apt-get install php5 php5-cli php-pear

then make sure to configure php safely befor using it.

also make your php file executable ( chmod 700 )

Respondido 28 ago 12, 11:08

  • Try the following step :
  • Open your cmd/console or press ctr+alt+t.
  • php5 /your/path/to/php_file_name.

Respondido 04 Oct 13, 05:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.