sloth456 Posted August 20, 2011 Share Posted August 20, 2011 Hi guys, I'm trying to run a php script from command line in linux. I installed xampp for linux a.k.a lampp so typing php /path/to/file.php Just brings up a message saying I need to install php. Whats the correct way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/245290-run-php-from-command-line-xampp-for-linux/ Share on other sites More sharing options...
codefossa Posted August 20, 2011 Share Posted August 20, 2011 Then, you should probably install PHP. Most distros give you the command you need. Ubuntu for example would say to use "sudo apt-get install <package>". Quote Link to comment https://forums.phpfreaks.com/topic/245290-run-php-from-command-line-xampp-for-linux/#findComment-1259852 Share on other sites More sharing options...
sloth456 Posted August 20, 2011 Author Share Posted August 20, 2011 Thanks for your reply Kira, however php is installed, I have xampp. I can run php scripts in my browser from localhost fine just don't know how to run scripts from command line. I think xampp installs php to a different directory than normal. Quote Link to comment https://forums.phpfreaks.com/topic/245290-run-php-from-command-line-xampp-for-linux/#findComment-1259870 Share on other sites More sharing options...
sloth456 Posted August 20, 2011 Author Share Posted August 20, 2011 figured it out myself in the end. For those wondering how you need to type path/to/php path/to/fileyouwantotrun.php So for xampp on linux this is /opt/lampp/bin/php /opt/lampp/htdocs/yourfile.php This worked for me Quote Link to comment https://forums.phpfreaks.com/topic/245290-run-php-from-command-line-xampp-for-linux/#findComment-1259872 Share on other sites More sharing options...
codefossa Posted August 20, 2011 Share Posted August 20, 2011 You didn't give your distro or version, so there wasn't much more I could tell ya. There's different packages though. In Ubuntu, the package "php" is the one you can run in terminal with "php path/to/file.php", and "php5" is the one that runs with Apache. Glad ya got it. Please tick this thread solved. Quote Link to comment https://forums.phpfreaks.com/topic/245290-run-php-from-command-line-xampp-for-linux/#findComment-1259883 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.