Search code examples
phplinuxubuntuconsolelampp

Execute PHP script on linux with PHP LAMPP service


So, I have that question. I've installed xampp on my ubuntu, and I run my web system from there ( /opt/lampp/htdocs ). I can open my php web systems from navigator with no troubles. So now I want to run a php script from linux console, like this:

php -f file.php

but ubuntu tells me to install php7.0-cli or hhvm packages to run a php script on console. The real question is, that I've installed lampp running php there. Is there any chance to run a php script on console with the lampp's php service? or I have to install those packages for ubuntu anyway?


Solution

  • When you run:

    php -f file.php
    

    from the linux terminal you are excecuting the system php enviroment (in ubuntu you install it using apt-get install), if you need run the script with the LAMPP php environment you must run:

    /opt/lampp/bin/php -f file.php