change php version in cmd (installed xampp) - php

I have installed xampp version(7.1.9). when I run php info in browser it is show me correct version of php which is 7.1.x. But when i check in cli the version show 5.5.2 and that's why I can not run command of magneto-2 in cli. How I change php version in cli?

Related

Cannot fire php -v from terminal

I have uninstalled XAMPP because recently I found that php comes install by default in macOS. My MacOs version is Catalina. So whenever I fire any php command from cli it gives me Library not loaded but strange thing is it returns XAMP path.

confusion over PHP version in Windows and wamp

I am running WAMP locally and I have phpinfo() showing php version as 5.6.25
windows powershell shows PHP environment variable as C:\wamp64\bin\php\php5.6.25
but when I'm doing php -v the version is showing 7.0.10 and I want the version to be 5.6.* else my Laravel 5.0.* project won't work , so can somebody please tell me which is the correct version of PHP in my system and if it's 7.0 then how to get it to 5.6
phpinfo() showing php version as 5.6.25
it means that php of version 5.6.25 was installed in wamp server as module.when phpinfo() executes webserver looks for php module in apache so it return's 5.6.25
php -v the version is showing 7.0.10
in shell , php version of 7.0.10 was installed as environment variable so it returns php7 .
don't worry php 5 executes when you send request for wamp server
how to get it to 5.6
set php 5 in environment variables by removing php7

Install and configure PHP5 and 7 on same Ubuntu server

I have installed both PHP versions (php5 & php7) on the same Linux server and it works for me, when I switch the version configuration on system.
Also it shows changes happen in the info.php file in the browser, but in terminal using php -v ,it shows only php7 version installed though it works under php5.
how can i correct the version information in php5 while chk in terminal?
When PHP is installed side to side there are different executables for the different versions. When you use a Web Server you choose which version to use via its configuration.
If php -v shows PHP 7 try php5 -v. If this returns the right version you can use php5 to run any script with php5.
To find out where exactly the PHP executables are use:
which php
whereis php
which php7
whereis php7

PHP (cli) version doesn't match XAMPP version I installed

Recently I installed XAMPP for doing local development on my Windows 7 machine. I honestly didn't think PHP was installed at all before hand. I installed the latest version of XAMPP and configured for php 5.6.24. I created some virtual hosts and everything seemed to work.
I was having an issue and I needed to confirm which version of PHP I was using so I opened up my command line and typed php -v. For some reason it is reporting I'm using PHP 5.4.25. The exact line is PHP 5.4.25 (cli) (built: Feb 5 2014 21:19:58)
I don't recall using this version (I had Visual Studio Community installed recently, is that related?). I don't understand either why my CLI is reporting one version, when XAMPP supposedly installed another version. Am I missing something? I need to run some gpm commands for the latest version of Grav CMS but when I do it says it required at least 5.5.9.
It is possible to have multiple versions of php installed.
You will want to ensure that you are executing the php-cli that came with XAMPP.
It sounds like you have another version of php installed and is in your PATH so that when you run php that version is loaded.
You can use the where command to find out what file is being loaded.
From the terminal type: where php
I am not a windows guy but there is a which command on linux. Apparently this is the command for windows. Here is a SO post about it:
Is there an equivalent of 'which' on the Windows command line?
Anyways, you may want to remove that php file and possibly create a symbolic link in its place for the XAMPP version of php-cli
If you remove/rename the file and the new php-cli is not in your path, you will probably get an error as the system will not know what php is.
The solution to this is to uninstall all the xampp's that are installed and then fresh install xampp with php version > 7.
Everything should work fine then.
What happened to me was that I had installed xampp two times. One
xampp on my C:// (version 5.6) and one xampp on my D:// (version 7.2)
When I did the command on my D:// xampp
php --version
It took the xampp php version from the C:// instead of the D://.

Compiling PHP 5.1.6 from source - php -v and phpinfo() version discrepancy

I have just bought a VPS running Ubuntu and I need to install the LAMP stack with PHP 5.1.6. The VPS came with no PHP installed (checked this from the shell with php -v) and with Apache/2.2.12 installed. I installed PHP 5.1.6 from source and compiled it with Apache 2.2 (using libapache2-mod-php5), tried a phpinfo() test which worked fine, however, phpinfo() shows the PHP version as 5.2.1 (with JSON enabled), whereas running php-v in the shell shows as 5.1.6. Anyone any ideas what might be happening here? I need to ensure I am running PHP 5.1.6.
Thanks in advance for any help!
php -v gives you the version of the cli installation of php, while phpinfo will give you the version which got installed as apache module.
If you are not using cli php anywhere, you should be fine with running php scripts off apache.
But ideally you should fix this.

Categories