I'm trying to move my Project to a linux redhat server that uses Apache but the problem I'm facing there is that this Server has 2 different PHP versions installed.
Symfony (2.5.12) seems to look for the php executable at /usr/bin/php
by default but there is a 5.2 version installed, which is needed for other projects.
At /opt/rh/php55/root/usr/bin/php
is an installed 5.5 version of PHP that I want to use for symfony.
So how can I configure Symfony to use the php version that is installed at the custom path?
If it's your web application that's using the wrong version of PHP, this is an Apache configuration issue. If it's the command line, this is actually a pretty easy thing to fix, you just need to make sure that /opt/rh/php55/root/usr/bin/
is in your $PATH
before /usr/bin
.
You can do this in your ~/.bashrc
or ~/.bash_profile
with this:
export PATH=/opt/rh/php55/root/usr/bin:$PATH
Just put that at the end, log out and in again. You can also just pop that in your command line directly, but it'll only apply for the current session, so the ~/.bashrc
or ~/.bash_profile
options are better.
I know this is old, but I had the same issue of Symfony using an older PHP version (7.1 in my case, the default with OSX Mojave) than I had installed. My $PATH
variable pointed to the newer 7.2 version and php -v
showed 7.2 and still Symfony used 7.1.
It looks like this was solved when I ran:
symfony local:php:list
It listed all the PHP versions on my system and it had 7.2 marked as default. After running this and executing symfony server:start
it was on 7.2.
The php:list
command also give useful instructions on setting a specific PHP version for a project:
To control the version used in a directory, create a .php-version
file that contains the version number (e.g. 7.2 or 7.2.15).
If you're using SymfonyCloud, the version can also be specified in the .symfony.cloud.yaml
file.