How to install laravel on a server running different php versions

我是研究僧i 提交于 2020-01-12 10:47:08

问题


im having issues to install laravel under my server running php 5.3 by default BUT i'm able to pick a version of php to run under any specific directory.

guzzlehttp/guzzle 4.1.2 requires php >=5.4.0 -> your PHP version does not satisfy that requirement.

so i choose php 5.4 to run on the directory that im trying to install laravel, but composer do not know that im running PHP 5.4 in that directory.

How to fix this problem?


回答1:


Try running composer command with --ignore-platform-reqs, e.g.

composer install --ignore-platform-reqs



回答2:


When you execute composer install/update it runs with your default PHP version of your machine. To make it work with specific versions (that's example path on my Mac) please change it with your executable php path.

/usr/local/Cellar/php71/7.1.8_20/bin/php composer.phar install



回答3:


This might help some... composer is likely to be using /usr/bin/php, consider the following:-

$ which php
/usr/bin/php

$ /usr/bin/php -v
PHP 7.1.33

$ php -v
PHP 7.2.24

$ type -a php
php is aliased to '/usr/bin/php7.2'
php is /usr/bin/php

$ which composer
/usr/local/bin/composer

As you can see our hosting has an alias to ensure the configured version of php (for webserver) is used on command line. But composer is configured to use /usr/bin/php.

The following is a workaround for the above circumstance.

Update .bash_aliases file

alias php="/usr/bin/php7.2"
alias composer="/usr/bin/php7.2 /usr/local/bin/composer"

Once logged out of terminal and logged back in...

$ type -a composer
composer is aliased to '/usr/bin/php7.2 /usr/local/bin/composer'
composer is /usr/local/bin/composer

composer is now using the correct php version.



来源:https://stackoverflow.com/questions/29907807/how-to-install-laravel-on-a-server-running-different-php-versions

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