If I run "phpbrew switch 5.6.3" followed by "php -v", i get 5.9.3 (PHP System Version) as current PHP Version.
If I run phpbrew "use 5.6.3", i also get 5.6.3 with php -v.
Is there any solution for this problem? PHP version 5.6.3 is installed and built with phpbrew and working after using the use command.
I am using Elementary OS Freya (Ubuntu 14.04) with the latest phpbrew version.
If you are getting a red error line "You should not see this, if you see this, it means you didn't load the ~/.phpbrew/bashrc script, please check if bashrc is sourced in your shell.", then you need to run source ~/.phpbrew/bashrc. It's also a good idea to run echo "source $HOME/.phpbrew/bashrc" >> ~/.bashrc, so that in the future this will be automatic.
Related
I am developing a PHP project. I am using Mac OS X now. To be honest, this is the first time developing a PHP project using Mac. I am a Windows. I installed PHP using Brew by running the following command.
brew install php
It gave me the php latest version, 7+. For my project, I need to use php version 5.6. So, I installed another PHP by running this command.
brew install php56
Up until this point when I enter "php --version" in the terminal, it is showing that I am using php version 7+. I found some solution to change php version and so I used one of them and run this command.
alias php='/usr/local/etc/php/5.6/php'
After running that command, when I type in "php --version" in the terminal, it is showing this error.
-bash: /usr/local/etc/php/5.6/php: No such file or directory
Now, I cannot use any PHP on my Mac right now. How can I fix that?
I installed Visual Code Studio w/ESLint. It won't operate because it is reporting "Language server needs at least PHP 7 installed. Version found: 5.5.38". After researching, I discovered that it seems to be looking at the pre-installed MAC OSX php version. I downloaded and ran PHP 7.1 onto the Mac, changed the PATH variables in ~/.profile, as recommended. I made sure that the LoadModule php5_module ... line in /etc/apache2/httpd.conf was commented out, and restarted (reboot of machine). When I do: > php -v it yields the new version (7.1), but the error report from VSC is the same. What am I missing?
I'm not necessarily sure what you're missing, but I'd use Homebrew, then once installed type the following into terminal to install php 7.1
brew install homebrew/php/php71
You can use the following to switch between versions:
brew unlink php71
And then to link (and vice versa):
brew link php55
To get the version of the PHP that is currently in PATH, type
php --version
Trust me, I've been doing LAMP development for seven years and it's a pain to not use Homebrew if you're using a Mac. I've also used VS Code before I started using PHP Storm, and this method worked for me.
I am quite new to CentOS.
On my CentOS web server I have PHP 5.4.16 as a native PHP version though I also have alternate PHP version 7.0.
I am trying to install xDebug for PHP 7.0 following the instruction on https://xdebug.org and one of the steps is to run
./configure
When I run ./configure command I am getting error message:
not supported. Need a PHP version >= 5.5.0 and < 7.2.0 (found 5.4.16)
So my question is how do I tell ./configure to use alternate PHP version 7.0?
If you run php -v on command line, it will output the version of PHP it is currently on your PATH. My guess is that it will return the older version of PHP as the result.
The quick and dirty way to try and get it to use version 7.0 for your current shell session would be to run the following
set PATH="/your/path/to/php7/bin:$PATH"
php -v
//Should output version 7.0
You could also try checking in /usr/bin or /usr/local/bin to see exactly which PHP binary it's pointing to, and manually change the location that the symlinks are pointing to.
Another option would be to try creating an alias in your ~/.bashrc file for PHP by editing the file and adding the following to the end:
alias php="/your/path/to/php/7/bin/php"
Then restart your shell session (i.e. close an & re-open PuTTY or whichever SSH client you're using).
Now type php -v and you should see it change to version 7.0.
When I run php -v in cli I get the exact php version 7, but when i run exec("php -v") in web server I get php 5.5 even thought in phpinfo i see that I am runing php 7?! Any idea why I get the older version of PHP?
running exec you get the CLI version of PHP
you probably installed php5.5 as CLI and php7 as apache module
If you use CentOs, add this line at the end of /etc/bashrc (or ~/.profile for Ubuntu)
export PATH=$PATH:/your/path/to/php7/bin
Then run:
source /etc/bashrc
P/s It may be better if you edit /etc/profile.d. Take a look both of them.
UPDATE
In MacOS, let edit ~/.bash_profile (create it if it does not exist) with the same content.
Need to downgrade php to 5.2.x, so I followed this tutorial:
http://andreys.info/blog/2010-03-25/compile-php-5-2-on-osx-10-6-snow-leopard#comment-631
I'm on snow leopard 10.6.4, with xcode installed.
So I compiled php5.2.x and completed the tutorial. phpinfo() loaded within the browser at htp://localhost says 5.2.x, Great!! But, Terminal command "php --version" says 5.3.x ??
While compiling/installing php5.2.x, the new module file replaced the php5.3.x module here:
/usr/libexec/apache2/libphp5.so
So where is Terminal getting 5.3.x from?
Do I have two php versions being loaded?
Should I even care?
For a more direct solution to the problem:
Rename the OLD version of PHP
sudo mv /usr/bin/php /usr/bin/php5424
Create a Symbolic link for your new version of php so it can live in /usr/bin
sudo ln -s /usr/local/php5/bin/php /usr/bin/php
Check using which php. This should tell you which is being used.
Yes, looks like you have two installed at different locations.
Yes, mind what's being used where. Having multiple versions is absolutely valid (at least on a development or testing system) but you always should be aware of the versions being used.