Wednesday, July 29, 2009

Using PHP from the Command Line (Terminal) in Linux with a xampp install

This is for those who are using the xampp server. If you are using the Generic Linux apache and PHP packages, use you package manager to download php-cli .

If you are using xampp, you already have the php-cli library. In the terminal, type:

/opt/lampp/bin/php {input file} {arguments}

Done! If you don't like using /opt/lampp/bin/php every time, you can set php as an environment variable for /opt/lampp/bin/php.

To do this, go to terminal and type:

php=/opt/lampp/bin/php
export php

if you are using Bash Shell (the default one in Ubuntu), you can use this shortcut:

export php=/opt/lampp/bin/php


and reboot.

now you can use

php {input file} {arguments}

1 comment:

  1. OK. Thanks for this useful information. Now testing some php codes from CLI. This process is most easy if we install 'tasksel' and then from the Terminal we input: sudo tasksel install lamp-server

    ReplyDelete