This page has been translated from English

Articles Comments

Guatewireless.org » Linux , PHP » Installing PHP for command line

Installing PHP for command line

A Does Qui © is PHP CLI?

PHP CLI is a PHP interface for short command line. As its name implies, this is a way to use PHP on the command line system. In other words, it is a way to run PHP scripts that are not on a web server (like Apache or IIS Web server from Microsoft).

The people speak and think in PHP web development, see PHP as a server side tool. However, PHP CLI uses all the advantages of PHP scripts which allow shell scripts to create server-side services or applications to GUI system.

PHP CLI is available for all operating systems: Linux, Windows, OSX, Solaris.

 Why use PHP CLI chemical ©?

You want to use PHP CLI SAPI Just because there are several advantages to being able to run PHP code from the command line such as:

  • No need to learn another development language such as Perl, Bash or Awk
  • Schedule and run tasks from cron written in php
  • Making GUI applications with PHP and GTK
  • Reusing existing components
  • Write robust scripts or scripts for your system using PHP5 ability to multithread
  • Access to STDIN, STDOUT, STERRAD operating system with PHP

The popular Linux distributions (like Ubuntu, Debian, Fedora, Suse, etc) allow you to install PHP CLI from the package manager (eg Synaptic or similar) with a few mouse clicks. This makes trouble-free installation and you can start using in a second!

If you have a standard installation of PHP for the Apache Web server, then there is high probability that you already have PHP CLI installed on your system. The possibilities are even greater if your system is running Linux.

Otherwise, any scrip wanting to run PHP from the command line, Linux will show this error:

  fher98 @ deathbian: ~ $ php
 / Usr / bin / env: php: No such file or directory 

Even 5.2.x installations the only Php Php files in /usr/bin are /usr/bin/php-cgi y /usr/bin/php5-cgi . For I can not run their PHP from the console. To resolve this can create a symbolic link in / usr / bin / from php php5-cgi. After executing the command which php , show them where to find the php.

Installing PHP CLI on Debian / Ubuntu

If you followed the installation guide for Apache / PHP and now want to run PHP pages from the command line is necessary to make the installation of PHP CLI.

  deathbian: ~ # apt-get install php4-cli
 O
 deathbian: ~ # apt-get install php5-cli 

To verify that our installation was successful, type:

  fher98 @ deathbian: ~ $ php-v
 PHP 5.1.6 (cli) (built: July 16, 2008 19:53:00)
 Copyright (c) 1997-2006 The PHP Group
 Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies 

Popularity: 3% [ ? ]

Written by

Passionate about home technology, music, free software and networks.

Filed under: Linux , Php · Tags: linux distributions , fedora core , linux windows , apache web server

9 Responses to "Installing PHP for command line"

  1. Miguel says:

    Hello.

    Stalin Did you get the problem? How?

    To me it's the same.
    Also gives me when I restart the htppd in the file / etc / httpd / logs / error_log and try to load the php_mapscript.ini-

    Thanks for the help.
    Greetings.

    1. Stalin says:

      Hey Miguel ....

      Actually I have not been able to solve the problem ... I'm looking for a solution ....

      If you find something let me know

      1. Miguel says:

        Hello.

        BUT I managed to solve the issue is not what was wrong and out of desperation I started again.

        My solution was:
        - Re-install everything again (with OSs inclusive)
        - Use the latest versions of the libraries that depend or may depend
        - In addition to the libraries compiled Curl and Geos (formerly installations from repositories)

        I think that the problem was not Mapscript (in fact, as they say, from the command line operated correctly), I think the problem was one of the libraries that depend more I searched but found nothing at all.

        Sorry I can not give more information poderte.
        Good luck.
        Greetings.

  2. Stalin says:

    Thanks for responding .... I'm actually trying to install mapserver with support for PHPMapscript and when loading the extension php_mapscript.so is where I produce the problem ...

    When I create a php file with the following contents:

    I return all the information about php.

    The problem arises when I want to load the library php_mapscript.so. For this I make a php file with the following code:

    And that's when the browser returns me the following error:

    Fatal error: Call to undefined function dl () in / usr/local/apache2/htdocs/index1.php on line 2

    Thanks again for your help

  3. Stalin says:

    I really get this error:

    Fatal error: Call to undefined function dl () in / usr/local/apache2/htdocs/index1.php on line 4

    They could tell that this error is due??

    Thanks

    1. fher98 says:

      This error indicates that the function you are calling in line 4 does not exist.

  4. Rodrigo Garcia says:

    estimated

    I have this warning! Please can you help me solve this problem

    root @ you: / # php5-v
    PHP Warning: PHP Startup: Unable to load dynamic library '/ usr/lib/php5/20060613 + lfs / php_mapscript.so' - / usr/lib/php5/20060613 + lfs / php_mapscript.so: can not open shared object file: No such file or directory in Unknown on line 0
    Libclamav Warning: *********************************************** ************
    Libclamav Warning: *** This version of the ClamAV engine is outdated. ***
    Libclamav Warning: *** DO NOT PANIC! Read http://www.clamav.net/support/faq ***
    Libclamav Warning: *********************************************** ************
    Libclamav Warning: *********************************************** ************
    Libclamav Warning: *** This version of the ClamAV engine is outdated. ***
    Libclamav Warning: *** DO NOT PANIC! Read http://www.clamav.net/support/faq ***
    Libclamav Warning: *********************************************** ************
    PHP Warning: Can not load module 'pdo_dblib' Because required module 'pdo' is not loaded in Unknown on line 0
    PHP 5.2.4-2ubuntu5.7 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21 2009 19:52:39)
    Copyright (c) 1997-2007 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans

    1. fher98 says:

      This version of the ClamAV engine is of the outdated is because the clamav antivirus must be updated.

  5. READ says:

    ACTIVATE PHP

Leave a Reply

*

You may use HTML tags and attributes These: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Search Terms

  • php commands (24)
  • php run linux (14)
  • Call to undefined function dl () (14)
  • install php cli (9)
  • run php from console (8)
  • php linux (7)
  • manipulate the Linux console from php (7)
  • run php from linux console (6)
  • php console running ubuntu (3)
  • command to install php on linux (3)
  • run php from console windows (3)
  • run linux command from php (3)
  • how to create a symbolic link in ubuntu 10 10 For php files (2)
  • mozilla run php in ubuntu (2)
  • mapscript php centos (2)
  • / Usr / bin / env php (2)
  • run php from console ubuntu (2)
  • command to install php (2)
  • php execute command line windows 7 (2)
  • install php-cli (2)

  • Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40400932 bytes) in / home / guatewireless / site / wp-content / plugins / google-bot-bling / google-bot-bling.php on line 114