Vagrant uses old php version - php

Can't find this online, probably not describing it properly because I'm pretty sure I am not alone with this problem.
I have vagrant running for a few months now, with PHP 5.6. Now I upgraded to PHP 7, but when I request my php -v inside Homestead in Terminal it still gives me version 5.6.
When I request my PHP version with this snippet <?php phpinfo() ?> inside a webpage I DO get version 7.
Is this normal or am I forgetting something?
Thanks
UPDATE
I have version 7.0 in my vagrant ssh right now. But apperently there is a different environment for ssh, ftp, code, ...
How do I set all of these versions to the same (obviously the latest 7.0 version)

Try this and if it's the right path of php7 you can use php7.0 instead of php
/usr/bin/php7.0 -v

Related

Ubuntu VirtualMin - Won't see PhP Versions

I have a fresh ubuntu server installed with virtualmin. It autoinstalls Php version 7.2, I need 7.4. So I install 7.4. When I check the version with -v it shows 7.4. However, webmin and wordpress both still see and use only 7.2. I've tried uninstalling 7.2 but the command fails and tells me that module doesn't exist when I can show it in the list of installed versions in ssh. Its just not showing up as an option in virtualmin when I go to change the php version. Only showing 7.2.
Any advice on where I should be looking to resolve this? I'm feeling stumped. Thanks!
You can try with below command :
sudo update-alternatives --set php /usr/bin/php7.4
For more details you can refer below link as well :
https://hackthestuff.com/article/how-to-change-php-version-from-command-line-in-ubuntu
The right way of changing PHP version for the given virtual server in Virtualmin is done using Server Configuration ⇾ PHP Options page.
Using update-alternatives command will change default PHP (CLI) version system-wide. It won't be applied to virtual-servers.
You may find our Virtualmin Community forum helpful.

Minimum PHP version...!! CakePHP 3.4.7 (Wamp / Xampp)

I Hope you can help me. I'm trying to "Cake bake" my proyect in the cmd, but it always says
Minimum PHP version: 5.6.0. You are using: 5.5.12.
Actually I'm using the 7.1.10 version of php. I've been testing with Xampp and Wamp both with a 7.x php
My cakePhp version is 3.4.7, and I don't know if I need to change some file.
Thanks
Converting my comment to an answer:
It's entirely possible to have a different version of PHP on the webserver and the command line. Ensuring the version is the one you expect can be done by php --version (CLI) or outputting phpinfo() (on the webserver).
In this case, CLI needs to be updated to match the webserver.

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