Symfony is linked to the wrong PHP version

若如初见. 提交于 2019-12-23 09:25:34

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/32482664/symfony-is-linked-to-the-wrong-php-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!